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

# As Tool Call Hook • AI Agent SDK

> as_tool_call_hook: Adapt a plain ``on_tool_call`` callback into a ``before_tool`` hook.

# as\_tool\_call\_hook

Function

> This function is defined in the [**middleware**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/middleware.md) module.

Adapt a plain `on_tool_call` callback into a `before_tool` hook.

`HooksConfig(on_tool_call=...)` is routed onto the existing `before_tool`
middleware slot, so it fires for every tool the agent executes (sync and
async paths both run through :class:`MiddlewareManager`). The callback
receives the :class:`ToolRequest`; its return value is ignored so the
request passes through unchanged.

```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: as_tool_call_hook"]
    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 as_tool_call_hook(callback: Callable[[Any], Any]) -> BeforeToolFn
```

## Parameters

**callback** `Callable` *required*

No description available.

### Returns

**Returns** `BeforeToolFn`

The result of the operation.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/hooks/middleware.py#L358)
>
> `praisonaiagents/hooks/middleware.py` at line 358

***

## Related Documentation

> [card] [Tools Concept](https://praison.ai/docs/docs/concepts/tools)

> [card] [Create Custom Tools](https://praison.ai/docs/docs/guides/tools/create-custom-tools)

> [card] [Tool Development](https://praison.ai/docs/docs/tutorials/advanced-tool-development)

> [card] [Hooks Concept](https://praison.ai/docs/docs/concepts/hooks)

> [card] [Hook Events](https://praison.ai/docs/docs/features/hook-events)


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