Skip to content

fix(providers): give Claude 4.6/4.7 their 1M context windows - #839

Open
MilkClouds wants to merge 1 commit into
lidge-jun:devfrom
MilkClouds:fix/anthropic-1m-context-windows
Open

fix(providers): give Claude 4.6/4.7 their 1M context windows#839
MilkClouds wants to merge 1 commit into
lidge-jun:devfrom
MilkClouds:fix/anthropic-1m-context-windows

Conversation

@MilkClouds

@MilkClouds MilkClouds commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • ANTHROPIC_MODEL_CONTEXT_WINDOWS omits claude-opus-4-7, claude-opus-4-6, and claude-sonnet-4-6, although all three ship in ANTHROPIC_MODELS. Anthropic documents all three at 1M.
  • Without a window entry those models advertise max_input_tokens: null, shouldMarkOneMillion() rejects them on its typeof window !== "number" guard, and buildAnthropicModelInfos() never emits the [1m] picker row. Claude Code then accounts them at its 200k default, so the extra context is unreachable from the /model picker.
  • buildClaudeContextWindows() skips them for the same reason, so they are also absent from /api/claude-code contextWindows.

Observed on 2.7.43 with an OAuth (Claude subscription) anthropic provider. /v1/models before:

claude-opus-4-6      claude-opus-4-6 (anthropic)       max_input=None
claude-opus-4-7      claude-opus-4-7 (anthropic)       max_input=None
claude-sonnet-4-6    claude-sonnet-4-6 (anthropic)     max_input=None
claude-opus-4-8      claude-opus-4-8 (anthropic)       max_input=1000000
claude-opus-4-8[1m]  claude-opus-4-8 (anthropic) · 1M  max_input=1000000

After, each of the three gains its · 1M row (24 advertised models to 27).

User config cannot work around this: OAUTH_RECONCILE_FIELDS includes modelContextWindows, so a hand-added entry in providers.anthropic is reconciled back to the registry value on the next ocx start.

The parity test also gains a roster-wide guard, so a future model added to ANTHROPIC_MODELS without a window fails instead of silently losing its [1m] row.

Verification

  • bun run typecheck — clean.
  • bun test tests/provider-registry-parity.test.ts — 31 pass.
  • New guard driven red first: with the registry map reverted it fails (30 pass / 1 fail), confirming it is not vacuous.
  • bun run privacy:scan — passed.
  • bun run test — 6420 pass / 6 skip / 8 fail / 5 errors. All 8 failures and 5 errors reproduce on unmodified upstream/dev in this environment: 3 in tests/cli-help.test.ts and tests/service.test.ts (service/CLI diagnostics), and 5 module-resolution errors from gui/ React deps not installed locally. None touch this change; the four files nearest to it (provider-registry-parity, claude-model-info, desktop-3p, oauth-provider-reconcile) are 61 pass / 0 fail.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing docs describe this table.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (Static model metadata only.)

Summary by CodeRabbit

  • New Features

    • Added support for Claude Opus 4.7, Opus 4.6, and Sonnet 4.6 with 1-million-token context windows.
  • Bug Fixes

    • Improved model metadata validation to ensure supported Anthropic models report valid context-window limits.

ANTHROPIC_MODEL_CONTEXT_WINDOWS omitted claude-opus-4-7, claude-opus-4-6, and
claude-sonnet-4-6 even though all three ship in ANTHROPIC_MODELS. Without a
window those models advertise max_input_tokens: null, shouldMarkOneMillion()
rejects them on its typeof guard, and buildAnthropicModelInfos never emits the
[1m] picker row — so Claude Code accounts them at its 200k default instead of
the 1M Anthropic documents for all three.

Also guard the whole roster: every model in the anthropic provider's list must
carry a context window, so the next model addition cannot repeat the omission.
The loop was driven red against the unfixed map before landing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqLtuGeb1Mb2izcYRZXgT4
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The registry adds 1,000,000-token context windows for Claude Opus 4.7, Opus 4.6, and Sonnet 4.6. Parity tests verify these entries and require positive context windows for all configured Anthropic models.

Changes

Anthropic context metadata

Layer / File(s) Summary
Context metadata and parity validation
src/providers/registry.ts, tests/provider-registry-parity.test.ts
src/providers/registry.ts:217 adds 1,000,000-token context-window entries for three Anthropic models. tests/provider-registry-parity.test.ts:610-616 verifies the model metadata and checks that every configured Anthropic model has a positive context-window value.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: assigning 1M context windows to Claude 4.6 and 4.7 models.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/providers/registry.ts`:
- Line 217: Align the Claude Sonnet 4.6 context-window limit across
ANTHROPIC_MODEL_CONTEXT_WINDOWS, the overrides in generate-jawcode-metadata.ts,
and related tests by choosing one supported value. Keep claude-sonnet-4-6
consistent between catalog generation and direct provider configuration, and do
not add a [1m] variant unless the Anthropic registry exposes and routes that
model ID.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f26daa53-2a85-4862-a906-9f44e308211c

📥 Commits

Reviewing files that changed from the base of the PR and between e1fc0f2 and ada8a9a.

📒 Files selected for processing (2)
  • src/providers/registry.ts
  • tests/provider-registry-parity.test.ts

Comment thread src/providers/registry.ts
// devlog/_plan/260710_provider_hardening/001_research_frontier.md.
const ANTHROPIC_MODELS = ["claude-fable-5", "claude-sonnet-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5"];
const ANTHROPIC_MODEL_CONTEXT_WINDOWS: Record<string, number> = { "claude-sonnet-5": 1_000_000, "claude-fable-5": 1_000_000, "claude-opus-5": 1_000_000, "claude-opus-4-8": 1_000_000, "claude-haiku-4-5": 200_000 };
const ANTHROPIC_MODEL_CONTEXT_WINDOWS: Record<string, number> = { "claude-sonnet-5": 1_000_000, "claude-fable-5": 1_000_000, "claude-opus-5": 1_000_000, "claude-opus-4-8": 1_000_000, "claude-opus-4-7": 1_000_000, "claude-opus-4-6": 1_000_000, "claude-sonnet-4-6": 1_000_000, "claude-haiku-4-5": 200_000 };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n 'claude-(opus-4-7|opus-4-6|sonnet-4-6)(\[1m\])?' \
  src/providers/registry.ts \
  src/generated/jawcode-model-metadata.ts

Repository: lidge-jun/opencodex

Length of output: 13756


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- registry context ---'
sed -n '190,235p' src/providers/registry.ts

printf '%s\n' '--- metadata symbols and consumers ---'
rg -n -C 3 'jawcode-model-metadata|MODEL_CONTEXT_WINDOWS|contextWindow|context_window|claude-sonnet-4-6' \
  src package.json README.md 2>/dev/null | head -n 240

printf '%s\n' '--- generated-file provenance ---'
rg -n -i -C 3 'jawcode-model-metadata|model metadata|generate.*metadata|metadata.*generat' \
  . --glob '!src/generated/jawcode-model-metadata.ts' --glob '!node_modules' --glob '!dist' --glob '!build' | head -n 240

Repository: lidge-jun/opencodex

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- generated metadata import and catalog merge ---'
rg -n -C 8 'jawcodeModelMetadata|JawcodeModelMetadata|apply.*Metadata|contextWindow.*metadata|metadata.*contextWindow|modelContextWindows' \
  src/codex/catalog.ts src/providers src/router.ts

printf '%s\n' '--- Anthropic registry entries ---'
rg -n -C 18 'anthropic-apikey|anthropic-oauth|ANTHROPIC_MODEL_CONTEXT_WINDOWS|ANTHROPIC_MODELS' \
  src/providers/registry.ts

printf '%s\n' '--- generator source ---'
sed -n '1,180p' scripts/generate-jawcode-metadata.ts

printf '%s\n' '--- catalog contract and resync notes ---'
sed -n '30,58p' devlog/_chase/_model/002_catalog_contract.md
sed -n '84,94p' devlog/_chase/_model/008_logic_delta.md
sed -n '70,110p' devlog/_plan/260730_remote_issue_merge_round/090_generated_metadata_resync.md

Repository: lidge-jun/opencodex

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- catalog metadata application ---'
rg -n -C 14 'augmentRoutedModelsWithJawcodeMetadata|applyProviderConfigHints|jawcode|metadata' \
  src/codex/catalog/provider-fetch.ts src/codex/catalog/*.ts | head -n 260

printf '%s\n' '--- catalog model construction and precedence ---'
rg -n -C 12 'modelContextWindows|contextWindow|context_window' \
  src/codex/catalog/provider-fetch.ts src/codex/catalog/aggregation.ts src/codex/catalog/parsing.ts | head -n 260

printf '%s\n' '--- generator input and output contract ---'
cat -n scripts/generate-jawcode-metadata.ts | sed -n '1,150p'

printf '%s\n' '--- direct source-of-truth statements ---'
rg -n -C 3 'PROVIDER_REGISTRY.*(source|truth|authoritative)|registry.*(source|truth|authoritative)|generated.*metadata.*(hint|snapshot)|context.*(registry|generator)' \
  devlog docs-site src | head -n 220

Repository: lidge-jun/opencodex

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- jawcode augmentation implementation ---'
rg -n 'function augmentRoutedModelsWithJawcodeMetadata|export function augmentRoutedModelsWithJawcodeMetadata|listJawcodeModelMetadata|getJawcodeModelMetadata' \
  src/codex/catalog/provider-fetch.ts
sed -n '600,700p' src/codex/catalog/provider-fetch.ts

printf '%s\n' '--- metadata lookup and model merge calls ---'
rg -n -C 10 'augmentRoutedModelsWithJawcodeMetadata|applyProviderConfigHints\(.*metadata|metadata.*contextWindow|contextWindow.*metadata' \
  src/codex/catalog/provider-fetch.ts

printf '%s\n' '--- generator override application ---'
sed -n '80,180p' scripts/generate-jawcode-metadata.ts

printf '%s\n' '--- relevant tests ---'
rg -n -C 8 'jawcode.*metadata|sonnet-4-6|contextWindow.*200.?000|contextWindow.*1.?000.?000' \
  tests src --glob '*test*' --glob '*.spec.*' | head -n 280

Repository: lidge-jun/opencodex

Length of output: 36362


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '842,930p' src/codex/catalog/provider-fetch.ts
sed -n '930,1010p' src/codex/catalog/provider-fetch.ts

printf '%s\n' '--- exact catalog parity assertions ---'
sed -n '590,625p' tests/provider-registry-parity.test.ts

printf '%s\n' '--- generator override references and rationale ---'
rg -n -C 8 'CONTEXT_WINDOW_OVERRIDES|claude-sonnet-4-6\[1m\]|claude-sonnet-4-6.*200' \
  scripts tests devlog src --glob '!src/generated/jawcode-model-metadata.ts'

Repository: lidge-jun/opencodex

Length of output: 17502


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re
from pathlib import Path

registry = Path("src/providers/registry.ts").read_text()
generator = Path("scripts/generate-jawcode-metadata.ts").read_text()
metadata = Path("src/generated/jawcode-model-metadata.ts").read_text()
catalog = Path("src/codex/catalog/provider-fetch.ts").read_text()

def value(pattern, text, label):
    match = re.search(pattern, text)
    if not match:
        raise SystemExit(f"missing {label}")
    return int(match.group(1).replace("_", ""))

registry_window = value(
    r'"claude-sonnet-4-6"\s*:\s*([0-9_]+)',
    registry,
    "registry window",
)
override_window = value(
    r'"anthropic/claude-sonnet-4-6"\s*:\s*([0-9_]+)',
    generator,
    "generator override",
)
metadata_match = re.search(
    r'\["claude-sonnet-4-6",\s*([0-9]+).*?\]\s*,\s*\["claude-sonnet-4-6\[1m\]",\s*([0-9]+)',
    metadata,
)
if not metadata_match:
    raise SystemExit("missing generated metadata rows")
metadata_window = int(metadata_match.group(1))
metadata_1m_window = int(metadata_match.group(2))

if "Math.min(model.contextWindow, configuredCap)" not in catalog:
    raise SystemExit("missing lower-bound merge rule")

effective_catalog_window = min(metadata_window, registry_window)

print({
    "registry": registry_window,
    "generator_override": override_window,
    "generated_base": metadata_window,
    "generated_1m": metadata_1m_window,
    "effective_catalog_window": effective_catalog_window,
})
assert registry_window == 1_000_000
assert override_window == 200_000
assert metadata_window == 200_000
assert metadata_1m_window == 200_000
assert effective_catalog_window == 200_000

Repository: lidge-jun/opencodex

Length of output: 382


Align the Claude Sonnet 4.6 context-window contract.

src/providers/registry.ts:217 sets claude-sonnet-4-6 to 1_000_000, while scripts/generate-jawcode-metadata.ts:30-32 intentionally overrides both generated IDs to 200_000. The catalog merge therefore uses 200_000, but direct provider configuration uses 1_000_000. Choose one supported limit and align the registry, generator override, and related tests. Do not add a [1m] variant unless the Anthropic registry exposes and routes that ID.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/providers/registry.ts` at line 217, Align the Claude Sonnet 4.6
context-window limit across ANTHROPIC_MODEL_CONTEXT_WINDOWS, the overrides in
generate-jawcode-metadata.ts, and related tests by choosing one supported value.
Keep claude-sonnet-4-6 consistent between catalog generation and direct provider
configuration, and do not add a [1m] variant unless the Anthropic registry
exposes and routes that model ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant