anomalyco / anomalyco/opencode
[Bug] litellm ContextWindowExceededError not detected as context overflow
Open
@nexxeln is already working on this.
Since Aug 25, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
litellm wraps provider context-overflow errors as ContextWindowExceededError: litellm.BadRequestError: Context Window exceeded for given call. No models have context window large enough for this call.
The shared overflow matcher in packages/llm/src/provider-error.ts doesn't recognize the phrase "context window exceeded", so these errors are classified as a generic API error instead of context overflow. This means compaction is never triggered and the session dead-ends.
Plugins
OpenCode version
0.0.0-dev-202608241310
Steps to reproduce
- Use a model behind litellm
- Set the model
max_input_tokensbelow the serving engines' max contect window, so we see the error from litellm, instead of the error message from the serving engine, being automaticall detected by opencode. - Send enough messages to exceed the litellm context window
- Observe the error is treated as a generic API failure rather than triggering automatic compaction
Screenshot and/or share link
Operating System
15.7.9 (24G830)
Terminal
zsh
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.