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
Sub2API preserves the upstream error message. AI Gateway also preserves this HTTP 400 response because its provider-error normalization only rewrites 499/5xx responses, and its existing input-length normalization only handles Responses API requests with an input field.
OpenCode then receives the exact message “Prompt exceeds max length”. The current context-overflow matcher recognizes messages such as “prompt is too long”, “request_too_large”, and “input is too long for requested model”, but not this Zhipu error message. The failure is therefore treated as a generic provider error, and the existing context-overflow recovery path is not entered.
Expected behavior:
An HTTP 400 response with provider error code 1261 and message “Prompt exceeds max length” should be classified as a context-overflow failure. OpenCode should invoke its existing compaction/recovery behavior, or report a specific context-overflow error if recovery is not possible.
Proposed focused fix:
recognize Prompt exceeds max length and Prompt exceeds maximum length in the shared provider error classifier;
keep the match case-insensitive;
add regression tests for the HTTP 400 invalid_request_error shape;
ensure unrelated errors such as max_tokens exceeds max length, ordinary bad requests, and HTTP 429 rate-limit responses are not classified as context overflow.
This is a provider-independent change in OpenCode’s LLM error classification. It does not require changes to AI Gateway or Sub2API.
I can submit a small PR containing only this classifier change and its regression tests if this behavior is in scope for the current dev branch.
Activity
github-actions commentedon Aug 25, 2026
This issue does not follow our contributing guidelines.
What needs to be fixed:
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might also be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Aug 25, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.
Suixinlei commentedon Oct 3, 2026
I can provide a complete reproduction from our OpenCode v2 Sandbox integration.
Environment:
Reproduction:
The upstream returns HTTP 400 with this response body:
{
"error": {
"code": "1261",
"message": "Prompt exceeds max length"
}
}
Sub2API preserves the upstream error message. AI Gateway also preserves this HTTP 400 response because its provider-error normalization only rewrites 499/5xx responses, and its existing input-length normalization only handles Responses API requests with an
inputfield.OpenCode then receives the exact message “Prompt exceeds max length”. The current context-overflow matcher recognizes messages such as “prompt is too long”, “request_too_large”, and “input is too long for requested model”, but not this Zhipu error message. The failure is therefore treated as a generic provider error, and the existing context-overflow recovery path is not entered.
Expected behavior:
An HTTP 400 response with provider error code 1261 and message “Prompt exceeds max length” should be classified as a context-overflow failure. OpenCode should invoke its existing compaction/recovery behavior, or report a specific context-overflow error if recovery is not possible.
Proposed focused fix:
Prompt exceeds max lengthandPrompt exceeds maximum lengthin the shared provider error classifier;invalid_request_errorshape;max_tokens exceeds max length, ordinary bad requests, and HTTP 429 rate-limit responses are not classified as context overflow.This is a provider-independent change in OpenCode’s LLM error classification. It does not require changes to AI Gateway or Sub2API.
I can submit a small PR containing only this classifier change and its regression tests if this behavior is in scope for the current dev branch.