Skip to content

fix: refresh stale fallback model catalog to current Claude models - #78

Merged
saucam merged 1 commit into
mainfrom
fix/stale-model-catalog
Jul 2, 2026
Merged

fix: refresh stale fallback model catalog to current Claude models#78
saucam merged 1 commit into
mainfrom
fix/stale-model-catalog

Conversation

@saucam

@saucam saucam commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

The model picker in the web UI shows Opus 4.7 / Sonnet 4.6 / Haiku 4.5 — stale names. Two causes:

  1. The fallback MODEL_CATALOG (what models.list serves until the live SDK supportedModels() list is cached) still mapped opus → Opus 4.7 and sonnet → Sonnet 4.6.
  2. The live list only arrives once any session runs a turn since daemon boot — resumed sessions spawn their Claude provider lazily, so after every restart the daemon serves the fallback until the first send. The live-list plumbing itself is intact (the multi-provider refactor did not lose it): the provider reports models on first query, SessionManager caches them, and the web picker refetches whenever it opens while the catalog isn't live.

So the fix is refreshing the fallback (and its dependents), not rewiring.

Changes

  • opusclaude-opus-4-8 (Opus 4.8), sonnetclaude-sonnet-5 (Sonnet 5); haiku unchanged (Haiku 4.5 is current)
  • Context-window table: now recognizes all current 1M families (Fable 5, Opus 4.5–4.8, Sonnet 5, Sonnet 4.6) instead of only opus-4-7 — the sonnet alias and Sonnet 4.6 sessions were under-reported as 200k, inflating ctx% warnings 5×
  • Stale version comments updated across daemon + TUI status bar

Old ids remain valid session values (still-served models; resolveModelId passes any claude-* through) — only the opinionated alias→current-best mapping and the window table moved.

Tests

Rewrote context-windows.test.ts for the current family table (1M families, alias windows, dated point releases, conservative unknown-model miss). Full suite: 722 pass / 0 fail, tsc + biome clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Updated model handling to recognize newer Claude model families and aliases, including newer Opus and Sonnet releases.
    • Expanded support for 1M context-window models and improved default context-window selection for model aliases.
  • Bug Fixes

    • Corrected context-window detection for several model names and aliases.
    • Improved fallback behavior for unknown or unrecognized models.

The fallback MODEL_CATALOG (served by models.list until any session runs
a turn and the live SDK supportedModels() list is cached) still pointed
opus/sonnet at Opus 4.7 / Sonnet 4.6 — so the web UI's model picker
showed old models after every daemon restart, since resumed sessions
spawn their provider lazily and the live list only arrives once a turn
runs. The live-list plumbing itself is intact (provider reports on first
query; the picker refetches while the catalog is not live).

- opus → claude-opus-4-8 (Opus 4.8), sonnet → claude-sonnet-5 (Sonnet 5);
  haiku stays claude-haiku-4-5-20251001
- context-window table now recognizes all current 1M families (Fable 5,
  Opus 4.5-4.8, Sonnet 5, Sonnet 4.6) instead of only opus-4-7 — the
  sonnet alias and Sonnet 4.6 sessions were being under-reported as 200k,
  inflating ctx% warnings 5x
- stale version comments updated across daemon + TUI status bar

Old ids remain valid session values (they're still-served models and
resolveModelId passes any claude-* through); only the opinionated
alias→current-best mapping and the window table moved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.79%. Comparing base (81b726f) to head (d7408d5).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
+ Coverage   80.76%   80.79%   +0.03%     
==========================================
  Files          59       59              
  Lines        8904     8920      +16     
==========================================
+ Hits         7191     7207      +16     
  Misses       1713     1713              
Flag Coverage Δ
daemon 80.79% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/daemon/context-math.ts 100.00% <ø> (ø)
src/daemon/context-windows.ts 100.00% <100.00%> (ø)
src/daemon/models.ts 100.00% <100.00%> (ø)
src/daemon/session.ts 73.85% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updates the model catalog to new canonical IDs (claude-opus-4-8, claude-sonnet-5), reworks context-window resolution to use a fragment-based ONE_MILLION_FAMILIES table with updated alias behavior (opus/sonnet now resolve to 1M, haiku to default), and updates related tests and comments across daemon and TUI files.

Changes

Model catalog and context-window resolution update

Layer / File(s) Summary
Context-window detection logic
src/daemon/context-windows.ts, src/daemon/context-windows.test.ts
Introduces ONE_MILLION_FAMILIES fragment table and rewrites contextWindowForModel() so matching families or -1m suffix return ONE_MILLION_CONTEXT; opus/sonnet aliases now resolve to 1M while haiku resolves to default; tests updated to match new family, alias, and default expectations.
Model catalog and documentation comments
src/daemon/models.ts, src/daemon/context-math.ts, src/daemon/session.ts, src/tui/components/StatusBar.tsx
Updates MODEL_CATALOG opus/sonnet entries to claude-opus-4-8/claude-sonnet-5 with new labels, updates resolveModelId doc comment, and revises inline comments referencing model versions and context-window defaults.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

Not applicable — changes are limited to lookup-table logic, catalog data, and documentation comments without new multi-component interaction flows.

🚥 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 summarizes the main change: refreshing the fallback Claude model catalog to current 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stale-model-catalog

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

@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.

🧹 Nitpick comments (2)
src/daemon/context-windows.ts (2)

25-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider consolidating the 1M-context constant across files.

ONE_MILLION_CONTEXT = 1_000_000 here is effectively re-declared as separate hardcoded literals in context-math.ts (CONTEXT_WINDOW_DEFAULT), session.ts (Session.CONTEXT_WINDOW), and StatusBar.tsx (CONTEXT_WINDOW_FALLBACK), plus per-model contextWindow fields in models.ts. This exact kind of scatter is what let the fallback catalog go stale in the first place (per the PR description). Centralizing on one exported constant (imported everywhere) would prevent a future drift bug of the same shape.

🤖 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/daemon/context-windows.ts` around lines 25 - 39, The 1M-context value is
duplicated across several places and should be centralized to avoid drift. Move
the shared 1_000_000 constant into a single exported source from
context-windows.ts (or an equivalent shared module) and update context-math.ts,
session.ts, StatusBar.tsx, and models.ts to import and use it instead of
hardcoded literals. Keep ONE_MILLION_FAMILIES and any per-model contextWindow
definitions aligned with that shared constant so all context-window fallback
logic stays in sync.

26-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Dot-form family fragments look unused.

Entries like "opus-4.5", "opus-4.6", "opus-4.7", "opus-4.8" (dot separator) sit alongside their dash equivalents, but Anthropic model ids consistently use the dash form (e.g. claude-opus-4-8). If dot-form ids never actually appear in practice, these entries are dead weight in the match loop.

🤖 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/daemon/context-windows.ts` around lines 26 - 38, The model-fragment list
in the context matching logic includes dot-form aliases that appear unused, so
clean up the redundant entries in the match loop. Update the fragment set in the
`context-windows` handling code to keep only the actual Anthropic-style dash
variants used by the model-id matching path, and remove the dot-separated
duplicates if they are not referenced elsewhere. Use the `context-windows.ts`
fragment list and its model matching logic as the place to verify and prune
these aliases.
🤖 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.

Nitpick comments:
In `@src/daemon/context-windows.ts`:
- Around line 25-39: The 1M-context value is duplicated across several places
and should be centralized to avoid drift. Move the shared 1_000_000 constant
into a single exported source from context-windows.ts (or an equivalent shared
module) and update context-math.ts, session.ts, StatusBar.tsx, and models.ts to
import and use it instead of hardcoded literals. Keep ONE_MILLION_FAMILIES and
any per-model contextWindow definitions aligned with that shared constant so all
context-window fallback logic stays in sync.
- Around line 26-38: The model-fragment list in the context matching logic
includes dot-form aliases that appear unused, so clean up the redundant entries
in the match loop. Update the fragment set in the `context-windows` handling
code to keep only the actual Anthropic-style dash variants used by the model-id
matching path, and remove the dot-separated duplicates if they are not
referenced elsewhere. Use the `context-windows.ts` fragment list and its model
matching logic as the place to verify and prune these aliases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 00af627a-155b-4510-b6af-a6adbeba4f57

📥 Commits

Reviewing files that changed from the base of the PR and between 81b726f and d7408d5.

📒 Files selected for processing (6)
  • src/daemon/context-math.ts
  • src/daemon/context-windows.test.ts
  • src/daemon/context-windows.ts
  • src/daemon/models.ts
  • src/daemon/session.ts
  • src/tui/components/StatusBar.tsx

@saucam

saucam commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Both nitpicks acknowledged, skipping as out of scope for this fix:

  • Consolidating the 1M constant across context-windows.ts / context-math.ts / Session.CONTEXT_WINDOW is a cross-module refactor with its own blast radius — worth doing, but not inside a catalog refresh.
  • Dot-form fragments (opus-4.8) predate this PR's pattern (the original table had opus-4.7 dot-forms too) — they're defensive against display-name-ish inputs and harmless; dropping them is cosmetic.

@saucam
saucam merged commit 0c714fe into main Jul 2, 2026
5 checks passed
@saucam
saucam deleted the fix/stale-model-catalog branch July 2, 2026 17:39
saucam added a commit that referenced this pull request Jul 6, 2026
…log (#117)

The 0.2.0 entry only covered the protocol/packages train (#100-#116) and
missed ten PRs that also ship in this release: the untrusted-content
sanitization and cross-tenant memory fixes (#91, #93 — now under a
proper Security heading), the performance run (#94-#99), and the model
catalog work (#78, #79).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant