Delegation flow
Example
How the coordinator pattern works
- The lead agent receives the user message and decides how to delegate. It can invoke subagents through tool-like calls that the runner intercepts.
- The runner dispatches each subagent invocation as a separate run. Subagents execute independently with their own instructions and model configuration. The runner manages concurrency, timeout, and failure handling for each subagent.
-
Subagent results are returned to the lead agent as execution records. Each record contains the subagent’s
output_textand optional error information. -
The lead agent receives all subagent outputs and synthesizes them into a unified response. This final synthesis step is what produces the coordinator’s
final_text.
What subagent_executions contains
TheAgentResult returned by the lead agent includes a subagent_executions list. Each entry is a SubagentExecutionRecord with:
You can inspect these records to understand what each subagent contributed:
Subagent failure handling
By default, subagent failure policy iscontinue. You can configure stricter or more resilient behavior using FailSafeConfig:
subagent_failure_policy="retry_then_degrade", the lead agent receives error information for failed subagents alongside successful results and can produce a best-effort synthesis.