Repository navigation
perf(agent): a finished worker returns its report, not every step - #423
Merged
Merged
Conversation
A subagent's result was the concatenation of the text from every step: "Let me read n.txt first.", "Now I'll check the tests.", ... and then the actual findings. All of it landed in the parent's context as one tool result. A worker that finishes now returns the text of its last step that said anything. Every worker's system prompt (built-in or custom agent) ends with a short `# Report` note saying only its final message reaches the parent, so findings are not left in earlier messages. An unfinished worker still returns its full step log, which gives the parent more to pick up from. Structured output already reads the final message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
force-pushed
the
perf/subagent-final-report
branch
from
November 7, 2026 13:48
fd5ddcd to
bd4d5db
Compare
Merged
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.
Part of the token-efficiency series (#418–#422).
Problem
A subagent's result was the concatenation of the text from every step: "Let me read n.txt first.", "Now I'll check the tests.", …, and only then the actual findings. All of it landed in the parent's context as one tool result, typically 0.5–3k tokens per
taskcall, with the narration carrying no information.Change
subagent.rs).# Reportnote: only its final message reaches the parent, so put every finding there. Findings therefore are not left in earlier messages.Checks
finished_worker_returns_its_report_not_every_step: a narrated tool step followed by a report step returns exactly the report.whycodes-agent --libpasses (765). fmt and clippy are ok. Local llvm-cov: every changed line is covered.execute_schedule_tool_command_and_goal,execute_bg_kill_already_status…) failed once under instrumented coverage. They pass in a normal run and do not touch this code.🤖 Generated with Claude Code