#18721: fix: prefer configured contextTokens over model catalog in status display
stale
size: XS
trusted-contributor
Cluster:
Context Management Fixes
Fixes #18696
When `contextTokens` is set in agent config (e.g., 1M for Claude Max), the status display now correctly shows the configured value instead of the model's built-in contextWindow (200K).
The bug was in `commands-status.ts` where the explicitly passed `contextTokens` parameter (derived from model catalog) was overwriting the agent defaults.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes a bug where the `/status` display showed the model catalog's built-in `contextWindow` (e.g., 200K) instead of the user-configured `contextTokens` (e.g., 1M for Claude Max). The one-line fix in `buildStatusReply` ensures `agentDefaults.contextTokens` takes precedence over the `contextTokens` parameter (derived from model catalog lookup) when assembling the agent config object passed to `buildStatusMessage`.
- The `??` (nullish coalescing) correctly falls back to the param-provided `contextTokens` when `agentDefaults.contextTokens` is not configured
- The fix aligns with how `buildStatusMessage` itself resolves context tokens (`entry?.contextTokens ?? args.agent?.contextTokens ?? lookupContextTokens(model)`) — the agent config value now correctly survives into the `args.agent.contextTokens` slot
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it is a minimal, correct one-line fix with no risk of regressions.
- The change is a single line that uses nullish coalescing to prefer the configured contextTokens over the model-catalog-derived value. The logic is consistent with how contextTokens is resolved elsewhere in the codebase (e.g., resolveContextTokens, buildStatusMessage). The fallback behavior is preserved when no agent default is configured.
- No files require special attention.
<sub>Last reviewed commit: 57759ce</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19412: fix(status): prefer configured contextTokens over session entry
by rafaelipuente · 2026-02-17
87.4%
#18886: fix(status): prefer configured contextTokens over model metadata
by BinHPdev · 2026-02-17
87.2%
#15726: fix(sessions): use model contextWindow instead of agent contextToke...
by lailoo · 2026-02-13
81.5%
#17604: fix(context): use getAvailable() to prevent cross-provider model ID...
by aldoeliacim · 2026-02-16
81.3%
#11109: fix(tui): prefer config contextTokens over persisted session value
by marezgui · 2026-02-07
79.1%
#17414: fix(sessions): refresh contextTokens when model override changes
by michaelbship · 2026-02-15
78.8%
#16478: fix(gateway): fall back to lookupContextTokens on model switch
by colddonkey · 2026-02-14
78.7%
#23279: fix: show correct context limit in status when runtime model differs
by Imccccc · 2026-02-22
78.6%
#15632: fix: use provider-qualified key in MODEL_CACHE for context window l...
by linwebs · 2026-02-13
78.0%
#18997: fix: improve context overflow error messages and docs
by realhoratiobot · 2026-02-17
77.2%