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
Getting maxOutputTokens error when sending a message (0.2.26+) #858
After upating to 0.2.26+ getting this error when trying to send a message:
ERROR 2025-07-10T20:54:23 +0ms service=tui failed to send message: POST "http://127.0.0.1:64603/session/ses_809e2202cffe2wWGTu1lEcRRjD/message": 400 Bad Request {"name":"UnknownError","data":{"message":"AI_InvalidArgumentError: Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1"}}
Using Claude Sonnet 4 via @ai-sdk/openai-compatible proxy
Reacted by Gabriel Garrett, Jian Yu, Siddharth Suresh, steinko-motius, Dayyan Smith and Muzaffer Kadir Yılmaz
I tried the workaround but I have the following issues:
opencode.log
ERROR 2025-07-11T07:09:51 +1ms service=session session=ses_807ae54e0ffeKLY96BvnvIFKW7 error=The number of tokens to keep from the initial prompt is greater than the context length.
ERROR 2025-07-11T07:09:51 +0ms service=tui failed to send message: POST "http://127.0.0.1:56548/session/ses_807ae54e0ffeKLY96BvnvIFKW7/message": 400 Bad Request {"name":"UnknownError","data":{"message":"TypeError: J is not an Object. (evaluating '\"name\"in J')"}}
LMStudio log
The number of tokens to keep from the initial prompt is greater than the context length.. Error Data: n/a, Additional Data: n/a
I'm using LMStudio with mistralai/devstral-small-2507, tried a bunch of context/output, same error.
Any clue?
FYI opencode v0.2.21 was the last ver that worked for me
as per @bmorton last comment, unfortunately ollama isn't a solution for everyone (including myself) as it doesn't run accelerated on my system, LMS does though via vulkan.
Activity
ggaabe commentedon Jul 10, 2025
I'm getting the same trying to point it at a locally running r1 model hosted via LM Studio:
svkozak commentedon Jul 10, 2025
Workaround to restore functionality: add the params in
~/.config/opencode/config.json:In my case it was
"claude-sonnet-4": {}, I addedlimit:svkozak commentedon Jul 10, 2025
Opened this #860 to fall back to
OUTPUT_TOKEN_MAXwhen limit is undefinedskelz0r commentedon Jul 11, 2025
I tried the workaround but I have the following issues:
opencode.log
LMStudio log
I'm using LMStudio with
mistralai/devstral-small-2507, tried a bunch of context/output, same error.Any clue?
Edit: same with other local models.
bmorton commentedon Jul 11, 2025
I'm seeing the same as what @skelz0r sees. Edit: same setup -- LMStudio, devstral.
bmorton commentedon Jul 11, 2025
Actually, this fixes it with Ollama for me. LMStudio still has the same result as @skelz0r.
mchzimm commentedon Jul 11, 2025
FYI opencode v0.2.21 was the last ver that worked for me
as per @bmorton last comment, unfortunately ollama isn't a solution for everyone (including myself) as it doesn't run accelerated on my system, LMS does though via vulkan.
bazhand commentedon Jul 11, 2025
{ "$schema": "https://opencode.ai/config.json", "theme": "opencode", "model": "anthropic/claude-3.5-sonnet", "autoshare": false, "autoupdate": true, "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Ollama (local)", "options": { "baseURL": "http://localhost:11434/v1", "apiKey": "ollama" }, "models": { "llama3.2:latest": { "name": "Llama 3.2", "limit": { "context": 128000, "output": 4096 } }, "mistral:7b": { "name": "Mistral 7B", "limit": { "context": 32768, "output": 4096 } }, "deepseek-r1:8b": { "name": "DeepSeek R1 8B", "limit": { "context": 32768, "output": 4096 } } } } } }works for me using local llm with Ollama
thdxr commentedon Jul 12, 2025
fixed in 0.2.28
codeus42 commentedon Aug 20, 2025
This problem still exists with LM Studio. It needs to manually increase the context inside LM Studio
Merge pull request anomalyco#858 from sliver2er/fix/install-missing-a…