Skip to content

[Bug] litellm ContextWindowExceededError not detected as context overflow #44888

Description

@fabian33-ops

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

  1. Use a model behind litellm
  2. Set the model max_input_tokens below 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.
  3. Send enough messages to exceed the litellm context window
  4. Observe the error is treated as a generic API failure rather than triggering automatic compaction

Screenshot and/or share link

Image

Operating System

15.7.9 (24G830)

Terminal

zsh

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions