Skip to content

fix: hide unknown Claude context usage - #308

Merged
zxch3n merged 1 commit into
mainfrom
fix/hide-unknown-context-usage
Sep 2, 2026
Merged

fix: hide unknown Claude context usage#308
zxch3n merged 1 commit into
mainfrom
fix/hide-unknown-context-usage

Conversation

@lodystage

@lodystage lodystage Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Related issue

Internal same-repository fix; no issue is required for contribution intake.

Problem / pressure

Claude models whose runtime metadata omits a 1m marker temporarily appear to have a 200K context window, even when the SDK later reports a 1M authoritative window. The placeholder is presented as fact and creates a misleading first-turn experience.

Summary

  • Advance the Claude ACP adapter to represent an unknown context window as null instead of 200K.
  • Suppress numeric context usage updates until a cached, inferred, resumed, or result-reported window is available.
  • Clear stale usage when switching to a model whose window is still unknown, then publish and cache the authoritative value from result.modelUsage.

Before / after

Before After
A fresh Fable 5.1 session could display used / 200K until its first result. Context usage stays hidden until the SDK reports the real 1M window.
Switching to an uncached model reused a guessed 200K window. The old display is cleared while the new window is unknown.

Test plan

  • pnpm --filter acp-extension-claude build
  • pnpm --filter acp-extension-claude test:run — 813 passed, 20 skipped
  • pnpm --filter acp-extension-claude check

Context handoff

Instructions for reviewing agents

  • Review focus: Review nullable window seeding, every usage_update emission, and the model-switch clear path in the Claude adapter.
  • Decisions to challenge: Confirm that the existing zero-sized ACP update is the right wire-level clear signal because ACP requires numeric fields.
  • Plausible failures / evidence gaps: A backend that never returns result.modelUsage.contextWindow will keep usage hidden; no live authenticated Claude API run was performed.

Authoring context

  • User goal / directives: Avoid presenting a guessed context size; hide context usage until a trustworthy window becomes available.
  • Constraints / non-goals: Preserve sub-second session creation and model switching without reintroducing the blocking getContextUsage call.
  • Risk-bearing decisions: Internal state uses null, while model switches emit numeric 0/0 solely to clear the previously persisted display.
  • Destructive or irreversible behavior: No destructive behavior or migration; rollback is the previous Claude adapter submodule pointer.
  • Deliberately not done or tested: No live authenticated provider request was run; deterministic adapter build, full tests, lint, and formatting cover the changed paths.
  • Unknowns / confidence: High confidence for standard Claude SDK results; third-party backends that omit valid window metadata will intentionally show no context usage.

@zxch3n
zxch3n merged commit 6aeeb8f into main Sep 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant