prompt is too long unrecoverable #3171

Open
opened 2026-02-16 17:38:57 -05:00 by yindo · 27 comments
Owner

Originally created by @benceferdinandy-signifyd on GitHub (Nov 27, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Opencode with Opus 4.5 often gives me prompt is too long: 209549 tokens > 200000 maximum. This is completely unrecoverable, short of rolling back the session or forking and you then need to compact or something.

Note I'm only at: 121,480 61% ($5.62)

OpenCode version

1.0.119

Steps to reproduce

Use Antropic api key with Opus 4.5, trigger a huge search for example in the primary agent.

Screenshot and/or share link

No response

Operating System

macos

Terminal

ghostty

Originally created by @benceferdinandy-signifyd on GitHub (Nov 27, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Opencode with Opus 4.5 often gives me ` prompt is too long: 209549 tokens > 200000 maximum`. This is completely unrecoverable, short of rolling back the session or forking and you then need to compact or something. Note I'm only at: 121,480 61% ($5.62) ### OpenCode version 1.0.119 ### Steps to reproduce Use Antropic api key with Opus 4.5, trigger a huge search for example in the primary agent. ### Screenshot and/or share link _No response_ ### Operating System macos ### Terminal ghostty
yindo added the bug label 2026-02-16 17:38:57 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 27, 2025):

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

  • #1092: AI_APICallError: prompt is too long - Nearly identical error with Opus model causing unrecoverable session state
  • #164: AI_APICallError: prompt is too long & OAuth error - Exact same token overflow error (201082 > 200000) with Anthropic Opus
  • #491: input length and 'max_tokens' exceed context limit - Same context window calculation issue with Anthropic models
  • #2464: AT_APICallError: prompt token count exceeds limit - Similar token overflow blocking work (130389 > 128000)
  • #3409: Opencode stuck after token too long - Token overflow causing stuck/unrecoverable state
  • #1212: Fetched documentation exceeds context window limit - Context window overflow from tool outputs
  • #4826: Is automatic tool calling output truncation supported? - Root cause discussion about tools generating huge outputs

All these issues share the same core problem: context window overflow leading to unrecoverable sessions. Feel free to ignore if your case has specific differences!

@github-actions[bot] commented on GitHub (Nov 27, 2025): This issue might be a duplicate of existing issues. Please check: - #1092: AI_APICallError: prompt is too long - Nearly identical error with Opus model causing unrecoverable session state - #164: AI_APICallError: prompt is too long & OAuth error - Exact same token overflow error (201082 > 200000) with Anthropic Opus - #491: input length and 'max_tokens' exceed context limit - Same context window calculation issue with Anthropic models - #2464: AT_APICallError: prompt token count exceeds limit - Similar token overflow blocking work (130389 > 128000) - #3409: Opencode stuck after token too long - Token overflow causing stuck/unrecoverable state - #1212: Fetched documentation exceeds context window limit - Context window overflow from tool outputs - #4826: Is automatic tool calling output truncation supported? - Root cause discussion about tools generating huge outputs All these issues share the same core problem: **context window overflow leading to unrecoverable sessions**. Feel free to ignore if your case has specific differences!
Author
Owner

@menoatree commented on GitHub (Dec 12, 2025):

I had this happen today aswell when the main agent tried to webfetch the openrouter model list

% WebFetch https://openrouter.ai/api/v1/models
prompt is too long: 206917 tokens > 200000 maximum
@menoatree commented on GitHub (Dec 12, 2025): I had this happen today aswell when the main agent tried to webfetch the openrouter model list ``` % WebFetch https://openrouter.ai/api/v1/models prompt is too long: 206917 tokens > 200000 maximum ```
Author
Owner

@Nindaleth commented on GitHub (Dec 18, 2025):

@menoatree That URL returns over 450 kB of data for me, that must be around 100,000 tokens of context.

@Nindaleth commented on GitHub (Dec 18, 2025): @menoatree That URL returns over 450 kB of data for me, that must be around 100,000 tokens of context.
Author
Owner

@ben-vargas commented on GitHub (Dec 19, 2025):

Yeah, see that #5360 issue where i added comments, there are tool calls like webfetch and mcp tools that are not truncated and if the source being webfetched or mcp tool scraped with something like firecrawl, it can easily cause the context window to be exceeded which results in this error with opus 4.5.

@ben-vargas commented on GitHub (Dec 19, 2025): Yeah, see that #5360 issue where i added comments, there are tool calls like webfetch and mcp tools that are not truncated and if the source being webfetched or mcp tool scraped with something like firecrawl, it can easily cause the context window to be exceeded which results in this error with opus 4.5.
Author
Owner

@thdxr commented on GitHub (Dec 30, 2025):

will be fixing this next week

@thdxr commented on GitHub (Dec 30, 2025): will be fixing this next week
Author
Owner

@PeterHa-UoH commented on GitHub (Jan 6, 2026):

will be fixing this next week

has it been fixed yet/

@PeterHa-UoH commented on GitHub (Jan 6, 2026): > will be fixing this next week has it been fixed yet/
Author
Owner

@Nindaleth commented on GitHub (Jan 6, 2026):

@PeterHa-UoH

rekram1-node closed this as completed in #6480 5 days ago

I would say yes, but feel free to try it on your own

@Nindaleth commented on GitHub (Jan 6, 2026): @PeterHa-UoH > rekram1-node closed this as completed in #6480 5 days ago I would say yes, but feel free to try it on your own
Author
Owner

@arshbot commented on GitHub (Jan 7, 2026):

Can confirm it's been fixed! Was on 1.0x, updated to 1.1.6 in order to solve, and presto! My session was recovered. Great fix @aryasaatvik

@arshbot commented on GitHub (Jan 7, 2026): Can confirm it's been fixed! Was on 1.0x, updated to 1.1.6 in order to solve, and presto! My session was recovered. Great fix @aryasaatvik
Author
Owner

@filipemendespi commented on GitHub (Jan 11, 2026):

I'm constantly getting this error.
I'm testing OpenCode with the new OpenAI integration for the Plus plan.

Image
@filipemendespi commented on GitHub (Jan 11, 2026): I'm constantly getting this error. I'm testing OpenCode with the new OpenAI integration for the Plus plan. <img width="3710" height="221" alt="Image" src="https://github.com/user-attachments/assets/95b1f658-f418-43a7-911d-eb0984c16c97" />
Author
Owner

@dedene commented on GitHub (Jan 11, 2026):

@rekram1-node I am also seeing this with the new OpenAI integration:

Image

As you can see from the screenshot, the context window was far from full

Context
52,123 tokens
13% used
@dedene commented on GitHub (Jan 11, 2026): @rekram1-node I am also seeing this with the new OpenAI integration: <img width="3680" height="2392" alt="Image" src="https://github.com/user-attachments/assets/cc70fd2e-f6cd-4ee1-a801-790dcf2eaa28" /> As you can see from the screenshot, the context window was far from full ``` Context 52,123 tokens 13% used ```
Author
Owner

@cjgratacos commented on GitHub (Jan 14, 2026):

I am running into the same error as well. Manual compaction clears it only until it shows up again. This looks like auto-compaction is not being triggered maybe?

@cjgratacos commented on GitHub (Jan 14, 2026): I am running into the same error as well. Manual compaction clears it only until it shows up again. This looks like auto-compaction is not being triggered maybe?
Author
Owner

@metersk commented on GitHub (Jan 15, 2026):

also encountering this on gpt 5.2 xhigh quite frequently

@metersk commented on GitHub (Jan 15, 2026): also encountering this on gpt 5.2 xhigh quite frequently
Author
Owner

@rekram1-node commented on GitHub (Jan 15, 2026):

Yeah noticed a bug w/ openai gpt-5 class models. Will fix issue sorry guys

@rekram1-node commented on GitHub (Jan 15, 2026): Yeah noticed a bug w/ openai gpt-5 class models. Will fix issue sorry guys
Author
Owner

@aviramkofman commented on GitHub (Jan 22, 2026):

@rekram1-node Just had it happen on the Desktop app v1.1.31 with gpt-5.2-codex with xhigh

@aviramkofman commented on GitHub (Jan 22, 2026): @rekram1-node Just had it happen on the Desktop app v1.1.31 with `gpt-5.2-codex` with `xhigh`
Author
Owner

@Suoliy commented on GitHub (Jan 22, 2026):

@rekram1-node but I use Claude Opus 4.5 with Copilot and I have this problem

Image
@Suoliy commented on GitHub (Jan 22, 2026): @rekram1-node but I use Claude Opus 4.5 with Copilot and I have this problem <img width="871" height="258" alt="Image" src="https://github.com/user-attachments/assets/d9823b2e-1c1e-443c-9253-c5b2bddb7524" />
Author
Owner

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

Gotta do something with image reading - it runs out of context

@laruss commented on GitHub (Feb 1, 2026): Gotta do something with image reading - it runs out of context
Author
Owner

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

Image also happening for me with opus 4.5
@robinr2 commented on GitHub (Feb 2, 2026): <img width="802" height="606" alt="Image" src="https://github.com/user-attachments/assets/c461341f-e923-49a9-a1d2-b1ea634e38eb" /> also happening for me with opus 4.5
Author
Owner

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

Image

antigravity opus4.5 can trigger similar content but in form of error.

@iamabigartist commented on GitHub (Feb 5, 2026): <img width="2215" height="421" alt="Image" src="https://github.com/user-attachments/assets/4c132e2e-c292-40e1-9f04-bde32ba627c9" /> antigravity opus4.5 can trigger similar content but in form of error.
Author
Owner

@ixoo commented on GitHub (Feb 8, 2026):

Getting this error with GitHub CoPilot on Opus 3.6 (128k token limit). Successive tool calls fill the context without triggering a compaction.

@ixoo commented on GitHub (Feb 8, 2026): Getting this error with GitHub CoPilot on Opus 3.6 (128k token limit). Successive tool calls fill the context without triggering a compaction.
Author
Owner

@miguelangelmorenochacon commented on GitHub (Feb 10, 2026):

Happening with Opus 4.6

@miguelangelmorenochacon commented on GitHub (Feb 10, 2026): Happening with Opus 4.6
Author
Owner

@ashaychangwani commented on GitHub (Feb 10, 2026):

Can we please reopen this issue? A lot of people are reporting the same in #5360

@ashaychangwani commented on GitHub (Feb 10, 2026): Can we please reopen this issue? A lot of people are reporting the same in #5360
Author
Owner

@rekram1-node commented on GitHub (Feb 10, 2026):

I found some places we had issues, fixing

@rekram1-node commented on GitHub (Feb 10, 2026): I found some places we had issues, fixing
Author
Owner

@daheli commented on GitHub (Feb 13, 2026):

Same issue
https://github.com/code-yeongyu/oh-my-opencode/issues/1815

Image
@daheli commented on GitHub (Feb 13, 2026): Same issue https://github.com/code-yeongyu/oh-my-opencode/issues/1815 <img width="2626" height="1980" alt="Image" src="https://github.com/user-attachments/assets/5170f781-4b95-4fcb-b491-d7fc5a0aadb9" />
Author
Owner

@smashah commented on GitHub (Feb 14, 2026):

The whole payload seems to be filled with tool definitions

@smashah commented on GitHub (Feb 14, 2026): The whole payload seems to be filled with tool definitions
Author
Owner

@ogyr commented on GitHub (Feb 14, 2026):

Same problem here with opus 4.6
/compact fails as well. I could live with a simple "How much of the oldest content do you want to trim? In k tokens"

@ogyr commented on GitHub (Feb 14, 2026): Same problem here with opus 4.6 /compact fails as well. I could live with a simple "How much of the oldest content do you want to trim? In k tokens"
Author
Owner

@iamtekeste commented on GitHub (Feb 14, 2026):

Is there a workaround in the meantime?

@iamtekeste commented on GitHub (Feb 14, 2026): Is there a workaround in the meantime?
Author
Owner

@ogyr commented on GitHub (Feb 15, 2026):

I created https://github.com/ogyr/opencode-cullto today as a workaround. It lets you cull your current session (or select one) to a specified token limit. Works from within opencode when the session is still responsive, or as a standalone CLI that lists all sessions to choose from, then reopens opencode with the culled session. Works well enough for my use case.

@ogyr commented on GitHub (Feb 15, 2026): I created https://github.com/ogyr/opencode-cullto today as a workaround. It lets you cull your current session (or select one) to a specified token limit. Works from within opencode when the session is still responsive, or as a standalone CLI that lists all sessions to choose from, then reopens opencode with the culled session. Works well enough for my use case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3171