[BUG] Status line cost counter resets on context compaction — undercounts session cost
Description
The $X.XX cost displayed in the Claude Code status line resets to zero when context is compacted mid-session. After compaction, the counter only tracks cost from the new context window, silently dropping all pre-compaction spend.
Reproduction
- Start a session that generates heavy context (e.g., iterative code review with many tool calls)
- Let the session compact (hit context limits, or the conversation gets continued after running out of context)
- Observe the status line cost drops dramatically
Observed behavior
- Before compaction: Status line showed ~$5-6 (roughly correct for 77 turns up to 164k context)
- After compaction: Status line showed ~$4.97 total (approximately post-compaction cost only)
- Actual total from JSONL: $8.35 (calculated from full transcript with correct Opus 4.6 pricing)
The status line was missing ~$3.50 of pre-compaction spend.
Expected behavior
The status line cost counter should be cumulative across the entire session, including all context windows before and after compaction events.
Verification
Calculated cost from the JSONL transcript (~/.claude/projects/{path}/{session_id}.jsonl) which contains all turns including pre-compaction ones. The JSONL-derived cost accounts for all 90 turns across the compaction boundary, while the status line only reflects the 13 post-compaction turns plus subagents.
Environment
- Model: Claude Opus 4.6 (1M context)
- Session had 90 main-thread turns, 23 subagent turns
- Context compacted at turn 77 (164k → 34k tokens)
- macOS, CLI
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗