Repository navigation
fix(ai): recognize more context overflow errors - #57982
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks good. I ran isContextOverflow on both checkouts with the three real payloads (the Z.ai 1261 JSON body, the custom-endpoint message and the Go gateway's 400 [unsupported_request] …configured input limit.). All three are unrecognized on the base and classified as context overflow with this change. An unrelated unsupported_request (image input) error stays unclassified. provider-error.test.ts passes (37 tests) and the packages/ai typecheck passes. I didn't run a full compact-and-retry session because the simulated model can't return these provider errors.
Public API is unchanged: only internal error-classification patterns change.
No concerns: the patterns are narrow and specific to each message.
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.
A few providers word their "context too long" errors in ways the overflow classifier doesn't match yet. When that happens the error isn't recognized as too long, so instead of compacting and retrying, the session just fails and stays stuck until you compact by hand.
This adds the three wordings I could confirm from real reports:
Prompt exceeds max lengthPrompt too long)The input is too long for the selected model.This text request is too large for the model's configured input limit.The patterns stay specific to each message, so nothing generic like "too long" or "input limit" gets swept in.
Fixes #57412
Related: #50574, #56296, #56454
Added by the opencode bot (AI-generated).
Fixes #56296
Related: #50574, #50761