Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Lifecycle

RunHooksmodule-attribute

RunHooks=RunHooksBase[TContext,Agent]

Run hooks when usingAgent.

AgentHooksmodule-attribute

AgentHooks=AgentHooksBase[TContext,Agent]

Agent hooks forAgents.

RunHooksBase

Bases:Generic[TContext,TAgent]

A class that receives callbacks on various lifecycle events in an agent run. Subclass andoverride the methods you need.

on_llm_startasync

on_llm_start(context:RunContextWrapper[TContext],agent:Agent[TContext],system_prompt:Optional[str],input_items:list[TResponseInputItem],)->None

Called just before invoking the LLM for this agent.

on_llm_endasync

on_llm_end(context:RunContextWrapper[TContext],agent:Agent[TContext],response:ModelResponse,)->None

Called immediately after the LLM call returns for this agent.

on_agent_startasync

on_agent_start(context:RunContextWrapper[TContext],agent:TAgent)->None

Called before the agent is invoked. Called each time the current agent changes.

on_agent_endasync

on_agent_end(context:RunContextWrapper[TContext],agent:TAgent,output:Any,)->None

Called when the agent produces a final output.

on_handoffasync

on_handoff(context:RunContextWrapper[TContext],from_agent:TAgent,to_agent:TAgent,)->None

Called when a handoff occurs.

on_tool_startasync

on_tool_start(context:RunContextWrapper[TContext],agent:TAgent,tool:Tool,)->None

Called immediately before a local tool is invoked.

on_tool_endasync

on_tool_end(context:RunContextWrapper[TContext],agent:TAgent,tool:Tool,result:str,)->None

Called immediately after a local tool is invoked.

AgentHooksBase

Bases:Generic[TContext,TAgent]

A class that receives callbacks on various lifecycle events for a specific agent. You canset this onagent.hooks to receive events for that specific agent.

Subclass and override the methods you need.

on_startasync

on_start(context:RunContextWrapper[TContext],agent:TAgent)->None

Called before the agent is invoked. Called each time the running agent is changed to thisagent.

on_endasync

on_end(context:RunContextWrapper[TContext],agent:TAgent,output:Any,)->None

Called when the agent produces a final output.

on_handoffasync

on_handoff(context:RunContextWrapper[TContext],agent:TAgent,source:TAgent,)->None

Called when the agent is being handed off to. Thesource is the agent that is handingoff to this agent.

on_tool_startasync

on_tool_start(context:RunContextWrapper[TContext],agent:TAgent,tool:Tool,)->None

Called immediately before a local tool is invoked.

on_tool_endasync

on_tool_end(context:RunContextWrapper[TContext],agent:TAgent,tool:Tool,result:str,)->None

Called immediately after a local tool is invoked.

on_llm_startasync

on_llm_start(context:RunContextWrapper[TContext],agent:Agent[TContext],system_prompt:Optional[str],input_items:list[TResponseInputItem],)->None

Called immediately before the agent issues an LLM call.

on_llm_endasync

on_llm_end(context:RunContextWrapper[TContext],agent:Agent[TContext],response:ModelResponse,)->None

Called immediately after the agent receives the LLM response.


[8]ページ先頭

©2009-2025 Movatter.jp