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
fix(provider): Z.AI GLM overflow error not classified as context overflow, causing chain compaction #27629
When Z.AI GLM models (glm-5-turbo, glm-5, glm-5.1) exceed their 200K context window, they return an error that is not recognized by opencode's OVERFLOW_PATTERNS in packages/opencode/src/provider/error.ts. This causes the error to be classified as a generic APICallError instead of ContextOverflowError, preventing auto-compaction and resulting in an unrecoverable chain compaction loop.
Observed Behavior
Session context fills past 200K threshold (common with many MCP tools)
opencode attempts compaction
Z.AI returns: "tokens in request more than max tokens allowed"
opencode classifies this as generic error (not overflow)
No compaction occurs → session retries → same error → infinite loop
Session becomes permanently unusable without DB intervention
Expected Behavior
The error message "tokens in request more than max tokens allowed" should be classified as context overflow, triggering auto-compaction.
Error Text
tokens in request more than max tokens allowed
Root Cause
OVERFLOW_PATTERNS in packages/opencode/src/provider/error.ts does not include a pattern matching Z.AI GLM's overflow error message.
Please check whether your issue is already covered by #27519 before proceeding. If the fix in #27519 also resolves the Z.AI GLM case, consider adding a comment there with the Z.AI-specific context rather than tracking it separately.
Activity
github-actions commentedon May 14, 2026
This issue might be a duplicate of existing issues. Please check:
/tokens in request more than max tokens allowed/itoOVERFLOW_PATTERNS— for the same error message from OpenAI-compatible providers. The root cause, error text, and proposed regex are identical; the only difference is that fix(provider): classify "tokens in request more than max tokens allowed" as context overflow #27519 is scoped more broadly while this issue focuses on Z.AI GLM specifically.Please check whether your issue is already covered by #27519 before proceeding. If the fix in #27519 also resolves the Z.AI GLM case, consider adding a comment there with the Z.AI-specific context rather than tracking it separately.
github-actions commentedon Jul 14, 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.