fix: report subagent status as completed when summary exists#3829
Merged
fix: report subagent status as completed when summary exists#3829
Conversation
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.
itsXactlY
pushed a commit
to itsXactlY/hermes-agent
that referenced
this pull request
Mar 30, 2026
…earch#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 NousResearch#1899.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a subagent hit
max_iterations, its status was always reported as"failed"even when it produced a usable summary. This is becauserun_agent.pysetscompleted = final_response is not None and api_call_count < self.max_iterations— so hitting the iteration limit always meanscompleted=False, regardless of output.Fix
Gate status on whether a summary was produced, not on the
completedflag:The
exit_reasonfield already distinguishes"completed"vs"max_iterations"for anything that needs to know how the task ended. Thestatusfield now answers "did the subagent produce usable output?"Tests
54 existing delegation tests pass. No test changes needed — existing tests already assert
status: "completed"for tasks with summaries.Closes #1899 (took the intent, simplified the approach — original PR used fragile error-substring scanning of tool messages).