fix: prioritize Anthropic 1M limits over cached context limits#2460
Merged
code-yeongyu merged 1 commit intodevfrom Mar 11, 2026
Merged
fix: prioritize Anthropic 1M limits over cached context limits#2460code-yeongyu merged 1 commit intodevfrom
code-yeongyu merged 1 commit intodevfrom
Conversation
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes a precedence regression where cached limits overrode Anthropic 1M mode, with new tests verifying the fix.
kilhyeonjun
added a commit
to kilhyeonjun/oh-my-opencode
that referenced
this pull request
Mar 18, 2026
…ers post-GA After Anthropic's 1M context GA (2026-03-13), the beta header is no longer sent. The existing detection relied solely on the beta header to set anthropicContext1MEnabled, causing all Anthropic models to fall back to the 200K default despite models.dev reporting 1M. Update resolveActualContextLimit to check per-model cached limits from provider config (populated from models.dev data) when the explicit 1M flag is not set. Priority order: 1. Explicit 1M mode (beta header or env var) - all Anthropic models 2. Per-model cached limit from provider config 3. Default 200K fallback This preserves the code-yeongyu#2460 fix (explicit 1M flag always wins over cached values) while allowing GA models to use their correct limits. Fixes premature context warnings at 140K and unnecessary compaction at 156K for opus-4-6 and sonnet-4-6 users without env var workaround.
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
context-window-monitor.tsanddynamic-truncator.tscachedLimit ?? anthropicLimit— cached 200K could override 1M modegetAnthropicActualLimit(), others → cached limitFixes regression from #2366
Summary by cubic
Ensures Anthropic’s 1M context window is always used when 1M mode is enabled, instead of being overridden by cached 200K limits. Prevents incorrect context warnings and truncation for Anthropic sessions.
getAnthropicActualLimit()and ignore cached model limits.context-window-monitor.tsanddynamic-truncator.ts.Written for commit 4516b2e. Summary will update on new commits.