Skip to content

fix(agents): resolve fable-5 1M context window for claude-cli provider - #101368

Closed
xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:fix/gap-ctx-claude-cli-fable5-context-window
Closed

xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:fix/gap-ctx-claude-cli-fable5-context-window

Conversation

@xialonglee

@xialonglee xialonglee commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

claude-cli + claude-fable-5 falls back to the default 200K context window instead of 1M. The resolveAnthropicFixedContextWindow Fable 5 guard only matched anthropic and anthropic-vertex providers, leaving claude-cli unhandled.

Both call paths were affected:

  • resolveContextTokensForModelFromCache (direct context resolution)
  • resolveDiscoveredAnthropicFixedContextWindow (discovery cache upgrade)

Same root cause as #100572: a new model was added to the catalog but the claude-cli provider boundary was not enumerated in the Fable 5 guard.

Why This Change Was Made

Add provider === 'claude-cli' to the existing Fable 5 fixed-window guard, matching the pattern already used by the Mythos 5 / Sonnet 5 guards and the GA 1M prefix check on the next branch.

User Impact

claude-cli/claude-fable-5 now correctly resolves to 1,000,000 token context window via ANTHROPIC_FABLE_CONTEXT_TOKENS. All three Anthropic-affiliated providers (anthropic, anthropic-vertex, claude-cli) now receive the correct fixed context window for Fable 5.

Evidence

Unit tests (66 passed, 0 failed)

$ node scripts/run-vitest.mjs run src/agents/context.test.ts

 Test Files  1 passed (1)
      Tests  66 passed (66)

Real behavior proof — resolveAnthropicFixedContextWindow live output

A proof script exercised resolveAnthropicFixedContextWindow() directly against the production source to verify that claude-cli/claude-fable-5 resolves to the correct 1M context window:

=== resolveAnthropicFixedContextWindow — Real Behavior Proof ===

  ✓ provider="claude-cli" model="claude-fable-5"
    result=1000000 expected=1000000
  ✓ provider="anthropic" model="claude-fable-5"
    result=1000000 expected=1000000
  ✓ provider="anthropic-vertex" model="claude-fable-5"
    result=1000000 expected=1000000
  ✓ provider="claude-cli" model="claude-opus-4-8-20260514"
    result=1048576 expected=1048576
  ✓ provider="claude-cli" model="claude-sonnet-4-6"
    result=1048576 expected=1048576
  ✓ provider="openai" model="gpt-5.5"
    result=undefined expected=undefined
  ✓ provider="claude-cli" model="claude-haiku-4-5"
    result=undefined expected=undefined

7/7 assertions checked
✓ All assertions passed — claude-cli/claude-fable-5 resolves to 1M context window

Key coverage:

  • claude-cli Fable 5 → 1,000,000 (the fix target)
  • anthropic / anthropic-vertex Fable 5 → 1,000,000 (existing coverage preserved)
  • claude-cli GA 1M models → 1,048,576 (Opus 4.8, Sonnet 4.6 via existing prefix-based branch)
  • Non-Anthropic → undefined (openai correctly excluded)
  • Non-1M Anthropic → undefined (claude-haiku-4-5 correctly excluded)

Real environment tested: Linux Node 24, commit 4a1919d, branch fix/gap-ctx-claude-cli-fable5-context-window
Exact command run: npx tsx scripts/proof-context-resolution.mjs (exercising resolveAnthropicFixedContextWindow from production source)
What was not tested: Live gateway end-to-end with actual claude-cli provider subscription (requires Claude CLI subscription and API key)

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jul 7, 2026
The resolveAnthropicFixedContextWindow fable-5 guard only matched
anthropic and anthropic-vertex providers, leaving claude-cli unhandled.
Without this, claude-cli + claude-fable-5 fell through to the GA 1M
prefix check where fable-5 doesn't match, returning undefined and
causing fallback to the default 200K context window.

Both call paths were affected:
- resolveContextTokensForModelFromCache (direct)
- resolveDiscoveredAnthropicFixedContextWindow (discovery cache upgrade)

Same root cause as openclaw#100572: new model added to catalog but claude-cli
provider boundary was not enumerated.

Fix: add provider === 'claude-cli' to the fable-5 guard, matching the
pattern already used by the GA 1M guard on the next branch.
@xialonglee
xialonglee force-pushed the fix/gap-ctx-claude-cli-fable5-context-window branch from 13b9324 to 4a1919d Compare July 7, 2026 05:02
@clawsweeper

clawsweeper Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 2:26 PM ET / 18:26 UTC.

Summary
The branch adds claude-cli to Fable 5 fixed context-window resolution and adds focused agent context regression cases.

PR surface: Source 0, Tests +5. Total +5 across 2 files.

Reproducibility: yes. Source inspection shows current main excludes claude-cli from the Fable 5 fixed-window branch, so a claude-cli/claude-fable-5 lookup falls through to the default/fallback context path.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: persistent cache schema: src/agents/context.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

Risk before merge

Maintainer options:

  1. Decide the mitigation before merge
    Land this narrow resolver fix if maintainers want the immediate context-budget repair, then reconcile or retarget the overlapping broader Claude CLI Fable 5 metadata PR.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair lane is needed; the remaining action is maintainer landing-order review with the broader overlapping Claude CLI Fable 5 PR.

Maintainer decision needed

  • Question: Should maintainers land this narrow resolver-only repair now, or wait for the broader Claude CLI Fable 5 metadata PR to subsume it?
  • Rationale: The patch is correct and proven, but another open PR by the same author overlaps this exact resolver change while also touching higher-risk provider/model metadata surfaces.
  • Likely owner: vincentkoc — Recent history ties this owner to the same context resolver and adjacent Fable/Mythos model support path.
  • Options:
    • Land the narrow repair first (recommended): Merge this low-risk resolver fix for immediate context-window correctness, then rebase or trim the broader metadata PR before it lands.
    • Wait for the broader PR: Hold this PR until the broader Claude CLI Fable 5 metadata PR clears proof and merge-risk review, then close or retarget this narrower branch if it becomes redundant.

Security
Cleared: The diff only changes an in-repo context-window resolver guard and focused tests; it does not touch dependencies, workflows, credentials, package metadata, downloads, or secret handling.

Review details

Best possible solution:

Land this narrow resolver fix if maintainers want the immediate context-budget repair, then reconcile or retarget the overlapping broader Claude CLI Fable 5 metadata PR.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main excludes claude-cli from the Fable 5 fixed-window branch, so a claude-cli/claude-fable-5 lookup falls through to the default/fallback context path.

Is this the best way to solve the issue?

Yes for the submitted narrow bug fix. Extending the existing fixed-window guard is the right layer for direct and discovery-cache context resolution; broader allowlist and catalog work remains separate in #101453.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against dd228d5f3cee.

Label changes

Label justifications:

  • P2: This is a bounded Claude CLI context-window bug with limited blast radius but real context-budgeting impact for the affected model.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes live output from the production resolver at head commit 4a1919d4c012, showing the fixed claude-cli/claude-fable-5 result and relevant preserved cases.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes live output from the production resolver at head commit 4a1919d4c012, showing the fixed claude-cli/claude-fable-5 result and relevant preserved cases.
Evidence reviewed

PR surface:

Source 0, Tests +5. Total +5 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 5 0 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 6 1 +5

What I checked:

  • Current-main resolver gap: Current main already treats claude-cli as an Anthropic-family provider, but the Fable 5 fixed-window branch only matches anthropic and anthropic-vertex, so claude-cli/claude-fable-5 falls through before the PR change. (src/agents/context-resolution.ts:153, dd228d5f3cee)
  • Discovery caller path: Discovered or inferred claude-cli/<model> entries flow through resolveAnthropicFixedContextWindow, so the same guard affects discovery-cache context upgrades as well as direct model context resolution. (src/agents/context.ts:321, dd228d5f3cee)
  • PR diff scope: The PR changes only the Fable 5 provider guard and adds tests covering discovery, direct resolution, authored windows, and materialized lower-window behavior for claude-cli/claude-fable-5. (src/agents/context.test.ts:84, 4a1919d4c012)
  • Real behavior proof: The PR body includes head-current live output for commit 4a1919d4c012 showing resolveAnthropicFixedContextWindow returns 1,000,000 for claude-cli/claude-fable-5 while preserving existing positive and negative cases. (4a1919d4c012)
  • Related overlap: Open PR fix(anthropic): add Fable 5 to Claude CLI catalog #101453 covers the same resolver subset plus broader Claude CLI allowlist, alias, manifest, and catalog work, but it remains open and proof-sensitive, so it is not a safe superseding close target for this narrower PR. (1d26a88eea20)
  • Feature-history provenance: History shows recent Claude model/context work touched this resolver and adjacent Fable/Sonnet/Mythos model contracts, including Fable 5 adaptive-thinking support and Mythos/Sonnet fixed-context additions. (src/agents/context-resolution.ts:148, f305e707a359)

Likely related people:

  • vincentkoc: Authored recent Mythos 5 model support that touched src/agents/context-resolution.ts, src/agents/context.test.ts, and related Anthropic model contracts; also merged the adjacent Fable 5 stream-wrapper fix. (role: recent model/context contributor; confidence: high; commits: f305e707a359, 37022833c5da; files: src/agents/context-resolution.ts, src/agents/context.test.ts, packages/llm-core/src/model-contracts/anthropic.ts)
  • steipete: Authored the merged Claude Fable 5 adaptive-thinking support that established the Fable 5 model identity contract this resolver path uses. (role: feature owner and adjacent owner; confidence: high; commits: 0e7b5c34292c; files: packages/llm-core/src/model-contracts/anthropic.ts, extensions/anthropic/register.runtime.ts, src/agents/context.ts)
  • vortexopenclaw: Authored merged Claude Sonnet 5 support across the same context resolver, tests, Claude CLI metadata, and model-contract surfaces. (role: recent model metadata contributor; confidence: medium; commits: 1f6ddb5df089; files: src/agents/context-resolution.ts, src/agents/context.test.ts, extensions/anthropic/cli-catalog.ts)
  • zhangguiping-xydt: Authored the merged Fable 5 context1m stream-wrapper fix for a closely related model-list drift on another Anthropic runtime path. (role: adjacent Fable 5 contributor; confidence: medium; commits: 37022833c5da; files: extensions/anthropic/stream-wrappers.ts, extensions/anthropic/stream-wrappers.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-07T05:17:56.132Z sha 4a1919d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T08:21:29.488Z sha 4a1919d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T15:45:34.029Z sha 4a1919d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T17:31:23.747Z sha 4a1919d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T17:38:30.568Z sha 4a1919d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-07T18:17:51.070Z sha 4a1919d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@xialonglee xialonglee changed the title fix(agents): resolve fable-5 1M context window for claude-cli provider refactor(anthropic): unify GA 1M model detection with shared capability helper Jul 7, 2026
@xialonglee
xialonglee force-pushed the fix/gap-ctx-claude-cli-fable5-context-window branch from ba64fc1 to 4a1919d Compare July 7, 2026 18:10
@xialonglee xialonglee changed the title refactor(anthropic): unify GA 1M model detection with shared capability helper fix(agents): resolve fable-5 1M context window for claude-cli provider Jul 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
@vincentkoc vincentkoc self-assigned this Jul 11, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Closing as a partial duplicate of #101453. That PR includes this same context-window correction and also updates the Anthropic CLI allowlist, aliases, labels, catalog, and migration coverage, so landing this branch separately would leave the provider surfaces inconsistent. Thanks for the fix; the broader canonical PR preserves the work.

@vincentkoc vincentkoc closed this Jul 11, 2026
@xialonglee
xialonglee deleted the fix/gap-ctx-claude-cli-fable5-context-window branch July 18, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants