AgentSetupHooksMixin#
Build extensions, choose hooks, and manage request-scoped state. See the guide.
- class zett_agent.extensions.base.AgentSetupHooksMixin[源代码]#
Hooks that prepare request-scoped tools and conversation context.
- async on_tool(context)[源代码]#
Register local or provider-hosted tools before context restoration.
All extensions finish this hook before the first on_state() call, so prompt extensions can reliably inspect
context.toolsandcontext.server_toolsas complete request-scoped registries.示例
Usage:
async def on_tool(self, context): context.register_tool(read_file) context.register_server_tool(ServerToolDefinition(type="web_search"))
- 参数:
context (AgentRunContext)
- 返回类型:
None
- async on_state(context)[源代码]#
Restore history and initialize state before any input conversion.
示例
Usage:
async def on_state(self, context): context.add_message(SystemMessage(content="Use concise answers."), index=0)
- 参数:
context (AgentRunContext)
- 返回类型:
None
- async on_message(context)[源代码]#
Transform context.input_message after state restoration, before append.
Replace the pending UserMessage to implement externally selected modes. Do not append or persist it here: the runtime appends the final message exactly once after all input hooks finish. before_run sees that message through
AgentRunContext.add_message()orAgentRunContext.replace_messages(), and persistence subscribers have already received it.- 参数:
context (AgentRunContext)
- 返回类型:
None