Error Propagation
What the platform does
- A subagent returns only its final message to its parent. Intermediate tool failures stay inside it unless that final message reports them. So a subagent's report must state failures and gaps explicitly.
- An API error that ends a subagent early (for example a rate limit) is never delivered as its result; the SDK has defined foreground and background behaviour for it.
- A subagent that reaches
maxTurnsreturns output marked partial, and it can be resumed. PostToolUseFailurehooks fire on tool failure;SubagentStophooks fire on completion, a place to log and aggregate.- Limits exist on spend, depth and concurrency; hitting
maxBudgetUsdends the query witherror_max_budget_usd(1.2).
Principles (design guidance)
- Never suppress silently. A swallowed error becomes a confident wrong answer. Surface what failed.
- Structured error context from subagent to coordinator: what was attempted, what failed (category, retryable), what partial results exist, and what is still unknown.
- Partial results with coverage annotations. If 8 of 10 sources were read, say so ("sources 4 and 9 were unavailable"), do not present the answer as complete.
- Local recovery first, then propagate. Retry transient failures in place (2.2); only propagate what the subagent cannot fix.
- Do not terminate everything for one failure when the task can still produce a useful partial answer; do not continue as if nothing happened when a critical step failed.
- Coordinator decides. With the structured context, it can retry, route to another subagent, accept partial output with a caveat, or escalate (5.2).
Example report from a research subagent
status: partial · completed: 8/10 sources · failed: [{source: "S4", category: "timeout", retryable: true}, {source: "S9", category: "permission", retryable: false}] · findings: [...] · unknowns: ["pricing for vendor B"]
Exam traps
- A subagent that returns "no results" for a failure.
- Aborting the whole pipeline on one non-critical failure.
- The coordinator presenting partial work as complete.
- Error text only for humans (no category or retryable flag for code).
- Assuming an API error reaches the parent as a result. It does not.
References
- Subagents in the SDK — checked Oct 16, 2026
- Hooks in the SDK — checked Oct 16, 2026
Check your understanding
Two of ten sources fail. What should the final answer include?Show answerHide answer
Answer
The findings plus a clear note of which sources were unavailable and what remains unknown.What reaches the coordinator from a subagent?Show answerHide answer
Answer
Its final message, so it must contain the error context.A transient timeout in a tool. Handle locally or propagate?Show answerHide answer
Answer
Retry locally first (bounded); propagate if it persists.