Skip to content

chore: upgrade qoder-agent-sdk to 1.0.23 and consume the new context-usage type - #28

Merged
luoxuanzao merged 5 commits into
mainfrom
chore/upgrade-qoder-agent-sdk
Aug 17, 2026
Merged

chore: upgrade qoder-agent-sdk to 1.0.23 and consume the new context-usage type#28
luoxuanzao merged 5 commits into
mainfrom
chore/upgrade-qoder-agent-sdk

Conversation

@luoxuanzao

@luoxuanzao luoxuanzao commented Aug 17, 2026

Copy link
Copy Markdown
Member

Stacked on #27 — merge that first; the diff here shrinks as #27 lands.

Summary

  • SDK upgrade: bumped @qoder-ai/qoder-agent-sdk from 1.0.16 to
    1.0.23. The new SDK ships the updated get_context_usage response
    type (contextWindow.usedPercentage plus percentage-only
    categories, matching the documented cost-usage API), so
    fetchContextUsage in the turn tracker now consumes the SDK type
    directly: the local stand-in interface, the as unknown as cast, and
    the dead branches for tokenCountsAvailable/usedTokens/maxTokens
    are 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).
  • Meter stability while streaming (user-reported): during a
    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
    (buildUsageInfo prefers it), the router drops zeroed usage chunks
    while 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 typecheck
  • npm run lint
  • npm run test (3326 passed)
  • npm run build
  • npm run release:check
  • npm run audit:prod
  • Tested affected qodercli behavior against a real CLI when applicable
    (scripts/smoke-qoder-sdk.mjs passes 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

  • No credentials, private vault content, internal URLs, or personal paths are included
  • User-visible changes are documented in CHANGELOG.md

luoxuanzao and others added 5 commits August 17, 2026 21:46
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
@luoxuanzao
luoxuanzao merged commit b86909e into main Aug 17, 2026
10 checks passed
@luoxuanzao
luoxuanzao deleted the chore/upgrade-qoder-agent-sdk branch August 17, 2026 23:43
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