Repository navigation
Description
Problem
claude-opus-5 shows a 200K context window in the TUI meter / compaction budget, even though the live Anthropic catalog reports 1M for it.
Evidence from ~/.jcode/logs/jcode-2026-07-24.log:
[2026-07-24 23:34:40.969] [INFO] Context limit cache: claude-opus-5 = 1000k
[2026-07-24 23:34:42.269] [INFO] Anthropic available models [oauth::claude-1]: claude-fable-5, ..., claude-opus-4-8, claude-opus-5, claude-sonnet-4-5-20250929, claude-sonnet-4-6, claude-sonnet-5
So the catalog knows 1M; the static classifier disagrees and wins on some paths.
Verified with a temporary probe test in jcode-provider-core:
opus-5=None opus-4-8=Some(1000000) mode=Standard
(context_limit_for_model_with_provider("claude-opus-5", Some("claude")) returns None, i.e. callers fall back to DEFAULT_CONTEXT_LIMIT = 200K.)
This is the third instance of the same shape:
- Sonnet 5 context size is incorrect #450 Sonnet 5 showed 200K (fixed by adding it to the prefix list).
- Kimi K3 (k3) resolves to 200K instead of 1M context in TUI meter and compaction budget #577 Kimi K3 shows 200K while its catalog says 1,048,576.
- now
claude-opus-5.
Root cause
Two hardcoded prefix lists gate Claude context resolution, and both fail closed at 200K:
anthropic_context_mode(crates/jcode-provider-core/src/anthropic.rs:65) only returnsNative1Mforclaude-opus-4-8/4.7,claude-sonnet-5,claude-fable-5. Anything unrecognized returnsStandard(200K, no 1M path).base_is_known_claude_model(crates/jcode-provider-core/src/models.rs:186) lacksclaude-opus-5, socontext_limit_for_model_with_provider_and_cacheskips the authoritative Claude branch and depends entirely on the dynamic cache.
The dynamic cache is not consulted on every path. Notably the default Provider::context_window (crates/jcode-provider-core/src/lib.rs:424) calls the cache-free context_limit_for_model_with_provider, and the Anthropic runtime does not override context_window(). In local (non-remote) sessions update_context_limit_for_model (crates/jcode-tui/src/tui/app/model_context.rs:639) reads self.provider.context_window(), so the 1M value the catalog already fetched never reaches the meter or the compaction budget.
The design consequence: every new Anthropic model launch silently regresses to 200K until someone edits two prefix lists. Comments in the code justify distrusting max_input_tokens because it over-advertises 1M for 200K-capped models (e.g. claude-sonnet-4-5), which is a fair reason to keep an override table, but the current fallback direction is wrong: unknown ids should prefer catalog data, not the 200K default.
Suggested direction
Rather than only adding claude-opus-5 to the lists:
- Make the classifier tri-state for unknown Claude ids: known-override / unknown. For unknown ids, fall through to the catalog's
max_input_tokensinstead of returningStandard. Keep the override table strictly for models where the catalog is known to lie (claude-sonnet-4-5). - Ensure the catalog-derived limit reaches all resolution paths, i.e. have the Anthropic runtime's
context_window()consult the populated cache (same gap as Kimi K3 (k3) resolves to 200K instead of 1M context in TUI meter and compaction budget #577 for direct OpenAI-compatible profiles). - Add a regression test asserting that a Claude id present in the catalog with
max_input_tokens: 1000000and absent from the override table resolves to 1M, so future launches are covered without a code edit.
Short term, claude-opus-5 needs Native1M + known-model entries and pricing, but without (1) and (2) this will recur on the next release.
Environment
- jcode v0.56.0 (9aa8c5a), macOS aarch64
- Provider: Anthropic OAuth (
claude-oauth:claude-opus-5)
Activity
1jehuang commentedon Jul 24, 2026
Good catch, and thanks for tying it to #450/#577. Two parts are addressed:
claude-opus-5is already registered as native-1M in the built-in catalog on master (ca73f45), and the Anthropic runtime now overridescontext_window()to go through the cache-aware lookup, so a live catalog limit for a Claude id missing from the static override table reaches the TUI meter and the compaction budget instead of falling back to 200K. Added a regression test asserting an unknown Claude id prefers the catalog's 1M over the default. Your suggestion (1), making the classifier tri-state so unknown ids fall through tomax_input_tokenswhile the override table stays only for models the catalog over-advertises, is the deeper change and is left for a maintainer decision since it changes the fail direction for all future Claude ids.— Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Jul 24, 2026
Note: the fix is committed on branch
triage/2026-07-24-batch(pushed). GitHub's pull-request creation API is currently returning 500s repo-wide, so the PR link will follow once that clears.— Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Jul 24, 2026
GitHub's PR API recovered: the fix is now in #580.
— Jcode agent (automated triage), on behalf of @1jehuang
fix(anthropic): resolve context window via the cache-aware lookup so …
1jehuang commentedon Jul 25, 2026
Fixed structurally in
1ce99fa35rather than by adding another prefix entry.All three instances of this bug (#450 Sonnet 5, #577 Kimi K3, #578 Opus 5) shared one shape: a hardcoded prefix list gated context resolution and failed closed at
DEFAULT_CONTEXT_LIMIT(200K), so every new model silently reported a ~5x too-small window until someone edited a list.What changed in
jcode-provider-core:anthropic_context_modenow parses family/version (same approachanthropic_reasoning_capsalready used) instead of matching prefixes, and defaults optimistically toNative1Mfor version 5+ generations.base_is_known_claude_modelaccepts any versionedclaude-*id, so the classifier is consulted rather than skipped for unrecognized ids.anthropic_context_mode_is_verifiedseparates live-probed knowledge from optimistic guesses, establishing an explicit precedence: verified pin > live catalog / user config > optimistic guess, and never the 200K default. Verified 200K-capped models likeclaude-sonnet-4-5still beat the catalog, which over-advertises 1M for them.k3id served byapi.kimi.com/codingis now recognized, and K3+ resolves to its real 1M window instead of the K2-era 256K.The regression tests assert the failure shape, not today's ids: unreleased generations (
claude-opus-6,claude-opus-7-20270101,claude-haiku-5, ...) must never fall back to the default. A future model release should no longer need a code change.fix(models): stop new models resolving to the 200K default (#577, #578)
chore(release): v0.57.0
test(context): add a context-window resolution matrix, and fix the 26…
chore: sync fork with upstream (224 behind), preserve fork commits (#2)
1 remaining item
chore(release): v0.57.0
fix(anthropic): resolve context window via the cache-aware lookup so …
test(context): add a context-window resolution matrix, and fix the 26…
test(context): add a context-window resolution matrix, and fix the 26…
fix(models): stop new models resolving to the 200K default (1jehuang#577
chore(release): v0.57.0
fix(anthropic): resolve context window via the cache-aware lookup so …
test(context): add a context-window resolution matrix, and fix the 26…
test(context): add a context-window resolution matrix, and fix the 26…
test(context): add a context-window resolution matrix, and fix the 26…
test(context): add a context-window resolution matrix, and fix the 26…
fix(models): stop new models resolving to the 200K default (1jehuang#577
chore(release): v0.57.0
fix(anthropic): resolve context window via the cache-aware lookup so …
chore(release): v0.57.0