> 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.tool_policy

The hooks server's tool policy: which tools an agent's call may use, and which of their arguments it may pass.

## Module Contents

### Classes

| Name                                                                | Description                                                                                                 |
| ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| [`ToolPolicy`](#nemoguardrails-server-hooks-tool_policy-ToolPolicy) | `hooks_server.allowed_tools`, `blocked_tools` and `allow_unlisted_tools`, read once when the server starts. |

### Functions

| Name                                                            | Description                                                                  |
| --------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [`_entries`](#nemoguardrails-server-hooks-tool_policy-_entries) | Each tool a list names, with its entry's arguments, or None for a bare name. |

### Data

[`ToolArguments`](#nemoguardrails-server-hooks-tool_policy-ToolArguments)

### API

```python
class nemoguardrails.server.hooks.tool_policy.ToolPolicy(
    allowed: collections.abc.Mapping[str, nemoguardrails.server.hooks.tool_policy.ToolArguments] = (lambda: MappingProxyType({...,
    blocked: collections.abc.Mapping[str, nemoguardrails.server.hooks.tool_policy.ToolArguments] = (lambda: MappingProxyType({...,
    allow_unlisted: bool = True
)
```

Dataclass

`hooks_server.allowed_tools`, `blocked_tools` and `allow_unlisted_tools`, read once when the server starts.

**`allow_unlisted`** `bool = True`

---

**`allowed`** `Mapping[str, ToolArguments]`

---

**`blocked`** `Mapping[str, ToolArguments]`

---

```python
nemoguardrails.server.hooks.tool_policy.ToolPolicy.allowed_arguments(
    name: str
) -> nemoguardrails.server.hooks.tool_policy.ToolArguments
```

The arguments *name*'s `allowed_tools` entry lists, or None when any argument is allowed.

```python
nemoguardrails.server.hooks.tool_policy.ToolPolicy.blocked_by_name(
    name: str
) -> bool
```

Whether `blocked_tools` names *name* bare, which blocks every call to it.

```python
nemoguardrails.server.hooks.tool_policy.ToolPolicy.decide(
    name: str,
    arguments: collections.abc.Mapping[str, typing.Any]
) -> typing.Optional[str]
```

Why the policy denies a call to *name* with *arguments*, or None when it lets the call through.

```python
nemoguardrails.server.hooks.tool_policy.ToolPolicy.denied_by_name(
    name: str
) -> bool
```

Whether every call to *name* is denied: it's blocked by name, or unlisted while unlisted tools are denied.

```python
nemoguardrails.server.hooks.tool_policy.ToolPolicy.from_config(
    hooks_server: nemoguardrails.rails.llm.config.HooksServerConfig
) -> nemoguardrails.server.hooks.tool_policy.ToolPolicy
```

classmethod

The policy a config's hooks_server section sets.

```python
nemoguardrails.server.hooks.tool_policy._entries(
    tool_list: collections.abc.Iterable[typing.Union[str, nemoguardrails.rails.llm.config.ToolEntry]]
) -> collections.abc.Mapping[str, nemoguardrails.server.hooks.tool_policy.ToolArguments]
```

Each tool a list names, with its entry's arguments, or None for a bare name.

```python
nemoguardrails.server.hooks.tool_policy.ToolArguments = Optional[tuple[str, ...]]
```