Skip to content

claude-opus-5 resolves to 200K instead of 1M: hardcoded Anthropic context-mode lists fail closed for new models #578

Closed

Description

@ravshansbox

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:

Root cause

Two hardcoded prefix lists gate Claude context resolution, and both fail closed at 200K:

  1. anthropic_context_mode (crates/jcode-provider-core/src/anthropic.rs:65) only returns Native1M for claude-opus-4-8/4.7, claude-sonnet-5, claude-fable-5. Anything unrecognized returns Standard (200K, no 1M path).
  2. base_is_known_claude_model (crates/jcode-provider-core/src/models.rs:186) lacks claude-opus-5, so context_limit_for_model_with_provider_and_cache skips 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:

  1. Make the classifier tri-state for unknown Claude ids: known-override / unknown. For unknown ids, fall through to the catalog's max_input_tokens instead of returning Standard. Keep the override table strictly for models where the catalog is known to lie (claude-sonnet-4-5).
  2. 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).
  3. Add a regression test asserting that a Claude id present in the catalog with max_input_tokens: 1000000 and 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

  1. added
    bug
    priority: medium
    triage: reproducible
    recurring-theme
    autonomous: likely
    on Jul 24, 2026
  2. 1jehuang commented on Jul 24, 2026

    @1jehuang
    Owner

    Good catch, and thanks for tying it to #450/#577. Two parts are addressed: claude-opus-5 is already registered as native-1M in the built-in catalog on master (ca73f45), and the Anthropic runtime now overrides context_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 to max_input_tokens while 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

  3. 1jehuang commented on Jul 24, 2026

    @1jehuang
    Owner

    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

  4. 1jehuang commented on Jul 24, 2026

    @1jehuang
    Owner

    GitHub's PR API recovered: the fix is now in #580.


    — Jcode agent (automated triage), on behalf of @1jehuang

  5. added a commit that references this issue on Jul 24, 2026
    3a33bcf
  6. 1jehuang commented on Jul 25, 2026

    @1jehuang
    Owner

    Fixed structurally in 1ce99fa35 rather 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_mode now parses family/version (same approach anthropic_reasoning_caps already used) instead of matching prefixes, and defaults optimistically to Native1M for version 5+ generations.
    • base_is_known_claude_model accepts any versioned claude-* id, so the classifier is consulted rather than skipped for unrecognized ids.
    • New anthropic_context_mode_is_verified separates 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 like claude-sonnet-4-5 still beat the catalog, which over-advertises 1M for them.
    • Kimi: the bare k3 id served by api.kimi.com/coding is 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.

  7. 1 remaining item

  8. added a commit that references this issue on Oct 9, 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

    autonomous: likelybugpriority: mediumrecurring-themetriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions