Offload session-log images to a folder on compact — fixes bloat and makes past images usable

Status Open
Maintainer reply None cached
Activity 0 comments · opened Sep 15, 2026

Session .jsonl bloat from inlined base64 images is well documented (#22365 hang/RAM, #18905 multi-GB, #79196 --resume OOM; one analysis found ~22 MB of screenshots in a 73 MB session). The obvious response is "strip the images." I'd like to suggest a framing that fixes two problems in the same move:

  1. Bloat — the logs are huge and slow (the known issue).
  2. Trapped images — every screenshot you ever pasted is base64 buried mid-line in a log. You pay disk to store images you can't open, browse, or selectively delete.

Offload, don't strip: move each image out to ~/.claude/images/ as a real file and leave a small reference in the log. Now the log is small and there's a browsable archive of your images — same disk, finally usable.

Why compact is the ideal trigger: you can't rewrite a live transcript (the prompt cache is exact-prefix, so rewriting it re-bills the whole prompt as new). But compact already discards the old prefix — so the pre-compact images are no longer part of any cached prefix, and offloading them then is free and cache-safe by construction. The event that shrinks the context is the one that should shrink the log on disk. It's ~20 lines on an event you already fire — no background service.

Working reference (an external daemon + a standalone, stdlib-only script; cache-safe, only touches closed sessions so live conversations are never disturbed): https://github.com/tibberous/offload-daemon — see demo/offload_claude_images.py. Happy to help spec the native version.

View original on GitHub ↗