From e4d575e563f83a89fa2ccf3ae911871381d0d82d Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 29 Mar 2026 18:21:36 -0700 Subject: [PATCH] fix: report subagent status as completed when summary exists (#3829) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tools/delegate_tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py index f974ee8ffc..b5b0a57c4b 100644 --- a/tools/delegate_tool.py +++ b/tools/delegate_tool.py @@ -289,7 +289,10 @@ def _run_single_child( if 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" else: status = "failed"