AI Agent Hub
Back to plugins
🤖

dsh-image-guard

Model Inference Updated 2026.09.14

Run the following command in DeepSeek Harness:

dsh plugin install mafeis/dsh-image-guard

Paste the following prompt into your AI chat to install this plugin:

Install in DeepSeek Harness by running dsh plugin install mafeis/dsh-image-guard, full source at https://github.com/mafeis/dsh-image-guard .

About this plugin

DeepSeek Harness measures its image budget in bytes or pixels, but the upstream still enforces a hard cap on how many images a single prompt may carry. A long conversation piles up a dozen or more screenshots, compaction just re-sends the same history, and a 400 error reading "At most N image(s)" keeps coming back. dsh-image-guard was built for exactly this gap: right before the request leaves the process, it trims the oldest images down to a configurable "keep latest N" window, replacing the rest with a recoverable marker that carries the filename, path, or a content fingerprint so the model or agent can fetch the image again on demand instead of losing it silently.

Trimming is only half the story. The other half is learning the limit and degrading gracefully. The first request still hits the 400, but the plugin parses N out of the error text, immediately retries with N−1 images, and remembers that number for every subsequent request in the same process—no second tuition. Each trimmed image saves roughly 930 visual tokens on average, so a fourteen-to-seven trim shaves off around 6.5 k tokens per round, and the settings page shows a live cumulative savings counter if you like to keep score.

The plugin mutates only a structuredClone of the outgoing body, never the conversation history, so prefix caching stays intact and turning it off restores the original behaviour instantly. It also pins itself to the very top of the globalThis.fetch chain; a 200 ms watchdog and chain probes reclaim the spot if a proxy plugin or any other wrapper tries to jump ahead. Built for DSH developers whose multi-image sessions keep hitting the per-prompt image cap, and for agent users who feed in screenshots and want to save tokens without throwing away earlier context.

Use Cases

  • Multi-image chats repeatedly hit the per-prompt image cap with a 400
  • Want to save visual tokens without losing early screenshot context
  • Agent sessions accumulate screenshots until compaction stops helping

Best For

  • Developers running multi-image DeepSeek chats in DSH
  • Power users feeding screenshots into autonomous agents
  • Ops engineers tracking visual token spend and cache hit rates