nemoguardrails.server.hooks.app
The hooks server: checks the tool call in each agent hook with one config’s tool-call rails, on IORails.
Module Contents
Classes
Functions
Data
API
Bases: ConfigurationError
A config the hooks server can’t serve, found before it answers any request.
Check the tool call the hook carries, and answer with the agent’s allow or deny, or an error status.
The server’s IORails engine for config, never LLMRails, which can’t run tool checks.
Raise when hooks_server.allowed_tools lists tools but leaves allow_unlisted_tools to its default.
Raise unless a tool-call rail uses any main model, and tool lists replace the tools it declares.
Raise when rails.tool_call.flows lists a rail, which can’t deny a call the tool policy allows.
Raise when the tool policy denies every call to a tool that per-tool rails are configured for.
Raise unless the tool policy or a per-tool rail can deny a call, since otherwise every call is allowed.
Decide the hook’s call with the tool policy, then run its tool’s per-tool rails on it, and log the verdict.
Whether config lists a per-tool rail for any tool’s calls.
Start the metrics exporter and the engine before the server accepts requests, and stop them on shutdown.
Log one line for a check, without the tool’s input; an error, which no rail decided, as a warning.
config’s main model, or None without one.
The tool call body asks to check on adapter’s path, raising a failure for the shared 422 handler.
The request body as JSON, whatever its Content-Type says.
Whether a global or per-tool tool-call rail names model_type with $model=.
Answer a hook_event_name the path doesn’t handle with 422 unsupported_hook_event.
Warn that the hooks server ignores the tools a main model declares, since the tool policy replaces them.
Warn that the scrape endpoint will show no guardrails metrics, when the config doesn’t turn them on.
Raise HooksConfigError unless IORails can serve config, it can deny a call, its rails and main run, and
an allowlist says whether unlisted tools are allowed.
Build the hooks server for config, with its own engine; raises HooksConfigError if it can’t serve hooks.
Answer a Claude Code hook in Claude Code’s hook output format.
Answer a Codex hook in Codex’s hook output format.
Answer a NeMo Relay tool conditional-execution guardrail with its decision.
Return HTTP 200 while the server process is running and able to serve requests.
The NEMO_GUARDRAILS_SERVER_METRICS_* exporter settings, with the hooks server’s defaults for those unset.