Skip to content

feat: on-demand context-window variants in the /model picker - #1

Merged
DevVig merged 2 commits into
mainfrom
feat/on-demand-context-window-variants
Jul 7, 2026
Merged

feat: on-demand context-window variants in the /model picker#1
DevVig merged 2 commits into
mainfrom
feat/on-demand-context-window-variants

Conversation

@DevVig

@DevVig DevVig commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Register each Claude model once per context window it supports (1M and/or 200K) as a distinct, labeled entry in OMP's native /model picker. The context window is now chosen on demand — pick the other entry — instead of via a global config edit + /reload.

Example (config contextWindow: "auto", Pro plan):

Picker id Window
claude-bridge/claude-opus-4-8 1M
claude-bridge/claude-opus-4-8-200k 200K
claude-bridge/claude-fable-5 200K
claude-bridge/claude-fable-5-1m 1M

How

  • src/models.ts
    • Add parseVariantId(id){ baseId, forced?: "1m" | "200k" } (base ids never end in those suffixes, so the split is unambiguous).
    • Make claudeCodeModelId variant-aware: a suffixed id forces its window regardless of config; the unsuffixed id follows the config default.
    • Replace applyLongContext with buildVariantModels: expands each model into one entry per available window, orders default-first, labels each (1M)/(200K), and sets each entry's contextWindow to its true window so OMP's status bar and auto-compaction threshold stay accurate.
  • src/index.ts — register buildVariantModels(MODELS, longContextSettings).
  • Behavior change: provider.contextWindow (auto/1m/200k) now only decides which window is the unsuffixed default; it no longer hides models. Both windows stay pickable wherever a runtime exists, so existing modelRoles / enabledModels ids keep resolving.

Notes

  • Forcing 1M is a request: some models may still be served 200K by subscription entitlement. CLAUDE_BRIDGE_DEBUG=1 logs the served window.
  • No version bump: 0.7.0 is unreleased (no tags). A 0.8.0 bump is worth considering before publishing, since this changes the registered model set.

Test plan

  • bun run typecheck clean
  • bun run test → 10/10 (rewritten tests/unit-context-window.mjs: expansion, default-first ordering, auto/Max flip, 200k/1m defaults + fallbacks, parseVariantId, claudeCodeModelId round-trips)
  • Manual /model visual check in a running OMP after /reload (can't drive the TUI from CI)

Register each model once per context window it supports (1M and/or 200K)
as a distinct, labeled picker entry, so the window is chosen on demand
from OMP's native /model list instead of via a global config edit + reload.

- models.ts: add parseVariantId; make claudeCodeModelId variant-aware
  (a "-1m"/"-200k" suffixed id forces that window; the unsuffixed id
  follows the config default). Replace applyLongContext with
  buildVariantModels: default-first ordering, "(1M)"/"(200K)" labels,
  and each entry's contextWindow set to its true window so the status
  bar and auto-compaction threshold stay accurate.
- index.ts: register buildVariantModels(MODELS, longContextSettings).
- provider.contextWindow (auto|1m|200k) now only picks which window is
  the unsuffixed default; it no longer hides models. Both windows stay
  in the picker wherever a runtime exists, so existing modelRoles /
  enabledModels ids keep working.
- Rewrite the context-window unit tests (10/10) and README accordingly.
Copilot AI review requested due to automatic review settings July 7, 2026 01:38
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d2cb63f-0bcf-4c2d-8bae-75b29c6e4ed1

📥 Commits

Reviewing files that changed from the base of the PR and between 142296d and 72b0f47.

📒 Files selected for processing (5)
  • README.md
  • documentation/completed/features/2026-07-06_on-demand-context-window-variants.md
  • src/index.ts
  • src/models.ts
  • tests/unit-context-window.mjs

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

Copilot AI 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.

Pull request overview

This PR updates the model registration logic so each Claude model is registered once per supported context window (1M and/or 200K) as separate, labeled entries in OMP’s native /model picker. This makes the context window a per-selection choice (pick the other entry) rather than a global config + /reload toggle, while keeping the unsuffixed id aligned with the configured default.

Changes:

  • Add variant-aware model-id parsing and runtime resolution so -1m / -200k picker ids force the requested window.
  • Replace single-entry long-context registration with variant expansion (default-first ordering, consistent (1M)/(200K) labels, accurate contextWindow per entry).
  • Update unit tests and documentation to reflect the new picker behavior and default-window semantics.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit-context-window.mjs Rewrites tests to validate variant expansion, ordering, defaults/fallbacks, suffix parsing, and runtime id mapping.
src/models.ts Introduces parseVariantId, makes claudeCodeModelId variant-aware, and replaces applyLongContext with buildVariantModels.
src/index.ts Switches provider registration to use buildVariantModels(MODELS, longContextSettings).
README.md Updates user-facing docs to explain variant entries in /model, default-window behavior, and the offered windows per model.
documentation/completed/features/2026-07-06_on-demand-context-window-variants.md Adds an implementation/decision record describing the approach, risks, and verification steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/models.ts
Comment thread src/models.ts Outdated
- claudeCodeModelId: report the actually-requested window in the "no
  runtime" error (the forced suffix when present, else the config mode)
  instead of always the config mode.
- buildVariantModels: detect unknown model ids up front via
  MODEL_IDS_IN_ORDER, before probing the forced resolvers, so an
  unrecognized id no longer triggers their "hiding it" console.error
  logs for a model the fast-path actually keeps.
@DevVig
DevVig merged commit 4855687 into main Jul 7, 2026
2 checks passed
@DevVig
DevVig deleted the feat/on-demand-context-window-variants branch July 7, 2026 01:52
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.

2 participants