> ## 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 • AI Agent SDK

> tool: Decorator to convert a function into a tool.

# tool

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**decorator**](../modules/decorator) module.

Decorator to convert a function into a tool.

Can be used with or without arguments:

@tool
def my\_func(x: str) -> str:
'''Does something.'''
return x

@tool(name="custom\_name", description="Custom description")
def my\_func(x: str) -> str:
return x

@tool(availability=lambda: (bool(os.getenv("API\_KEY")), "API\_KEY missing"))
def my\_func(x: str) -> str:
return x

@tool(retry\_policy=RetryPolicy(max\_attempts=5))
def my\_func(x: str) -> str:
return x

@tool(approval=True)
def delete\_account(user\_id: str) -> str:
return "deleted"

@tool(approval="critical")
def deploy(env: str) -> str:
return "deployed"

```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"]
    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(func: Optional[Callable]) -> Union[FunctionTool, Callable[[Callable], FunctionTool]]
```

## Parameters

<ParamField query="func" type="Optional[Callable]" required={false}>
  The function to wrap (when used without parentheses)
</ParamField>

### Returns

<ResponseField name="Returns" type="Union[FunctionTool, Callable[[Callable], FunctionTool]]">
  FunctionTool instance that wraps the function
</ResponseField>

## Uses

* `FunctionTool`
* `add_approval_requirement`
* `RuntimeError`
* `tool_instance.validate`
* `tool_instance.validate_schema_roundtrip`
* `logging.warning`
* `logging.debug`
* `get_registry`
* `registry.register`
* `decorator`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/tools/decorator.py#L232">
  `praisonaiagents/tools/decorator.py` at line 232
</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>
