Compaction fails on sessions with pasted screenshots (base64 images)
Resolved 💬 4 comments Opened Jan 7, 2026 by kmichels Closed Feb 22, 2026
Description
When a Claude Code session contains pasted screenshots (which are stored as base64-encoded images in the session transcript), compaction fails with "Error compacting conversation".
Steps to reproduce
- Start a Claude Code session
- Paste 2-3 screenshots during the conversation (Cmd+V with image in clipboard)
- Continue conversation until context fills up and auto-compaction triggers
- Observe "Error compacting conversation" error
Expected behavior
Compaction should handle sessions with embedded images gracefully, either by:
- Stripping images during compaction (preserving text summary)
- Handling larger message payloads without failing
- Warning user about image-heavy sessions before compaction fails
Actual behavior
Compaction fails silently. Manual /compact also fails. Session becomes unusable until user manually deletes the session file from ~/.claude/projects/.
Root cause analysis
Session files grow very large because pasted screenshots are stored as base64 in the message JSON:
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": "iVBORw0KGgo..." // ~1MB per screenshot
}
}
A session with 2-3 screenshots can easily reach 4-5MB. Compaction appears to fail when processing these large payloads.
Workaround
- Use
Read /path/to/screenshot.pnginstead of pasting (Claude Code reads image files directly) - Manually delete bloated session files from
~/.claude/projects/<project>/
Environment
- Claude Code version: 2.0.76
- macOS: Sequoia 15.x / Tahoe 26
- Images: PNG screenshots, ~1MB each base64-encoded
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗