agent_progress messages (155 × 80KB) overflow context while /context reports 33% usage
Bug Description
Session became permanently unresponsive with "Prompt is too long" despite /context showing only 33% usage (66k/200k tokens). The root cause: 155 agent_progress messages consumed 796KB of the 1.1MB session file, but were not reflected in /context token accounting.
Related to #23463 and #24341, but with a distinct mechanism: streaming progress messages from subagents, not just final results.
Environment
- Claude Code v2.1.44
- Model: claude-opus-4-6
- Platform: Linux (Arch)
- CLI (not IDE)
Reproduction Steps
- Start a session, have moderate conversation (~10 user turns)
- Launch 2 subagents (
Explore+general-purpose) that read large source files (C# files, 80KB+) - Agents stream progress back as
agent_progressmessages containing full file contents - One agent fails with internal error (
classifyHandoffIfNeeded is not defined) - Every subsequent message returns "Prompt is too long"
/contextreports 33% usage — 66k/200k tokens, 95k free
Session Analysis
The JSONL session file (1.1MB, 263 lines) breaks down as:
| Message Type | Count | Size | % of File |
|---|---|---|---|
| progress/agent_progress | 155 | 795.6KB | 71.3% |
| user | 35 | 231.5KB | 20.7% |
| assistant | 54 | 83.2KB | 7.5% |
| Other | 18 | 5.8KB | 0.5% |
The largest individual agent_progress messages were 81KB each — containing raw file reads (entire C# source files) from subagent tool results streamed as progress updates.
What /context Reported
Messages: 44.9k tokens (22.5%)
Free space: 95k (47.7%)
Autocompact buffer: 33k tokens (16.5%)
This is clearly wrong — the 795KB of progress messages (~200k tokens) are not accounted for.
Key Difference from #23463
In #23463, the overflow comes from final agent results (task-notification messages). In this case, the overflow comes from agent_progress streaming messages — the intermediate progress updates that stream subagent activity back to the parent. These are much more numerous (155 messages vs 7 in #23463) and contain full tool result payloads (file reads, grep results).
Workaround
Manually editing the JSONL to remove agent_progress messages reduced the file from 1,117KB to 288KB, making the session resumable. Original backed up.
Suggested Fixes
- Don't include full tool result content in progress messages — progress should be a lightweight status update, not a full payload replay
- Count progress messages in context budget — if they ARE sent to the API,
/contextmust reflect them - Cap progress message size — truncate tool results in progress messages to a reasonable limit (e.g., 1KB summary)
- Auto-compact should handle progress bloat — these ephemeral messages should be first to go when context pressure rises
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗