fix: restore the context usage meter on CLI 1.1.21 and keep the chosen context-window tier - #27
Merged
Merged
Conversation
qodercli 1.1.21 changed the get_context_usage control response from flat token counts (totalTokens/maxTokens/rawMaxTokens/percentage) to a percentage-based shape (contextWindow.usedPercentage, categories, tokenCountsAvailable). The turn tracker kept reading the old fields, so every lookup came back undefined and the context usage meter was stuck at its "appears after the first response" placeholder. Parse the new shape: percentage drives the meter directly, absolute token counts are used when the CLI reports them (tokenCountsAvailable), and window size falls back to the previous turn or the model catalog. Router tests now mock the new wire shape. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
The post-response context-usage refresh fell back to the model catalog default window whenever the CLI omitted maxTokens, so a tier chosen in the per-model editor (such as 400K) reverted to the default (200K) after the first message. Route the effective per-model context window into the turn tracker and prefer it over the catalog fallback when the CLI reports no absolute window. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_context_usagecontrolresponse from flat token counts (
totalTokens/maxTokens/rawMaxTokens/percentage) to a percentage-based shape(
contextWindow.usedPercentage,categories,tokenCountsAvailable).The turn tracker kept reading the old fields, so every lookup came back
undefined and the context usage meter stayed stuck at its "appears after
the first response" placeholder. The tracker now parses the new shape:
the reported percentage drives the meter, absolute token counts are only
trusted when
tokenCountsAvailableis true, and the window size fallsback to the effective per-model override, then the previous turn, then
the model catalog.
tier chosen in the per-model editor (such as 400K) and reverted to the
model catalog default (200K), because the CLI omits
maxTokensin thenew shape. The runtime now routes the effective per-model context window
into the tracker, so the chosen tier survives every response.
Verification
npm run typechecknpm run lintnpm run test(3324 passed)npm run buildnpm run release:checknpm run audit:prod(end-to-end in Obsidian against qodercli 1.1.21: meter shows a real
percentage after the first response, and a 400K tier selection stays
400K across multiple responses instead of reverting to 200K)
Safety
CHANGELOG.md