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
DeepSeek V4 Flash Free appears to have incorrectly configured context length #38108
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:
Activity
github-actions commentedon Sep 20, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.