anomalyco / anomalyco/opencode
[BUG] Agent accumulated 51 images via read tool, session bricked by provider 50-image count limit with no recovery
@rekram1-node is already working on this.
Since Sep 5, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Agent bricked its own session by accumulating images, user got stuck and cannot chat anymore.
Session ses_f9337a042ffebyl9CiHpjtKvlu titled Facetworks (816 messages, 3377 parts) ended in an unrecoverable loop:
Error from provider (Console Go): Upstream request failed: [invalid_request_error] request contains 51 images, exceeding the maximum of 50 allowed per request
Full error from DB:
- statusCode 400, isRetryable False
- responseBody:
{"model":"muse-spark-1.3-contributor","error":{"param":null,"type":"invalid_request_error","message":"Error from provider (Console Go): Upstream request failed: [invalid_request_error] request contains 51 images, exceeding the maximum of 50 allowed per request"}} - metadata url:
https://opencode.ai/zen/go/v1/responses - first failure 2026-09-05T13:13:44Z, then every retry fails identically including plain user messages.
What exactly happened, verified from local ~/.local/share/opencode/opencode.db:
- 51 parts with image attachments in this session
- 48x
readtool reading screenshots:/tmp/profile-readme/covers/*.png,/tmp/undertow-shot*.png,/tmp/lichen-*.png,/tmp/abyss-shot*.png,/tmp/drift-shot*.png,/tmp/facet-wide.png,/tmp/facet-mobile.png,/tmp/gummy-*.png,/tmp/jelly-thumb.jpg,/tmp/src-check.png, plusprojects/lichen/docs/screenshot.pngandprojects/drift/docs/screenshot.png - 3x
huggingface_gr1_z_image_turbo_generateoutputs withmime image/webpattachments - Agent was doing visual verification loops across undertow, lichen, abyss, drift, facetworks, gummy. User did not paste 51 images manually.
Why it is bricked:
- History already contains 51 images, so every subsequent LLM call fails before the model runs.
- User tried
okay continue now?,use less images then,can something be done?- all failed with the same 51-image error. - No way to
/compact, fork without images, prune old tool attachments, or delete messages from TUI to recover.
Expected:
- OpenCode should enforce a client-side image budget before hitting the provider (warn, stop attaching old images, downscale to text placeholder, or auto-prune oldest image attachments).
- Compaction and retry paths should strip or summarize images so a session never becomes permanently dead.
- Provide recovery: remove message, fork from message without images, or
compactthat excludes image bytes.
Related but not duplicates (all size or invalid file, not count):
- #14562 Request Entity Too Large with images blocks session, compaction also fails
- #21668 Session dead when image exceeds 5 MB limit
- #9512 Trying to read an invalid image file bricks the session
- #13865 request_too_large pixels image
Plugins
No response - stock build agent with huggingface MCP image tool available
OpenCode version
1.18.27 at session time, binary now 1.18.29
Steps to reproduce
- Start session on
opencode-go/muse-spark-1.3-contributorvariant xhigh in a repo with browser screenshot workflow - Let agent iteratively take screenshots to /tmp and
readthem for visual check (repeat 40+ times) plus a few image generations - Once attachment count in history exceeds 50, next step fails with 400 invalid_request_error
- Send any follow-up message, it fails with the same error. Session cannot continue.
Screenshot and/or share link
No share link, private code. Error text above is verbatim from session message msg_071b40311001TNVEKL93snfrs2. Can provide DB part counts on request.
Operating System
Ubuntu 24.04.4 LTS, kernel 7.0.0-30-generic
Terminal
xterm-256color via OpenCode TUI/CLI
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.