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

# Execute Tool Call • AI Agent SDK

> execute_tool_call: Execute a tool call with all hooks and middleware.

# execute\_tool\_call

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

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

Execute a tool call with all hooks and middleware.

Order:

1. before\_tool hooks (in order)
2. wrap\_tool\_call middleware chain
3. actual tool call
4. after\_tool hooks (in reverse order)

```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: execute_tool_call"]
    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 execute_tool_call(request: ToolRequest, tool_fn: Callable[[ToolRequest], ToolResponse]) -> ToolResponse
```

## Parameters

<ParamField query="request" type="ToolRequest" required={true}>
  No description available.
</ParamField>

<ParamField query="tool_fn" type="Callable" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="ToolResponse">
  The result of the operation.
</ResponseField>

## Uses

* `tool_fn`
* `run_before_tool`
* `run_after_tool`
* `execute`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/hooks/middleware.py#L413">
  `praisonaiagents/hooks/middleware.py` at line 413
</Card>

***

## Related Documentation

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

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

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