Description
I was working on a project using DeepSeek V4 Flash Free. OpenCode reports 130,554 tokens and 65% used at the top right. However, I got this message:
Type validation failed: Value: {"error_type":"validation_error","error_message":"{\"error\":{\"message\":\"This model's maximum context length is 163840 tokens. However, you requested 32000 output tokens and your prompt contains at least 131841 input tokens, for a total of at least 163841 tokens. Please reduce the length of the input prompt or the number of requested output tokens. (parameter=input_tokens, value=131841)\",\"type\":\"BadRequestError\",\"param\":\"input_tokens\",\"code\":400}}"}.
Error message: [
{
"code": "invalid_union",
"errors": [
[
{
"expected": "array",
"code": "invalid_type",
"path": [
"choices"
],
"message": "Invalid input: expected array, received undefined"
}
],
[
{
"expected": "object",
"code": "invalid_type",
"path": [
"error"
],
"message": "Invalid input: expected object, received undefined"
}
]
],
"path": [],
"message": "Invalid input"
}
]
This seems strange, as I've previously had threads with this model that exceeded 163,840 tokens (the claimed limit in the error message) so this must have been a recent change.
Updating from 1.18.3 to 1.18.4 did not solve it.
I think OpenCode should automatically change its settings when receiving an error like this from the OpenCode provider, especially because it's a first-party provider.
For now, there is a workaround to manually override the context length:
// opencode.json
"provider": {
"opencode": {
"models": {
"deepseek-v4-flash-free": {
"limit": {
"context": 131840,
"output": 32000
}
}
}
},
}
Similar issues (unresolved):
#27929
#35991
Plugins
No response
OpenCode version
1.18.4
Steps to reproduce
- Try and have a conversation with DeepSeek V4 Flash Free that uses more than 131840 tokens (163840 total ctx - 32000 response length)
- Observe error.
Screenshot and/or share link
No response
Operating System
Linux (Arch-based)
Terminal
Ghostty
Description
I was working on a project using DeepSeek V4 Flash Free. OpenCode reports 130,554 tokens and 65% used at the top right. However, I got this message:
This seems strange, as I've previously had threads with this model that exceeded 163,840 tokens (the claimed limit in the error message) so this must have been a recent change.
Updating from 1.18.3 to 1.18.4 did not solve it.
I think OpenCode should automatically change its settings when receiving an error like this from the OpenCode provider, especially because it's a first-party provider.
For now, there is a workaround to manually override the context length:
Similar issues (unresolved):
#27929
#35991
Plugins
No response
OpenCode version
1.18.4
Steps to reproduce
Screenshot and/or share link
No response
Operating System
Linux (Arch-based)
Terminal
Ghostty