LangEx.Prebuilt.Handoff (LangEx v0.11.3)

Copy Markdown View Source

Builds a tool that transfers control from the current agent to another.

A handoff tool is an ordinary %LangEx.Tool{} whose function returns a %LangEx.Command{} setting :active_agent to the target and appending a short transfer reply. The prebuilt team topologies (LangEx.Prebuilt.Swarm, LangEx.Prebuilt.Supervisor) route on :active_agent, so calling the tool hands the conversation to the named agent on the next super-step.

tools = [LangEx.Prebuilt.Handoff.tool(:billing)]

The LLM sees a transfer_to_billing function; invoking it moves the active agent to :billing.

Summary

Functions

Returns a %LangEx.Tool{} that hands control to target.

Functions

tool(target, opts \\ [])

@spec tool(
  atom(),
  keyword()
) :: LangEx.Tool.t()

Returns a %LangEx.Tool{} that hands control to target.

Options

  • :name - tool name the LLM calls (overrides :prefix; default "transfer_to_<target>")
  • :prefix - prepended to the target name to form the tool name (e.g. "delegate_to_" yields "delegate_to_<target>")
  • :description - tool description (default asks the target for help)
  • :task_description - when true, the tool accepts a task_description argument that is passed to the target agent as an explicit task brief (default false, a pure routing handoff)
  • :active_agent_key - state key holding the active agent (default :active_agent)