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
</div>
This function is defined in the middleware 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).
Signature
def as_step_hook(callback: Callable[[Any], Any]) -> AfterModelFnParameters
ParamField
CallableNo description available.
Returns
ResponseField
AfterModelFnThe result of the operation.
Source
View on GitHubpraisonaiagents/hooks/middleware.py at line 339