AgentConfig.SubAgents to give an agent the call_sub_agent tool. A SubAgentClient controls which agents are available and how messages reach them. The built-in registry client lives in pkg/agents/subagents.
Create a catalog
Withmodel configured, import pkg/agents/subagents and pkg/agents/prompts:
call_sub_agent.
Choose availability
The caller is excluded from ordinary registry entries;
WithSelf adds it separately. Name include/exclude options filter registry entries. Use WithFilter when policy should also restrict the self entry. All filters must accept an entry for it to be available.
A self call runs the calling agent’s configuration in a separate thread. It does not receive the parent’s conversation. The default prompt resolvers include ResolveSubAgents, which lists names and descriptions.
Call and follow up
The model sends arguments such as:syncwaits and returns the child’s answer as the tool result.asyncreturns an acknowledgement immediately; the task later delivers its answer to the parent’s thread.thread_idcontinues a previously returned child thread; omit it for a new thread.
ParentThreadID, and are Hidden. Their default group is the calling thread ID. Ordinary thread listings omit them; include_hidden=true includes them within the requested group. History stays separate while attachments can share session scope.
Human input from an async child
An async child that pauses for approval or input keeps its task pending. The parent thread’s history response exposesrun.backgroundTasks with agentName, agentThreadId, and pending interrupts. Answer those interrupts by posting resume entries to the child agent and child thread. After the child finishes, its answer is delivered to the parent.
A call_sub_agent call in sync mode reports a child pause as unfinished work; it does not forward that interruption through the parent. Use the synchronous agent tool if the parent must pause and relay the child’s decision.
Runtime behavior
Local background tasks live in the process. Temporal and Restate run their waits separately from the parent run. A task’s fixed message ID lets a retried wait recognize a persisted child turn. External tool effects still need idempotency, and all workers need access to the same history and broker. Customagents.SubAgentClient implementations provide ListSubAgents, RunSubAgent, and SteerSubAgent. Both execution methods must enforce the same allowed catalog as listing and support concurrent use.