fix(agents): stop raw tool output leaking into subagent completion announces#80049
fix(agents): stop raw tool output leaking into subagent completion announces#80049blaspat wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. for source-level reproduction: current main selects Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land one canonical raw-output leak fix with aligned subagent and tasks docs plus real Telegram/runtime proof, then track the duplicate-progress symptom separately unless this PR proves it too. Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: current main selects Is this the best way to solve the issue? Yes for the central raw-output leak: returning Full review comments:
Overall correctness: patch is correct What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 4f053b87048f. |
…nounces selectSubagentOutputText() was falling through to snapshot.latestRawText when no assistant-produced text was available. Raw tool output is not user-facing content and must not be delivered as completion text. Fix: return undefined instead of snapshot.latestRawText so the caller falls back to readLatestAssistantReply (post-compaction result) or synthesizes a bounded failure summary. Updated tests that expected raw tool output to be announced — they now correctly expect '(no output)' since no assistant-composed text exists. Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
ff96117 to
d43cb97
Compare
|
Thanks @blaspat. Closing this in favor of #80110, which preserves the core fix from this PR and credits your commit in the replacement maintainer commit. Why this PR was not mergeable as-is:
Replacement PR #80110 keeps the important runtime change, adds the missing docs/test/changelog coverage, and includes Crabbox/Testbox proof:
Thanks again for identifying the right core selector bug. |
Summary
Fixes #79986 — Subagent announce leaks raw tool output to Telegram and duplicates parent progress reply.
Root cause:
selectSubagentOutputText()insrc/agents/subagent-announce-output.tswas falling through tosnapshot.latestRawText(from tool/toolResult messages) when no assistant-produced text was available. Raw tool output is not user-facing content and must not be delivered as completion text.Fix: Return
undefinedinstead ofsnapshot.latestRawTextso the caller falls back toreadLatestAssistantReply()(post-compaction result) or synthesizes a bounded failure summary.Files changed
src/agents/subagent-announce-output.ts— StopselectSubagentOutputTextfrom returning raw tool outputsrc/agents/subagent-announce.format.e2e.test.ts— Updated tests that expected raw tool output to be announced to correctly expect(no output)Acceptance criteria
pnpm test --run src/agents/subagent-announce.format.e2e.test.ts src/agents/subagent-announce-output.test.ts src/agents/subagent-announce-delivery.test.ts src/gateway/server-methods/agent.test.ts✅pnpm test --run src/gateway/server-chat.agent-events.test.ts✅pnpm exec oxfmt --check --threads=1 on: ...✅Real Behavior Proof
Before fix (buggy behavior):
A subagent completes a task with tool-only output (no assistant text). The completion announce sends raw tool output to Telegram:
After fix (correct behavior):
Same scenario now produces a bounded
(no output)summary instead of raw tool text:How to reproduce:
sessions_spawn runtime="subagent") that runs a task producing tool-only output (e.g., a file write with no assistant reply)(no output)