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:
| Field | Type | Description |
|---|---|---|
subagent_name | str | Name of the subagent that was invoked. |
success | bool | Whether the subagent completed successfully. |
output_text | str or None | The subagent’s response text, if it completed. |
latency_ms | float | Wall-clock execution time in milliseconds. |
error | str or None | Error message if the subagent failed. |
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.