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
GLM / Vertex overflow errors with INVALID_ARGUMENT are not classified as context overflow #23713
opencode does not seem to classify Google / GLM-style INVALID_ARGUMENT context-limit failures as context overflow, which prevents the normal overflow / compaction path from running.
Version
Observed against local installed opencode --version:
1.14.19
Actual error shape
Bad Request: [{
"error": {
"code": 400,
"message": "Requested token count exceeds the model's maximum context length of 202752 tokens. You requested a total of 211266 tokens: 179266 tokens from the input messages and 32000 tokens for the completion. Please reduce the number of tokens in the input messages or the completion to fit within the limit.",
"status": "INVALID_ARGUMENT"
}
}]
Expected behavior
This should be classified as a context overflow / prompt-too-large condition, the same way other provider-specific context-limit messages are handled.
Why I think this is the miss
Current overflow detection in packages/opencode/src/provider/error.ts appears to include patterns like:
input token count.*exceeds the maximum
maximum context length is \d+ tokens
model_context_window_exceeded
context_length_exceeded
But not the GLM / Vertex phrasing:
Requested token count exceeds the model's maximum context length ...
So this error is likely falling through as a generic API error instead of context_overflow.
Suggested fix
Add an overflow matcher for this message shape, for example:
If your issue is distinct (e.g., the specific INVALID_ARGUMENT error shape from Vertex/GLM that isn't matched by existing patterns), feel free to clarify that distinction so this can be tracked separately.
This looks distinct from the generic GLM overflow issues because the provider response here is a Vertex/GLM INVALID_ARGUMENT body rather than a finish-reason style overflow signal.
Observed error shape:
Bad Request: [{
"error": {
"code": 400,
"message": "Requested token count exceeds the model's maximum context length of 202752 tokens. You requested a total of 211266 tokens: 179266 tokens from the input messages and 32000 tokens for the completion. Please reduce the number of tokens in the input messages or the completion to fit within the limit.",
"status": "INVALID_ARGUMENT"
}
}]
In a local source check, the narrow fix shape was simply to treat this message pattern as a context overflow alongside the existing matchers:
Requested token count exceeds the model's maximum context length ...
Once classified as overflow, the existing compaction path can continue instead of surfacing a generic API error.
Activity
github-actions commentedon Apr 21, 2026
This issue might be a duplicate of existing issues. Please check:
model_context_window_exceededfinish reason is not handled correctly, also resulting in overflow not being detectedIf your issue is distinct (e.g., the specific
INVALID_ARGUMENTerror shape from Vertex/GLM that isn't matched by existing patterns), feel free to clarify that distinction so this can be tracked separately.karabil commentedon Apr 21, 2026
This looks distinct from the generic GLM overflow issues because the provider response here is a Vertex/GLM
INVALID_ARGUMENTbody rather than a finish-reason style overflow signal.Observed error shape:
In a local source check, the narrow fix shape was simply to treat this message pattern as a context overflow alongside the existing matchers:
Requested token count exceeds the model's maximum context length ...Once classified as overflow, the existing compaction path can continue instead of surfacing a generic API error.
github-actions commentedon Jul 4, 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.