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
AI_APICallError with Qwen 3 Coder 480b: Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536 #1551
It goes through a number of tool calls like fetch, and glob, and task and then errors out with that message. Here's the prompt I'm using for reference if it helps recreate the issue:
Can you read through all the docs. I want to learn how to setup MCP servers for me in open code using the opencode.json file. Is there a way to also leverage my existing @CLAUDE.md files in my repo subfolder to help setup opencode?
Before you do anything can you provide me with an over view of what I can do to set things up?_
changed the title [-]AI_APICallError with Qwen 3 Code 480b: Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536[/-][+]AI_APICallError with Qwen 3 Coder 480b: Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536[/+]on Aug 3, 2025
I got this error just now but what's concerning is the output after was someone's request about django and cloudflare which was totally unrelated to my context and query.
@jflaflamme thats very strange… just for clarity it is literally impossible for “someone elses request” to be sent instead of yours (on our end) because the opencode instance is only running on your machine, I guess technically anthropic could have served you the wrong response somehow but I feel like this is the llm confusing itself based on context and other things most likely
@jflaflamme thats very strange… just for clarity it is literally impossible for “someone elses request” to be sent instead of yours (on our end) because the opencode instance is only running on your machine, I guess technically anthropic could have served you the wrong response somehow but I feel like this is the llm confusing itself based on context and other things most likely
I appreciate the prompt response and I didn't mean to hijack the topic, just the the AI_APICallError about the length of the message error was the same even with Anthropic models selected, perhaps because of the context? Weird too.
Same goes for the possible confusing context, which I never had issues with before with Claude code (or opencode).
Could it be because I switched the model used for the agent within the session?
Thanks all for your comments. Just tried Qwen on Cerebras again today to see if I can get it working, but I still keep running into this same issue. I don't get this issue with the anthropic or open AI models. Qwen unfortunately for me is un-useable atm. Let me know if there's other ways I can get more info to help debug this one and I'll see if I can get everyone some more detail. Thanks!
Activity
[-]AI_APICallError with Qwen 3 Code 480b: Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536[/-][+]AI_APICallError with Qwen 3 Coder 480b: Please reduce the length of the messages or completion. Current length is 69553 while limit is 65536[/+]adeperio commentedon Aug 3, 2025
It looks like it's hitting max content length for the model and not compacting down the chat history when it reaches the limit.
adeperio commentedon Aug 3, 2025
Interestingly I also get this error when trying to find the bug in the opencode repo, with opencode. Probably another github issue though :)
Debugging with claude code the error: "AI_APICallError: Please reduce the length of the messages or completion" I get the following:
Summary
The issue is in /packages/opencode/src/session/index.ts around
lines 612-624. The context length check before summarization is
insufficient because:
the model, including:
- System prompts
- All conversation messages
- The new user message
When the total exceeds 65536 tokens (Cerebras' limit), the API
throws the error before summarization can help.
Fix
The context check needs to estimate the total tokens that will
be sent. Here's what needs to be changed:
messages
strategy for models with smaller context windows
The check should happen before line 822 where streamText is
called, and should account for all the messages that will be
sent in the messages array.
thdxr commentedon Aug 3, 2025
what provider are you using where the limit is this low?
adeperio commentedon Aug 4, 2025
Hi @thdxr it's with Cerebras.
polo871209 commentedon Aug 8, 2025
I am facing the similiar issue using copilot/gpt-5 now 🙏
AI_APICallError: prompt token count of 128783 exceeds the limit of 128000torbjornvatn commentedon Aug 13, 2025
Same here. Is this a limit set by copilot somehow?
jflaflamme commentedon Aug 24, 2025
I got this error just now but what's concerning is the output after was someone's request about django and cloudflare which was totally unrelated to my context and query.
rekram1-node commentedon Aug 24, 2025
@jflaflamme thats very strange… just for clarity it is literally impossible for “someone elses request” to be sent instead of yours (on our end) because the opencode instance is only running on your machine, I guess technically anthropic could have served you the wrong response somehow but I feel like this is the llm confusing itself based on context and other things most likely
jflaflamme commentedon Aug 25, 2025
I appreciate the prompt response and I didn't mean to hijack the topic, just the the AI_APICallError about the length of the message error was the same even with Anthropic models selected, perhaps because of the context? Weird too.
Same goes for the possible confusing context, which I never had issues with before with Claude code (or opencode).
Could it be because I switched the model used for the agent within the session?
rekram1-node commentedon Aug 25, 2025
tbh I am not really sure without seeing your session, as for the error we need to do more context optimizations like:
adeperio commentedon Aug 25, 2025
Thanks all for your comments. Just tried Qwen on Cerebras again today to see if I can get it working, but I still keep running into this same issue. I don't get this issue with the anthropic or open AI models. Qwen unfortunately for me is un-useable atm. Let me know if there's other ways I can get more info to help debug this one and I'll see if I can get everyone some more detail. Thanks!
rekram1-node commentedon Dec 28, 2025
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!