[FEATURE] Image-aware compaction: strip/summarize images before context compression

Resolved 💬 3 comments Opened Feb 9, 2026 by jankowtf Closed Feb 12, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Screenshots and images pasted into Claude Code conversations are stored as base64 data in the context window. In visual workflows (UI development, design review, browser automation via MCP), images quickly dominate the context budget. Once compaction triggers, Claude must summarize the entire context including megabytes of base64 image data, causing extremely slow compaction (12+ minutes observed).

Real-world data from a UI development session:
| Content Type | Size | % of Context |
|---|---|---|
| Screenshots (base64) | 6,988 KB | 86.3% |
| Progress messages | 454 KB | 5.6% |
| Assistant responses | 235 KB | 2.9% |
| System reminders | 115 KB | 1.4% |
| Other | 308 KB | 3.8% |

Screenshots are ephemeral by nature. Once Claude has seen and acted on a screenshot, the base64 data serves zero purpose — only the information extracted from it matters.

Currently there is:

  • No way to remove images from conversation context
  • No hook API to modify message payloads before compaction
  • No setting to control image retention behavior
  • No mechanism to mark images as "consumed" after processing

Proposed Solution

Option A: Automatic image-to-description during compaction
During compaction, replace base64 image blocks with a text summary of what was in the image. Claude already analyzed the image during the conversation — just preserve the analysis, drop the pixels.

Option B: Image lifecycle hooks
Allow PreCompact hooks to strip/replace image data:

{
  "images": [
    { "message_index": 5, "image_index": 0, "size_bytes": 314572 }
  ]
}

Hook returns which images to strip or replace with text descriptions.

Option C: Ephemeral image flag
When images enter the conversation (paste, MCP tool result, file read), allow marking them as ephemeral:

/image-policy ephemeral  # images auto-stripped after current turn
/image-policy retain     # default behavior

Option D: Manual image removal
A /drop-images command that strips all base64 data from conversation, replacing with [Image: previously analyzed screenshot] placeholders.

Any combination of these would dramatically improve:

  • Compaction speed (12 min → <2 min for image-heavy sessions)
  • Useful session length before compaction triggers
  • Viability of visual workflows (UI dev, design review, browser automation)

Alternative Solutions

Current workarounds:

  • Manually triggering /compact early (before images accumulate)
  • Avoiding screenshots when possible (defeats the purpose)
  • Starting new sessions frequently (loses conversation context)

None are satisfactory for visual iteration workflows.

Related Issues

  • #16592 — Expose pasted image data to hooks and plugins
  • #13480 — Oversized image breaks conversation permanently
  • #16255 — Expose context usage to AI model for proactive memory management

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗