Assistant text preceding a tool call is dropped from the transcript after auto-compaction
Preflight Checklist
- Searched existing issues for this behavior; none found (see duplicate search notes below).
- This is a single bug report.
- Observed on Claude Code 2.1.280.
What's Wrong?
After an automatic context-compaction boundary (a transcript record with "subtype":"compact_boundary"), the session transcript .jsonl under ~/.claude/projects stops recording most assistant text that precedes a tool call in the same response. In one session, only tool_use/thinking blocks and each turn's final text-only reply were written after the boundary; in other sessions the share of such text fell sharply (numbers below). Before the boundary, the same kind of text is written normally.
What Should Happen?
All assistant text blocks should be persisted to the transcript in emission order, whether or not they precede a tool call, and whether the turn occurs before or after a compaction boundary.
Steps to Reproduce
- Run a long session in the Claude desktop app's Code tab until it auto-compacts (a
compact_boundaryrecord appears). - After compaction, prompt Claude so a reply mixes narration text then a tool call.
- Grep the transcript
.jsonlfor that narration: absent, even after the turn completes (the final text-only reply is present). - Compare to a mixed text+tool_use turn from before the boundary, where narration is present.
Additional Information
Grouping assistant records by message.id, the share of tool-call responses that also contain text: three compacted 2.1.280 sessions show 34-42% before the boundary vs 6-8% after; one uncompacted 2.1.280 session shows 24%; one July 2.1.202 session shows 61% after its compaction. In the sessions checked, records after the boundary carry the same version string as before it, so this is not a mid-session upgrade. The July result suggests a regression, though it is not a controlled comparison. 2.1.280 is the version bundled with the desktop app; the latest published CLI, 2.1.282, is untested. Only auto-compaction was observed; manual /compact is untested; a headless claude -p repro wasn't possible. Impact: PreCompact/Stop hooks and tools reading transcript_path miss mid-turn assistant text after compaction.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know (see version-rate comparison above)
Claude Code Version
2.1.280
Platform
Anthropic API (Claude Max subscription, through the Claude desktop app's Code tab)
Operating System
Windows
Terminal/Shell
Other — Claude desktop app's Code tab (not a terminal)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗