Prompt token count of exceeds the limit of 128000 #8229

Closed
opened 2026-02-16 18:09:28 -05:00 by yindo · 8 comments
Owner

Originally created by @DanielProkhorov17 on GitHub (Feb 1, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I get this error when a model like claude is trying to read file attachments that are images (.png, jpeg), thus crashing with token count limit.

I'd be great to perform token count before the request is getting sent to the model. In case, it exceeds the images shall be compressed to a reasonable size.

Plugins

No response

OpenCode version

1.1.48

Steps to reproduce

  1. Let the model download an image (for e.g. via MPC), or python script ivocation, or curl
  2. The AI model tries to read downloaded image(s)

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @DanielProkhorov17 on GitHub (Feb 1, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I get this error when a model like claude is trying to read file attachments that are images (.png, jpeg), thus crashing with token count limit. I'd be great to perform token count before the request is getting sent to the model. In case, it exceeds the images shall be compressed to a reasonable size. ### Plugins _No response_ ### OpenCode version 1.1.48 ### Steps to reproduce 1. Let the model download an image (for e.g. via MPC), or python script ivocation, or curl 2. The AI model tries to read downloaded image(s) ### Screenshot and/or share link _No response_ ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the windowsbugperf labels 2026-02-16 18:09:28 -05:00
yindo closed this issue 2026-02-16 18:09:28 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 1, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #11450: ContextWindowExceededError during compaction (litellm & claude-opus-4.5) - Similar context/token limit issues
  • #11306: Read tool fails to read image files even with vision-capable models - Related to image file handling causing context issues
  • #11437: Read tool accesses JPEG file but vision model hallucinates incorrect description - Related to image processing and model context limits
  • #11304: Images returned from Read tool don't work with OpenAI-compatible providers - Related to image handling in Read tool
  • #11550: Read tool for kimi k2.5 on zen does not work on images - Similar image handling issue
  • #11286: Model context limits not respected - Related to context window limit management

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 1, 2026): This issue might be a duplicate of existing issues. Please check: - #11450: ContextWindowExceededError during compaction (litellm & claude-opus-4.5) - Similar context/token limit issues - #11306: Read tool fails to read image files even with vision-capable models - Related to image file handling causing context issues - #11437: Read tool accesses JPEG file but vision model hallucinates incorrect description - Related to image processing and model context limits - #11304: Images returned from Read tool don't work with OpenAI-compatible providers - Related to image handling in Read tool - #11550: Read tool for kimi k2.5 on zen does not work on images - Similar image handling issue - #11286: Model context limits not respected - Related to context window limit management Feel free to ignore if none of these address your specific case.
Author
Owner

@DanielProkhorov17 commented on GitHub (Feb 1, 2026):

#11450 This issue is reported during compaction. The usecase I'm describing is specifically related to image attachments.

@DanielProkhorov17 commented on GitHub (Feb 1, 2026): #11450 This issue is reported during compaction. The usecase I'm describing is specifically related to image attachments.
Author
Owner

@bankjaneo commented on GitHub (Feb 1, 2026):

The last good version that can read image is 1.1.31

You might want to pin to that version until this bug is fixed.

@bankjaneo commented on GitHub (Feb 1, 2026): The last good version that can read image is 1.1.31 You might want to pin to that version until this bug is fixed.
Author
Owner

@tlaukkanen commented on GitHub (Feb 2, 2026):

Thanks for the tip. 1.1.31 works with images. Especially handy when agent uses MCP like playwright to troubleshoot some bug and tries to take a screenshot.

@tlaukkanen commented on GitHub (Feb 2, 2026): Thanks for the tip. 1.1.31 works with images. Especially handy when agent uses MCP like playwright to troubleshoot some bug and tries to take a screenshot.
Author
Owner

@thomashfr commented on GitHub (Feb 2, 2026):

I'm getting the same error when using the Figma prototype, or any more detailed prompt in plan mode. Version 1.1.48

@thomashfr commented on GitHub (Feb 2, 2026): I'm getting the same error when using the Figma prototype, or any more detailed prompt in plan mode. Version 1.1.48
Author
Owner

@paq85 commented on GitHub (Feb 3, 2026):

Happens also with local model, when it tries to analyse image

Image
@paq85 commented on GitHub (Feb 3, 2026): Happens also with local model, when it tries to analyse image <img width="1132" height="312" alt="Image" src="https://github.com/user-attachments/assets/303e22c0-5f0e-428e-af7f-43c4ced1727a" />
Author
Owner

@aeciolevy commented on GitHub (Feb 5, 2026):

1.1.31

Lifesaver.

I could not do anything with images anymore.

@aeciolevy commented on GitHub (Feb 5, 2026): > 1.1.31 Lifesaver. I could not do anything with images anymore.
Author
Owner

@bankjaneo commented on GitHub (Feb 5, 2026):

This bug has been fixed in 1.1.52 🎉

@bankjaneo commented on GitHub (Feb 5, 2026): This bug has been fixed in 1.1.52 🎉
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8229