fix(context-limit-resolver): check modelContextLimitsCache before Anthropic hardcoded fallback#2837
Closed
anas-asghar4831 wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
…hropic hardcoded fallback resolveActualContextLimit() skipped modelContextLimitsCache for Anthropic providers, always falling back to the hardcoded 200K default. Users who configured model context limits in opencode.json had their config silently ignored for Anthropic providers. Now checks the config-populated cache first for ALL providers, then falls back to provider-specific logic only when no cached entry exists. Fixes code-yeongyu#2836
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Correctly prioritizes user-configured context limits for Anthropic providers, fixing a bug where they were bypassed, while maintaining identical logic for all other providers.
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Owner
|
Superseded by #2664 which was merged and addresses the same context-limit-resolver cache priority issue. The approach in #2664 also handles the Anthropic 4.6 vs older model distinction. Thanks @anas-asghar4831! |
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.
Summary
resolveActualContextLimit()now checksmodelContextLimitsCachefirst for all providers before falling back to provider-specific logicopencode.jsonFixes #2836
Problem
resolveActualContextLimit()had an early return for Anthropic providers that bypassedmodelContextLimitsCache:This caused Claude Opus 4.6 (1M context, GA since March 2026) to report as 200K when used behind a proxy that doesn't return the
context-1mbeta header.Fix
Check the config-populated cache first, then fall back to provider-specific defaults:
Changes
src/shared/context-limit-resolver.ts— Reorder resolution: cache → provider-specific → nullsrc/shared/context-limit-resolver.test.ts— Update test to validate cache is respected for Anthropic; add fallback testTesting
Summary by cubic
Respect cached model context limits by checking
modelContextLimitsCachebefore provider fallbacks inresolveActualContextLimit(). Fixes Anthropic models incorrectly reporting 200K when a cached 1M limit is configured fromopencode.json.Written for commit af5aaf7. Summary will update on new commits.