> This page is for version Latest (default).
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.25.0: https://docs.nvidia.com/nemo/guardrails/v0.25.0/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.

# nemoguardrails.server.hooks.adapters

Each agent's hook interface: the event its path handles, the tool call that event asks to check, and its answer.

## Module Contents

### Classes

| Name                                                                                           | Description                                                                                                   |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [`HookAdapter`](#nemoguardrails-server-hooks-adapters-HookAdapter)                             | One agent's path: the event it handles, the tool call that event's body carries, and each outcome's response. |
| [`UnsupportedHookEventError`](#nemoguardrails-server-hooks-adapters-UnsupportedHookEventError) | A `hook_event_name` that the agent's path doesn't handle.                                                     |

### Functions

| Name                                                                                         | Description                                                                                               |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [`_pre_tool_use_invocation`](#nemoguardrails-server-hooks-adapters-_pre_tool_use_invocation) | The tool call a Claude Code or Codex `PreToolUse` hook asks to check.                                     |
| [`_pre_tool_use_output`](#nemoguardrails-server-hooks-adapters-_pre_tool_use_output)         | Claude Code's and Codex's `PreToolUse` output: no decision for an allow, the deny shape for a deny.       |
| [`_relay_decision`](#nemoguardrails-server-hooks-adapters-_relay_decision)                   | The verdict the Relay plugin turns into its guardrail callback's `Ok(None)` or `Ok(Some(reason))`.        |
| [`_relay_invocation`](#nemoguardrails-server-hooks-adapters-_relay_invocation)               | The tool call a NeMo Relay guardrail asks to check, with no id: Relay passes its guardrail callback none. |
| [`_require_decision`](#nemoguardrails-server-hooks-adapters-_require_decision)               | Raise for an error outcome, which is answered with an error status, not a `200` body.                     |

### Data

[`ADAPTERS`](#nemoguardrails-server-hooks-adapters-ADAPTERS)

[`DENY_REASON_PREFIX`](#nemoguardrails-server-hooks-adapters-DENY_REASON_PREFIX)

[`HookAgent`](#nemoguardrails-server-hooks-adapters-HookAgent)

### API

```python
class nemoguardrails.server.hooks.HookAdapter(
    agent: nemoguardrails.server.hooks.adapters.HookAgent,
    event: str,
    request_model: type[pydantic.BaseModel],
    invocation: typing.Callable[[Any], nemoguardrails.server.hooks.checking.ToolInvocation],
    response_body: typing.Callable[[HookOutcome], dict]
)
```

Dataclass

One agent's path: the event it handles, the tool call that event's body carries, and each outcome's response.

**`agent`** `HookAgent`

---

**`event`** `str`

---

**`invocation`** `Callable[[Any], ToolInvocation]`

---

**`request_model`** `type[BaseModel]`

---

**`response_body`** `Callable[[HookOutcome], dict]`

---

```python
nemoguardrails.server.hooks.HookAdapter.parse(
    body: object
) -> nemoguardrails.server.hooks.checking.ToolInvocation
```

The tool call *body* asks to check, as this path's event; error locations are relative to the body.

```python
class nemoguardrails.server.hooks.UnsupportedHookEventError(
    agent: nemoguardrails.server.hooks.adapters.HookAgent,
    event: str,
    handled_event: str
)
```

Exception

**Bases:** `Exception`

A `hook_event_name` that the agent's path doesn't handle.

```python
nemoguardrails.server.hooks.adapters._pre_tool_use_invocation(
    request: typing.Union[nemoguardrails.server.hooks.schemas.ClaudeCodePreToolUseRequest, nemoguardrails.server.hooks.schemas.CodexPreToolUseRequest]
) -> nemoguardrails.server.hooks.checking.ToolInvocation
```

The tool call a Claude Code or Codex `PreToolUse` hook asks to check.

```python
nemoguardrails.server.hooks.adapters._pre_tool_use_output(
    outcome: nemoguardrails.server.hooks.checking.HookOutcome
) -> dict
```

Claude Code's and Codex's `PreToolUse` output: no decision for an allow, the deny shape for a deny.

```python
nemoguardrails.server.hooks.adapters._relay_decision(
    outcome: nemoguardrails.server.hooks.checking.HookOutcome
) -> dict
```

The verdict the Relay plugin turns into its guardrail callback's `Ok(None)` or `Ok(Some(reason))`.

```python
nemoguardrails.server.hooks.adapters._relay_invocation(
    request: nemoguardrails.server.hooks.schemas.NemoRelayToolConditionalExecutionGuardrailRequest
) -> nemoguardrails.server.hooks.checking.ToolInvocation
```

The tool call a NeMo Relay guardrail asks to check, with no id: Relay passes its guardrail callback none.

```python
nemoguardrails.server.hooks.adapters._require_decision(
    outcome: nemoguardrails.server.hooks.checking.HookOutcome
) -> None
```

Raise for an error outcome, which is answered with an error status, not a `200` body.

```python
nemoguardrails.server.hooks.adapters.ADAPTERS: dict[HookAgent, HookAdapter] = {(adapter.agent): adapter for adapter in (HookAdapter(agent='claude-code', event...
```

```python
nemoguardrails.server.hooks.adapters.DENY_REASON_PREFIX = 'NeMo Guardrails: '
```

```python
nemoguardrails.server.hooks.adapters.HookAgent = Literal['claude-code', 'codex', 'nemo-relay']
```