chore: upgrade qoder-agent-sdk to 1.0.23 and consume the new context-usage type - #28
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>
The new SDK ships the updated get_context_usage response type (contextWindow.usedPercentage plus percentage-only categories), so the turn tracker now consumes the SDK type directly instead of a local stand-in: drop the cast, the dead token-count branches, and the CLI-reported window path that the API no longer provides. Token counts shown in the meter tooltip are derived from the reported percentage against the effective context window (configured tier first). Smoke-tested against a real CLI; the one affected router test now asserts the percentage-derived shape. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
Mid-turn usage chunks were built against the model catalog window and could carry zeroed token counts, so the meter flashed to the catalog default (200K) or to its 0% placeholder during a response and only recovered when the post-response refresh ran. Transform options now carry the effective per-model context window, the router drops zeroed usage snapshots while a real reading is buffered, and the buffered reading survives across turns (it is the fallback chain's previous-turn source) instead of being cleared at turn boundaries. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
…gent-sdk # Conflicts: # CHANGELOG.md # src/qoder/runtime/qoder-turn-tracker.ts # tests/unit/qoder/runtime/qoder-chat-runtime.test.ts
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
@qoder-ai/qoder-agent-sdkfrom 1.0.16 to1.0.23. The new SDK ships the updated
get_context_usageresponsetype (
contextWindow.usedPercentageplus percentage-onlycategories, matching the documented cost-usage API), sofetchContextUsagein the turn tracker now consumes the SDK typedirectly: the local stand-in interface, the
as unknown ascast, andthe dead branches for
tokenCountsAvailable/usedTokens/maxTokensare removed. The CLI no longer exposes absolute token counts, so the
token counts shown in the meter tooltip are derived from the reported
percentage against the effective context window (configured per-model
tier first, then the previous turn, then the model catalog).
response the meter flashed to the catalog default window (200K) or to
its 0% placeholder, then recovered after the response. Two causes:
mid-turn usage chunks were built against the model catalog window,
and zeroed streaming snapshots overwrote the meter. Fix: transform
options now carry the effective per-model context window
(
buildUsageInfoprefers it), the router drops zeroed usage chunkswhile a real reading is buffered, and the buffered reading survives
across turns — it is the fallback chain's previous-turn source and no
longer gets cleared at turn boundaries.
Verification
npm run typechecknpm run lintnpm run test(3326 passed)npm run buildnpm run release:checknpm run audit:prod(
scripts/smoke-qoder-sdk.mjspasses against qodercli 1.1.21;end-to-end in Obsidian with a 400K tier: baseline 9% "37k / 400k",
mid-stream hover keeps 9% "38k / 400k" instead of flashing to the
placeholder, post-response 10% "39k / 400k")
Safety
CHANGELOG.md