You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
core: request accumulates 52 images, exceeds provider max of 50 #47721
Upstream request fails with [invalid_request_error] request contains 52 images, exceeding the maximum of 50 allowed per request after iterating on image assets in a single session.
Active plugins: none found (no .opencode/plugin or .opencode/plugins; config has minimax provider + exa remote MCP only)
Reproduction
In one session, iteratively build HTML visuals rendered via headless Chrome.
Have the agent read PNG/GIF outputs after each iteration (hero-banner.png, anatomy-eta.png, decision-2am.png, plus GIF previews).
After ~10-15 image reads across turns, any new request fails.
Error: Error from provider (Console): Upstream request failed: [invalid_request_error] request contains 52 images, exceeding the maximum of 50 allowed per request
Expected Behavior
Old image attachments should be compacted, dropped, or blocked before hitting the provider cap — or at least warn with a way to continue text-only.
Actual Behavior
Request hard-fails at 52/50 images. Session is stuck: can't send even text-only prompts without hitting the image count.
Additional Context
Earlier in same session also saw: Unable to process image(s). Mouse mode is currently enabled, which limits image messages to one image per message.
Workflow: Substack visual iteration (1600px HTML -> Chrome screenshot -> read PNG). No manual image uploads, only agent read tool outputs.
Frequency: consistent once cap is hit; blocks the session.
Workaround tried: none yet — reporter asked agent to stop sending images. Proposed: new session / text-only mode.
We ran into this on 2.0 as well and traced the exact core mechanism on current dev:
boundImages() in packages/core/src/session/model-request.ts triggers only on bytes (>25 MiB). It enforces no count check, so 51 small screenshots (e.g. 50 KB each) still get sent and trigger provider 400 errors.
packages/ai/src/provider-error.ts doesn’t classify image-count errors as context overflow, so automatic recovery never runs.
When core does remove an image, its placeholder is a blind stub without the file path, so the model cannot re-read it.
Proposed fix:
Add an image count ceiling to boundImages().
Keep the file path in the removal placeholder so the model has actionable recall via read.
Add image-count patterns to provider-error.ts so recovery kicks in.
We have a working standalone implementation in opencode-prune-images and have this patch ready if you would like a core PR.
Activity
github-actions commentedon Sep 7, 2026
This issue might be a duplicate of existing issues. Please check:
Sugamsss commentedon Oct 14, 2026
We ran into this on 2.0 as well and traced the exact core mechanism on current
dev:boundImages()inpackages/core/src/session/model-request.tstriggers only on bytes (>25 MiB). It enforces no count check, so 51 small screenshots (e.g. 50 KB each) still get sent and trigger provider 400 errors.packages/ai/src/provider-error.tsdoesn’t classify image-count errors as context overflow, so automatic recovery never runs.Proposed fix:
boundImages().read.provider-error.tsso recovery kicks in.We have a working standalone implementation in
opencode-prune-imagesand have this patch ready if you would like a core PR.