AgentRunHooksMixin#

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

class zett_agent.extensions.base.AgentRunHooksMixin[源代码]#

Hooks around one complete request and its terminal outcome.

async before_run(context)[源代码]#

Run after the transformed user input is appended and published.

参数:

context (AgentRunContext)

返回类型:

None

async after_run(context, result)[源代码]#

Run after a successful final answer is appended.

参数:
返回类型:

None

async on_success(context, result)[源代码]#

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.

示例

Usage:

async def on_success(self, context, result):
    await save_answer(context.session_id, result.content)
参数:
返回类型:

None

async on_error(context, error)[源代码]#

Run before an agent error is propagated to the caller.

参数:
返回类型:

None