Skip to content

Apply provider context window settings to occupancy lookups - #923

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-7762-providersnamecontextwindow-is-parsed-but-never-applied-wire
Sep 12, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-7762-providersnamecontextwindow-is-parsed-but-never-applied-wire

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Applies providers.<name>.contextWindow at config load so occupancy, compaction, and the status-bar meter honor the setting
  • Keys the override as <provider>:<model> for every model on a provider that sets the field, plus the bare model id for the resolved provider
  • Leaves the known OAuth-projection gap: Codex/xAI synthetic settings still drop the field

Verification

  • bun run typecheck, bun run build, and bun run test pass
  • bun run check passes (6957 pass, 0 fail)

Fixes CL-7762

The settings field was parsed but occupancy and compaction still
used models.dev metadata and family heuristics. An override at
config load is the one place that can beat both without being
wiped by a later pricing refresh.
@linear-code

linear-code Bot commented Sep 12, 2026

Copy link
Copy Markdown

CL-7762

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Critic · Comment

Wires providers.<name>.contextWindow into contextWindowFor at loadConfig after resolveProvider. Overrides beat registry/heuristic; OAuth projection still drops the field.

Findings

  • src/provider/context-window.ts:111 — override lookup reuses registry lookupCandidates, so a prefixed id for a provider that did not set contextWindow still hits the resolved provider's bare key. Sequence: firepass {models:["fp-large"], contextWindow:32000} + other {models:["fp-large"]} (no window), resolve firepass; contextWindowFor("other:fp-large") and hasContextWindowFor("other:fp-large") return 32k / true via candidate fp-large. Occupancy uses bare source.model / config.model, so the meter still honors the startup provider; the model-catalog provider:model path does not. Production already writes <provider>:<model> for every overridden provider — exact override match would keep the bare-key rule without this bleed. The unit test at context-window.test.ts:45 encodes the fallthrough by setting only a bare map.

Notes

  • OAuth gap is documented, not silently copied (providersAsSettings omits the field; settingsForResolution overwrites). Leave it.
  • Bare keys stay frozen at the loadConfig-resolved provider. After /agent switch, compaction (lastModel = event.source?.model) and the status-bar meter (state.config.model) miss the other provider's override; maxTokensFor still reads live settings. Matches the stated keying; not a merge blocker.

@TheGreatAxios
TheGreatAxios merged commit a156094 into main Sep 12, 2026
9 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-7762-providersnamecontextwindow-is-parsed-but-never-applied-wire branch September 12, 2026 03:16
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