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
First of all - HUGE thumbs up for this project. I have been using it daily in long horizon tasks with success.
During my last long run (aprox 4 hours) this issue happened 3 times - (it has also happened before with all previous desktop versions)
This model's maximum context length is 139264 tokens. However, you requested 63472 output tokens and your prompt contains at least 75793 input tokens, for a total of at least 139265 tokens. Please reduce the length of the input prompt or the number of requested output tokens. (parameter=input_tokens, value=75793)
It's like it needed 1 more token that it didn't have available to use. It happens on any context value - always by +1 token more needed. Usually I retry and it recovers - (compacts and keep going) but it needs my manual intervention of course.
Plugins
I'm using superpowers
OpenCode version
Desktop 2.0.27 - but it happens since version 1 - when I started using the desktop version
Steps to reproduce
Long horizon task, on complex project, on perhaps a smaller context to increase the number of times it needs to compact - it will happen no doubt.
One note first: the "+1 token" is probably not a real off-by-one. That wording (your prompt contains at least … (parameter=input_tokens, value=…)) comes from vLLM-style backends, which report a lower bound for the prompt: the context limit minus the requested output, plus 1. That means the real prompt was probably bigger than OpenCode estimated, and the request asked for more output than was actually left in the window.
To reproduce this, could you share:
The provider and model you were using (e.g. provider/model as shown in the model picker). Is it a built-in provider or a custom OpenAI-compatible / vLLM endpoint?
Any model config that affects limits: a limit (context / output) block, maxTokens or similar options, or a selected variant, from your opencode.json. Please remove any API keys.
Which request fails: does the error show on the compaction step itself ("Session compaction failed"), or on a normal reply just before compaction? In 2.0.27 a compaction summary asks for at most 32,000 output tokens, so a request for 63,472 suggests either a normal turn or a setting or plugin (e.g. superpowers) changing the output limit.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
These issues look related. None is clearly the same problem; they're ordered from most to least likely:
On opencode.jsonc I have this related to limits:
"limit": {
"context": 131072,
"output": 65536
},
It happens always in the same moment - starts compaction - ends compaction (with the compaction text shown) and then it starts again, fails and I retry (new picture from a previous identical issue on the same long task)
Thanks for the details. I was able to reproduce this on 2.0.27, and it still happens on the latest dev (bcf23b677).
I used a mock server that behaves like vLLM: a 139,264-token limit, a tokenizer that counts dense code more heavily than OpenCode's estimate does, and vLLM's exact error text. OpenCode used your provider config (context: 131072, output: 65536). I sent one long, dense prompt in a fresh session. OpenCode asked for 38,890 output tokens on a prompt that was really about 112.5k tokens and got the same "total of at least 139265 tokens" error. The compaction that followed was rejected too. The script below sets this up end to end. The mock's tokenizer is my approximation, not Qwen's real one.
What's going on:
When OpenCode has no token count reported by the provider, it estimates the prompt size at about 4 characters per token plus a 15% margin. That's the case on the first turn of a session and on the turn right after a compaction, which matches what you see. It then asks for all the remaining room as output.
On dense code, or a tokenizer that produces more tokens than that estimate, the real prompt is bigger, so the request goes over the limit.
The "+1" comes from how vLLM reports the error: it gives the smallest prompt size that would overflow, so the total always shows as the limit plus one. The actual overflow can be much larger.
Possible workaround (I haven't checked it against your setup): a lower limit.output (e.g. 32768) leaves more headroom and should make this happen less often.
Justo to let you know that even with the last version of the Desktop App this is still happening.
I'm currently running several long horizon tasks with a Qwen 3.8 27B backend and this happens at least 5 or 6 times a day - once for each project.
max context on vllm for Qwen is 118784 and I set opencode.jsonc to:
"limit": {
"context": 118784,
"output": 59392
},
at least one time a day - even when I try chatting 'retry' several times it doesn't work. The only solution is go back to my last prompt before the failure and restart from there.
Regarding the above image - that happened just now - I tried prompting 'retry' and it worked. 'retry' prompt works around 80% of the time.
Activity
opencode-agent commentedon Oct 12, 2026
Thanks for the kind words and the clear report!
One note first: the "+1 token" is probably not a real off-by-one. That wording (
your prompt contains at least … (parameter=input_tokens, value=…)) comes from vLLM-style backends, which report a lower bound for the prompt: the context limit minus the requested output, plus 1. That means the real prompt was probably bigger than OpenCode estimated, and the request asked for more output than was actually left in the window.To reproduce this, could you share:
provider/modelas shown in the model picker). Is it a built-in provider or a custom OpenAI-compatible / vLLM endpoint?limit(context/output) block,maxTokensor similar options, or a selected variant, from youropencode.json. Please remove any API keys.You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
These issues look related. None is clearly the same problem; they're ordered from most to least likely:
ppereirasky commentedon Oct 12, 2026
Hi There,
Thanks for the fast reply.
"limit": {
"context": 131072,
"output": 65536
},
opencode-agent commentedon Oct 12, 2026
Thanks for the details. I was able to reproduce this on 2.0.27, and it still happens on the latest
dev(bcf23b677).I used a mock server that behaves like vLLM: a 139,264-token limit, a tokenizer that counts dense code more heavily than OpenCode's estimate does, and vLLM's exact error text. OpenCode used your provider config (
context: 131072,output: 65536). I sent one long, dense prompt in a fresh session. OpenCode asked for 38,890 output tokens on a prompt that was really about 112.5k tokens and got the same "total of at least 139265 tokens" error. The compaction that followed was rejected too. The script below sets this up end to end. The mock's tokenizer is my approximation, not Qwen's real one.What's going on:
Possible workaround (I haven't checked it against your setup): a lower
limit.output(e.g. 32768) leaves more headroom and should make this happen less often.Related: #38108 (same vLLM error shape), #50187, #54690.
Reproduction script (repro.sh)
Run it:
bash repro.shppereirasky commentedon Oct 12, 2026
OK - I will lower the output limit to 32768 and keep going to see how it behaves.
Thanks a lot for the help trying to debug and solve this and for the blazing fast replies. GREAT work.
👍
ppereirasky commentedon Oct 12, 2026
Just to let you know - before I changed anything this also happened (see picture)
It has never happened before - should I lower the output limit despite this error message?
I retried and it kept going:
rekram1-node commentedon Oct 15, 2026
lookin
rekram1-node commentedon Nov 3, 2026
This should be fixed after some recent durability cahnges we made in last few releases
ppereirasky commentedon Nov 4, 2026
Justo to let you know that even with the last version of the Desktop App this is still happening.
I'm currently running several long horizon tasks with a Qwen 3.8 27B backend and this happens at least 5 or 6 times a day - once for each project.
max context on vllm for Qwen is 118784 and I set opencode.jsonc to:
"limit": {
"context": 118784,
"output": 59392
},
at least one time a day - even when I try chatting 'retry' several times it doesn't work. The only solution is go back to my last prompt before the failure and restart from there.
Regarding the above image - that happened just now - I tried prompting 'retry' and it worked. 'retry' prompt works around 80% of the time.