Repository navigation
fix(ai): detect litellm context window exceeded error - #54608
Closed
fabian33-ops wants to merge 1 commit into
Closed
fabian33-ops wants to merge 1 commit into
fabian33-ops wants to merge 1 commit into
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
There was a problem hiding this comment.
The fix works. I ran opencode run against a local OpenAI-compatible server that returns LiteLLM's ContextWindowExceededError with HTTP 400. On the base branch the session stops with the error and makes no compaction attempt. With this PR the error is classified as a context overflow and opencode sends the compaction request. packages/ai tests and the type check pass.
The new pattern is specific enough not to catch unrelated errors, and rate-limit messages are still excluded. The public API is unchanged.
No concerns.
Related: #46564
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #44888
Type of change
What does this PR do?
When LiteLLM rejects a chat completion request for being too large context, it shows a special error message. Because it is special for LiteLLM, opencode simply aborts, and does not detect the error as being max context size reached.
How did you verify your code works?
Trying it locally, running the whole testsuite, using the patch every day.
Screenshots / recordings
Checklist
Added by the opencode bot (AI-generated).
Related: #46564