fix: report subagent status as completed when summary exists (#3829)

When a subagent hit max_iterations, status was always 'failed' even
if it produced a usable summary via _handle_max_iterations(). This
happened because the status check required both completed=True AND
a summary, but completed is False whenever max_iterations is reached
(run_agent.py line 7969).

Now gates status on whether a summary was produced — if the subagent
returned a final_response, the parent has usable output regardless of
iteration budget. The exit_reason field already distinguishes
'completed' vs 'max_iterations' for anything that needs to know how
the task ended.

Closes #1899.
This commit is contained in:
Teknium
2026-03-29 18:21:36 -07:00
committed by GitHub
parent 2a0e8b001f
commit e4d575e563

View File

@@ -289,7 +289,10 @@ def _run_single_child(
if interrupted: if interrupted:
status = "interrupted" status = "interrupted"
elif completed and summary: elif summary:
# A summary means the subagent produced usable output.
# exit_reason ("completed" vs "max_iterations") already
# tells the parent *how* the task ended.
status = "completed" status = "completed"
else: else:
status = "failed" status = "failed"