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 — fix(ai): detect litellm context window exceeded error by fabian33-ops · Pull Request #54608 · anomalyco/opencode

Conversation

@fabian33-ops

@fabian33-ops fabian33-ops commented Oct 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #44888

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #46564

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fabian33-ops
fix(ai): detect litellm context window exceeded error
ca0eac0
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencode-agent[bot]
opencode-agent Bot reviewed Oct 11, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent opencode-agent Bot mentioned this pull request Oct 17, 2026
compaction: LiteLLM router context-window rejections not recognized — session dies instead of compacting #56403
Closed
@joryirving joryirving mentioned this pull request Oct 17, 2026
[Bug] litellm ContextWindowExceededError not detected as context overflow #44888
Closed
@fabian33-ops fabian33-ops closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug] litellm ContextWindowExceededError not detected as context overflow

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@fabian33-ops
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.
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.