fix(errors): classify Z.AI GLM token-limit message as context overflow (port opencode#35671) - #61725
Closed
teknium1 wants to merge 1 commit into
Closed
fix(errors): classify Z.AI GLM token-limit message as context overflow (port opencode#35671)#61725teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
Port from anomalyco/opencode#35671: Z.AI / Zhipu GLM returns 'tokens in request more than max tokens allowed' (error code 1210) on context overflow. This matched no pattern in _CONTEXT_OVERFLOW_PATTERNS, so the error classified as unknown/retryable — the agent would retry the oversized request instead of triggering context compression. Proven live on main before the fix: classify_api_error() returned FailoverReason.unknown for the exact Z.AI error shape; now returns context_overflow.
Contributor
Author
|
Superseded by the re-authored branch (attribution-check fix): same change on opencode-port/zai-glm-overflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Z.AI / Zhipu GLM context-overflow errors now classify as
context_overflowand route to compression — previously they classified asunknown/retryable, so the agent retried the same oversized request instead of compressing.Port of anomalyco/opencode#35671 (classify zai token limit overflow). Root cause: Z.AI's overflow message
tokens in request more than max tokens allowed(error code 1210) matched no entry in_CONTEXT_OVERFLOW_PATTERNS.Changes
agent/error_classifier.py: add the Z.AI/GLM pattern to_CONTEXT_OVERFLOW_PATTERNStests/agent/test_error_classifier.py: regression test with the real error shape (code 1210, provider=zai)Validation
classify_api_error()on the exact Z.AI 400 bodyFailoverReason.unknownFailoverReason.context_overflowtests/agent/test_error_classifier.pyBug was reproduced live on current main before the fix (the exact error string returned
unknown).Infographic