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

<Badge color="blue">AI Agent</Badge>

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"
```

## Import

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

## Classes

<CardGroup cols={2}>
  <Card title="FunctionTool" icon="brackets-curly" href="../classes/FunctionTool">
    A BaseTool wrapper for plain functions.
  </Card>
</CardGroup>

## Functions

<CardGroup cols={2}>
  <Card title="is_injected_type()" icon="function" href="../functions/is_injected_type">
    Function definition.
  </Card>

  <Card title="get_injected_params()" icon="function" href="../functions/get_injected_params">
    Function definition.
  </Card>

  <Card title="inject_state_into_kwargs()" icon="function" href="../functions/inject_state_into_kwargs">
    Function definition.
  </Card>

  <Card title="tool()" icon="function" href="../functions/tool">
    Decorator to convert a function into a tool.
  </Card>

  <Card title="is_tool()" icon="function" href="../functions/is_tool">
    Check if an object is a tool (BaseTool instance or decorated function).
  </Card>

  <Card title="get_tool_schema()" icon="function" href="../functions/get_tool_schema">
    Get OpenAI-compatible schema for any tool-like object.
  </Card>
</CardGroup>

### Constants

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