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

# decorator • AI Agent SDK

> Tool decorator for converting functions into tools.

# decorator

AI Agent

Tool decorator for converting functions into tools.

This module provides the @tool decorator for easily creating tools from functions.

Usage:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import tool

@tool
def search(query: str) -> list:
    '''Search the web for information.'''
    return [...]

# Or with explicit parameters:
@tool(name="web_search", description="Search the internet")
def search(query: str, max_results: int = 5) -> list:
    return [...]

# With injected state:
from praisonaiagents.tools import Injected

@tool
def my_tool(query: str, state: Injected[dict]) -> str:
    '''Tool with injected state.'''
    return f"session={state.get('session_id')}"

# Requiring human approval (mirrors Agent(approval=...)):
@tool(approval=True)
def refund_order(order_id: str) -> str:
    return "refunded"

# Guarding just this one tool's arguments and result:
def internal_only(arguments: dict):
    if not arguments["to"].endswith("@corp.com"):
        return False, "Recipient is outside the company domain."
    return True, arguments

@tool(input_guardrails=[internal_only])
def send_email(to: str, body: str) -> str:
    return "sent"
```

## Import

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents.tools import decorator
```

## Classes

> [card] [FunctionTool](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/FunctionTool.md)
>
> A BaseTool wrapper for plain functions.

## Functions

> [card] [is\_injected\_type()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/is_injected_type.md)
>
> Function definition.

> [card] [get\_injected\_params()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/get_injected_params.md)
>
> Function definition.

> [card] [inject\_state\_into\_kwargs()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/inject_state_into_kwargs.md)
>
> Function definition.

> [card] [tool()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/tool.md)
>
> Decorator to convert a function into a tool.

> [card] [is\_tool()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/is_tool.md)
>
> Check if an object is a tool (BaseTool instance or decorated function).

> [card] [get\_tool\_schema()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/get_tool_schema.md)
>
> Get OpenAI-compatible schema for any tool-like object.

### Constants

| Name | Value |
| - | - |
| `_VALID_RISK_LEVELS` | `('critical', 'high', 'medium', 'low')` |
| `_UNSET` | `object()` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.