> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool Policy • AI Agent SDK

> tool_policy: Build the :class:`ToolPolicy` this binding declares, if any.

# tool\_policy

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**RouteBinding**](../classes/RouteBinding) class in the [**protocols**](../modules/protocols) module.

Build the :class:`ToolPolicy` this binding declares, if any.

Returns `None` when the binding does not constrain the toolset, so
callers can cheaply skip the apply/restore dance for trusted routes.
The `untrusted` trust tier seeds a conservative substring deny-list;
explicit `allow_tools` / `deny_tools` layer on top of it.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    agent["Agent"] -- "uses" --> tool["Tool: tool_policy"]
    tool -- "returns" --> result["Result"]
    style tool fill:#189AB4,color:#fff
    style agent fill:#8B0000,color:#fff
    style result fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def tool_policy() -> Optional['ToolPolicy']
```

### Returns

<ResponseField name="Returns" type="Optional['ToolPolicy']">
  The result of the operation.
</ResponseField>

## Uses

* `ToolPolicy`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L1779">
  `praisonaiagents/gateway/protocols.py` at line 1779
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Tools Concept" icon="wrench" href="/docs/docs/concepts/tools" />

  <Card title="Create Custom Tools" icon="plus" href="/docs/docs/guides/tools/create-custom-tools" />

  <Card title="Tool Development" icon="code" href="/docs/docs/tutorials/advanced-tool-development" />
</CardGroup>
