GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — compaction: LiteLLM router context-window rejections not recognized — session dies instead of compacting · Issue #56403 · anomalyco/opencode

compaction: LiteLLM router context-window rejections not recognized — session dies instead of compacting #56403

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
compaction: LiteLLM router context-window rejections not recognized — session dies instead of compacting#56403
Copy link
Labels
pending closetriaging

Description

@joryirving
joryirving
opened on Oct 17, 2026
Issue body actions

Summary

OpenCode's reactive auto-compaction fails to trigger on context-window rejections returned by a LiteLLM proxy router. LiteLLM (with enable_pre_call_checks: true) rejects oversized requests before any backend sees them, using error phrasing that matches none of OpenCode's context-window error patterns — so the session dies with a System Error instead of compacting and retrying.

Environment

  • opencode version: v2.0.22
  • OS: macOS (darwin arm64, Darwin 27.0.0)
  • Terminal: xterm-256color
  • Shell: fish
  • Install/channel: latest
  • Active plugins: @eleboucher/[email protected], paseo runtime plugin (local file://)

Reproduction

  1. Serve models through a LiteLLM proxy with enable_pre_call_checks: true and a model group whose declared max input tokens is smaller than the session (e.g. a 262,144-token local model).
  2. Grow an OpenCode session past that limit (in my case: 262,619 tokens vs 262,144).
  3. Send the next request.

Expected Behavior

OpenCode recognizes the rejection as a context-window error, auto-compacts, and retries — the same way it does for backend-generated rejections.

Actual Behavior

The error surfaces as a System Error and the session step fails. No compaction is attempted:

[ System Error] litellm.ContextWindowExceededError: litellm.BadRequestError: litellm._pre_call_checks: Context Window exceeded for given call. No models have context window large enough for this call.
Model=openai/qwen3.8-flash-next, Max Input Tokens=262144, Got=262619

LiteLLM: model group 'qwen3.8-flash-next' failed with the error above. No fallback was attempted.

Additional Context

OpenCode classifies context-window rejections by matching the error text against a hardcoded regex list (extracted from the installed binary):

Jn = [/prompt is too long/i, /input too long for requested model/i,
      /exceeded this model context window limit/i, /exceeds context window/i,
      /exceeds (?:the )?(?:model'?s )?maximum context length(?: [\d,]+ tokens?|\s*\([\d,]+\))/i,
      /maximum context length is \d+ tokens/i, /context[_ ]length[_ ]exceeded/i,
      /* ~24 more provider-specific phrasings */]

None of these match LiteLLM's router-generated message (Context Window exceeded for given call. No models have context window large enough for this call. — note "Context Window exceeded" doesn't match context[_ ]length[_ ]exceeded either). The request never reaches the backend, so the backend's own error phrasing — which does match — is never produced.

Contrast with the working case from my logs: a rejection that came from the backend server itself (This model's maximum context length is 147456 tokens. However, you requested…) matched /maximum context length is \d+ tokens/i and OpenCode logged provider rejected the request as too long; compacting and recovered normally. Only router-generated rejections fall through.

Suggested patterns to add:

/no models have context window large enough/i
/context window exceeded for given call/i
/Max Input Tokens=\d+, Got=\d+/i   // litellm's generic tail, also robust

Workaround at the proxy side exists (context_window_fallbacks), but is not viable when the oversized model is intentionally the largest context available and failover is undesired.

Activity

  1. opencode-agent commented on Oct 17, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 17, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed report and the suggested patterns! I think this is a duplicate of #44888. That issue reports the same LiteLLM error (Context Window exceeded for given call. No models have context window large enough for this call.): OpenCode treats it as a generic error instead of a context overflow, so auto-compaction never runs. It is still open and has another v2 reproduction.

    Possible duplicates and related items, most likely first:

    • [Bug] litellm ContextWindowExceededError not detected as context overflow #44888: same problem, a LiteLLM pre-call context-window rejection that isn't recognized as overflow, so the session dead-ends instead of compacting
    • fix(ai): detect litellm context window exceeded error #54608: open PR that adds detection for this LiteLLM error message (linked to [Bug] litellm ContextWindowExceededError not detected as context overflow #44888)
    • [v2] One-shot provider-overflow recovery does not engage when the provider returns an opaque 400 (e.g. bare "invalid request") — session dead-ends with no recovery #46564: related, about overflow recovery not starting when the provider error isn't recognized
    • Image-count 400s (Azure: "Exceeded maximum number of images (50)") are not classified as context overflow, so media-strip compaction never triggers #39677: related, with the same root cause (an error the overflow patterns don't match) but a different error (Azure's image-count 400)

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Any further details or reproductions are welcome on #44888.

  2. opencode-agent
    added
    pending close
    triaging
    on Oct 17, 2026
  3. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 18, 2026 – with OpenCode Agent
    Contributor
    More actions

    We haven't heard back, so I'm closing this as a duplicate of #44888, which reports the same problem: LiteLLM's pre-call rejection (Context Window exceeded for given call. No models have context window large enough for this call.) isn't recognized as a context overflow, so auto-compaction never runs. Please follow #44888 and the open PR #54608. You can add details or reproductions there, including your suggested patterns. If your problem turns out to be different, reply here and we can reopen.

  4. opencode-agent
    closed this as duplicateon Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending closetriaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.