> ## 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 Step Hook • AI Agent SDK

> as_step_hook: Adapt a plain ``on_step`` callback into an ``after_model`` middleware hook.

# as\_step\_hook

Function

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

Adapt a plain `on_step` callback into an `after_model` middleware hook.

`HooksConfig(on_step=...)` advertises "called once per agent step". An
agent step is one model call, so the callback is routed onto the existing
`after_model` middleware slot: it is invoked with the :class:`ModelResponse`
for the step and its return value is ignored (the response passes through
unchanged, so an observer can never corrupt the run).

```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 TD
    event["Event Trigger"] --> hook["Hook: as_step_hook"]
    hook --> decision{"Decision"}
    decision -- "Allow" --> proc["Process"]
    decision -- "Deny" --> block["Block"]
    style hook fill:#189AB4,color:#fff
    style event fill:#8B0000,color:#fff
    style proc fill:#8B0000,color:#fff
    style block fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def as_step_hook(callback: Callable[[Any], Any]) -> AfterModelFn
```

## Parameters

**callback** `Callable` *required*

No description available.

### Returns

**Returns** `AfterModelFn`

The result of the operation.

## Source

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

***

## Related Documentation

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

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

> **[Callbacks](https://praison.ai/docs/docs/features/callbacks)**


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