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

# Middleware Manager • AI Agent SDK

> MiddlewareManager: Manages middleware for an agent.

# MiddlewareManager

> Defined in the [**middleware**](../modules/middleware) module.

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

Manages middleware for an agent.

Provides methods to execute before/after hooks and middleware chains
for both model and tool calls.

## Constructor

<ParamField query="hooks" type="Optional" required={false}>
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="has_model_hooks()" icon="function" href="../functions/MiddlewareManager-has_model_hooks">
    Check if any model hooks are registered.
  </Card>

  <Card title="has_tool_hooks()" icon="function" href="../functions/MiddlewareManager-has_tool_hooks">
    Check if any tool hooks are registered.
  </Card>

  <Card title="run_before_model()" icon="function" href="../functions/MiddlewareManager-run_before_model">
    Run all before\_model hooks.
  </Card>

  <Card title="run_after_model()" icon="function" href="../functions/MiddlewareManager-run_after_model">
    Run all after\_model hooks (in reverse order).
  </Card>

  <Card title="run_before_tool()" icon="function" href="../functions/MiddlewareManager-run_before_tool">
    Run all before\_tool hooks.
  </Card>

  <Card title="run_after_tool()" icon="function" href="../functions/MiddlewareManager-run_after_tool">
    Run all after\_tool hooks (in reverse order).
  </Card>

  <Card title="execute_model_call()" icon="function" href="../functions/MiddlewareManager-execute_model_call">
    Execute a model call with all hooks and middleware.
  </Card>

  <Card title="execute_tool_call()" icon="function" href="../functions/MiddlewareManager-execute_tool_call">
    Execute a tool call with all hooks and middleware.
  </Card>
</CardGroup>

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Middleware Feature" icon="layer-group" href="/docs/features/middleware" />
</CardGroup>
