[Bug] Background subagents report status: completed with empty/partial results and no output
Bug Description
Title: Background subagents report status: completed while returning no result / partial reasoning — causes silent re-work
Body:
Claude Code, Opus 5 / Sonnet 5 subagents, macOS. Long session (~6.5h) running ~30 background subagents that each read 4–15 large images (3024px) and write a report file.
Issue: Background subagents repeatedly terminated with status: completed in the task-notification while having produced no usable output. Observed 4–5 times in one session, in three distinct shapes:
1. Agent "completes" with an empty inline result and no report file written at all.
2. Agent "completes" with its final result being a mid-reasoning fragment — e.g. the entire returned result was: "Let me check the actual pixel dimensions and crop the exact region..." — clearly not a finished answer.
3. Agent writes only the header of its output file, then stops.
These consistently occurred at roughly 100–150k subagent tokens. Smaller-scoped agents (4 frames instead of 8) survived reliably, which suggests a context/size cliff rather than a task-specific bug.
Why it costs real tokens: [REDACTED] completed is indistinguishable from success, so the orchestrating agent has to detect failure by inspecting the filesystem, then re-run the whole subagent. Each re-run re-reads the same large images.
Secondary issue: dead agents aren't recoverable. SendMessage to the agent ID returns No transcript found for agent ID: <id>, so partial work can't be salvaged and must be redone from scratch.
Suggested fixes:
- Distinguish "completed" from "terminated without producing a result" in the task-notification status.
- Surface a token/context-exhaustion reason when that's the cause.
- Preserve subagent transcripts so a truncated agent can be resumed rather than re-run.
Workaround that worked: scope subagents smaller (halve the workload) and instruct them to write output incrementally as they go, so a truncated run still leaves partial signal.
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.1.226
- Feedback ID: 37e4b284-6e57-4b34-b07b-55a5f66dfe73
Errors
[]This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗