State-driven transitions pattern.
Enables dynamic transfer of control between agent processes.
A handoff tool is added to an agent's tools list. When the LLM
invokes it, the agent's tool loop returns a {:handoff, target, context}
tuple to the caller, who can then redirect future messages.
Summary
Functions
Creates a tool that triggers a handoff to the target agent when invoked.
Sends a context to the target agent via GenServer.cast.
Produces a trimmed context suitable for the receiving agent.
Types
@type handoff_result() :: {:handoff, target :: pid() | atom(), ExAgent.Context.t()}
Functions
@spec build_handoff_tool(String.t(), pid() | atom(), String.t()) :: ExAgent.Tool.t()
Creates a tool that triggers a handoff to the target agent when invoked.
The tool accepts a "summary" parameter that the LLM uses to
summarize the conversation before handoff.
@spec execute_handoff(pid() | atom(), ExAgent.Context.t()) :: :ok
Sends a context to the target agent via GenServer.cast.
@spec transfer_context(ExAgent.Context.t(), map()) :: ExAgent.Context.t()
Produces a trimmed context suitable for the receiving agent.
Adds a system message summarizing the handoff.