AgentRunHooksMixin#

Build extensions, choose hooks, and manage request-scoped state. See the guide.

class zett_agent.extensions.base.AgentRunHooksMixin[source]#

Hooks around one complete request and its terminal outcome.

async before_run(context)[source]#

Run after the transformed user input is appended and published.

Parameters:

context (AgentRunContext)

Return type:

None

async after_run(context, result)[source]#

Run after a successful final answer is appended.

Parameters:
Return type:

None

async on_success(context, result)[source]#

Run once after all after_run hooks succeed, before RUN_COMPLETED.

This callback observes a completed request, not an intermediate model step. Failed or cancelled requests do not trigger it. Callback errors propagate through on_error and prevent RUN_COMPLETED from being emitted.

Examples

Usage:

async def on_success(self, context, result):
    await save_answer(context.session_id, result.content)
Parameters:
Return type:

None

async on_error(context, error)[source]#

Run before an agent error is propagated to the caller.

Parameters:
Return type:

None