← Open Source

Keep long, image-heavy AI agent chats fast (Codex, Claude Code, WorkBuddy, Gemini CLI, DeepSeek Harness, Hermes Agent & more): earlier images become ID placeholders the model fetches back on demand, even after compaction. Local, cache-friendly, MIT.

AI EngineeringGive agent toolsBuild agent UITypeScript
Momentum
+0stars in 24 hours0.0%
842
Stars
86
Forks
+6
This week
7
Contributors
Created 2026-09-24 · Updated 2026-12-04 · #16776 today
Top developers
chipfighterlin-cocoTeapoyY
README

Context Attachment Manager

Keep long, image-heavy chats in AI agents fast.
Works with Codex, Claude Code, WorkBuddy, Gemini CLI, DeepSeek Harness, Hermes Agent, and more. Earlier images become one-line placeholders with an ID; when the model needs one again, it fetches the original by its ID, also after the chat is compacted.

English · 简体中文 · 繁體中文 · 日本語 · 한국어 · Tiếng Việt
Español · Português (Brasil) · Français · Deutsch · Italiano · Polski
Русский · Türkçe · العربية · हिन्दी · Bahasa Indonesia · ไทย

42.4 MB → 0.12 MB

One request in a Codex chat
with nine keyframes

20/20 vs 8/20

Questions about the images
after compaction (Sonnet 5.5)

About the same cost

Largest request: 41,859
vs 110,671 tokens

Get started in three steps

1. Install. Send this to your agent. It identifies its platform and installs the right setup:

Install Context Attachment Manager for me, following https://github.com/chipfighter/context-attachment-manager/blob/main/INSTALL.md

Then restart the agent (in Claude Desktop, start a new Code session). To do it by hand, see installation, updates and uninstall. In Codex and Claude Code it then keeps itself up to date: new versions install in the background and take effect the next time the agent starts.

2. Work as usual. The plugin is on by default. Images from earlier turns go out as one-line placeholders; new images and the references you pin go out as they are. A placeholder looks like this:

[Image IMG-004 omitted | shot-1.png | generated image | turn 2 | 505×505]
Features: place: Street | Qinghe | medium shot, umbrella, lanterns
For the original, call cam_view_image with "IMG-004".

3. The model fetches by ID. When it needs to look at an earlier image again, it fetches the original by its ID, also after compaction. Nothing is deleted, and your images and chat history stay on your computer.

The panel: browse by character and place

The plugin works without the panel; open it when you want control:

  • Browse by character and place: images are sorted into characters, places, screens and documents, with one card per name. Open a character to see their design images first, then the shots they appear in, place by place.
  • Find an image by a detail or a comment you remember, like "rainy night" or "best face".
  • Keep a reference in view: open an image and check Send every turn.
  • Choose images yourself: turn off Auto-select and pick what goes with your next message.

In Codex, open Context Assets in the task's side panel. In Claude Desktop's Code tab, the panel opens automatically when there are images; type /cam to bring it back.

Results

  • Codex: a chat with nine keyframes grew to 42.4 MB and could not be sent after a restart or a compaction; with the plugin the same requests were 0.12 MB.
  • Claude Code (Sonnet 5.5): in a 16-turn short-film task whose images exist only in the conversation, we compacted the chat and then asked about the images. With the plugin it answered 20 of 20 questions correctly; without it, 8 of 20. Its largest request was 41,859 tokens instead of 110,671, at about the same cost.

See the Codex comparison, the Claude Code compaction comparison and the Claude Code long-task comparison for the results and reproduction steps.

How it works: keep the cache working

Model services cache the start of a chat. When a request begins exactly like the one before, that part is read from the cache, which is faster and much cheaper. When something early in the chat changes, everything after the change is processed again. The plugin makes its change as late in the chat as it can:

  • A placeholder is written once: an image becomes a placeholder in the turn after it appeared, and stays the same from request to request.
  • Fetching changes nothing earlier: the original is added at the end of the current turn and its placeholder stays where it is, so earlier turns are still read from the cache.
  • The model gets the original back: not a smaller copy, and not a summary of it.
How fetching works, and what it costs

This is not free. After a turn with images, the rest of that turn is processed again once, and the model writes a short line for each new image. Changing an old image in the panel (unchecking it, checking it again, Send every turn) changes the chat at that image, so what follows it is processed again once. In our long-task comparison in Claude Code, 87% of the input was read from the cache with the plugin and 91% without it.

An agent's own compaction, and clearing old tool results on the API side (Anthropic's context editing, for example), remove early content so that what follows is processed again: the third row of the first figure.

Works with

Codex and Claude Code are tested and also have the panel (desktop). WorkBuddy, Gemini CLI, DeepSeek Harness and Hermes Agent are tested live with auto-select. The remaining agents below are supported through adapters written from their code and docs, and have not been tested live yet. If you use one of them, please tell us how it went, whether it worked or not.

Agent What it is Support
Codex OpenAI's coding agent, desktop and CLI Auto-select + panel, tested
Claude Code Anthropic's coding agent, desktop and CLI Auto-select + panel (desktop), tested
WorkBuddy Tencent's desktop AI work assistant, with CodeBuddy inside Auto-select, tested
Gemini CLI Google's open-source terminal agent Auto-select, tested
DeepSeek Harness DeepSeek's agent harness where everything is a plugin Auto-select (dsh plugin), tested
Hermes Agent Nous Research's open-source agent for terminal, desktop and gateways Auto-select (Hermes plugin), tested
OpenCode Open-source terminal coding agent for any model provider Auto-select, not tested yet
pi Minimal, extensible terminal coding agent Auto-select (pi extension), not tested yet
Qwen Code Qwen's open-source terminal agent Auto-select, not tested yet
Cline Open-source coding agent for VS Code, JetBrains and the terminal Auto-select, not tested yet
Kilo Code Open-source coding agent for VS Code, JetBrains and the terminal Auto-select, not tested yet
goose Open-source agent for desktop and terminal, extended with MCP Auto-select, not tested yet
Cherry Studio Open-source desktop chat client for many models Auto-select, not tested yet

Setup for these agents: INSTALL.md. To connect another agent, see ADAPTERS.md.

FAQ

Why do AI agents get slow or fail with "request too large" (413) in chats with many images?

Agents resend every earlier image with each new message, so requests grow quickly, token costs pile up, and long chats can hit request-size limits (such as 413 Payload Too Large) or stop going through. In Codex, a chat with nine keyframes grew to 42.4 MB and could not be sent after a restart or a compaction; with Context Attachment Manager the same requests were 0.12 MB.

How do I remove old images from context without breaking the prompt cache?

Context Attachment Manager replaces each image from earlier turns with a fixed one-line ID placeholder once, and never changes that placeholder afterward. When the model fetches an original back with cam_view_image, it is added at the end of the current turn, so earlier turns are still read from the prompt cache. After a turn with images, only the rest of that turn is processed again once. In our long-task comparison in Claude Code, 87% of the input was read from the cache with the plugin versus 91% without it.

How is it different from compaction, dropping history, or resizing images?

Compaction and dropping early history remove the early part of the chat, and resizing or compressing images changes it. Either way nearly the whole conversation misses the prompt cache and is processed again, leaving the model with only a summary or a lower-resolution copy. With Context Attachment Manager, earlier turns stay cached, only the rest of the previous turn is processed again, and the model fetches the full-resolution original back by its ID.

Does the model still know the earlier images after compaction?

Yes. Every image has an ID such as IMG-001, and the model notes one line on each: its category, a name, and the characters in it. These stay in the placeholders after compaction, and the model fetches the original by its ID when it needs to look again.

Does it handle the many screenshots from computer use and browser use?

Yes. When computer-use or browser-use tools return dozens of screenshots in one turn, older ones become placeholders in batches while the newest few stay in full, preventing rapid context and token bloat. The model can note a run of similar screenshots in one line and fetch any exact screenshot back by its ID.

Does it reduce PDF token usage and handle large PDFs?

In Claude Code, yes. Normally, every PDF Claude Code reads is sent again in full with every following message, which quickly drives up token usage. With Auto-select on, a PDF from an earlier turn goes out as a short placeholder with an ID such as PDF-001, and the model fetches only the specific pages it needs by ID and page number. Text PDFs and scans both work. Codex never sends PDF files themselves; pages turned into images there are managed like any other image.

Are my images deleted, or sent anywhere else?

No. The plugin runs on your computer. Your original images and chat history stay as they are, and requests go to the service your agent already uses. Apart from those requests, it asks GitHub about once a day whether there is a new version; that request carries nothing about you, and you can turn automatic updates off in the panel.

Which AI agents does it work with, and does one shared proxy serve multiple sessions?

Codex, Claude Code, WorkBuddy, Gemini CLI, DeepSeek Harness and Hermes Agent are tested live (OpenCode, pi, Qwen Code, Cline, Kilo Code, goose and Cherry Studio also have adapters that we have not tested live yet). Proxy-based agents share one local engine and MCP server (cam_view_image) across concurrent sessions with session-bound image IDs so sessions never mix up images; DeepSeek Harness and Hermes Agent run as native in-process plugins. It is free and open source under the MIT license.

How do I install it? Do I need a terminal?

No. Send your agent the one sentence in Get started above: it identifies its platform and runs the setup itself, and you only restart the agent afterwards (in Claude Desktop, start a new Code session). In Codex you can also install it from the Plugins page with a few clicks. If you prefer to do it by hand, it takes one command in Codex and two claude commands in Claude Desktop; see INSTALL.md.

Changelog · Contributing · MIT License

Nearby in the ranking
Similar items

AI Rank for iPhone

Follow AI model rankings

Download on the App Store