Skip to content

Fix Claude context meter's incorrect 200K fallback - #4664

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-github-issue-4617-thr_fw2jzgejxv
Oct 2, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-github-issue-4617-thr_fw2jzgejxv

Conversation

@ymichael

@ymichael ymichael commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When a Claude session was recreated, BB lost its measured context capacity and guessed 200K for plain Opus/Sonnet model names until a result arrived. This made threads running with a 1M window appear over their limit. Resident follow-up turns already retained the measured capacity.

What changed

Read Claude's context usage asynchronously on session initialization and feed the reported capacity into subsequent assistant usage updates. Plain models now keep capacity unknown until reported instead of assuming 200K. The existing collector bounds the read to five seconds and discards stale token-count snapshots while preserving capacity from delayed reads; prompt submission and streaming do not wait for it. Model changes and newer lookups invalidate pending capacity reads; session freshness checks also remain in place. Existing explicit 1M/Fable compatibility hints remain unchanged.

No server/daemon wire fields, public APIs, or CLI flags changed.

How you verified

  • Read the affected live thread's recorded snapshot: 363,550 tokens used out of 1,000,000.
  • Regression cases failed before the fix: initialization produced no context snapshot, and plain model hints incorrectly returned 200K.
  • Verified both 200K and 1M initialization reports persist through assistant usage updates, with compaction invalidation preserved.
  • pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code: 354 tests passed across 25 files; lint and typecheck passed.
  • Delayed-read regressions for both 200K and 1M failed against the prior PR commit and pass after the race fix; stale usage is not republished, and previous-model capacity is discarded.
  • git diff --check passed. No live UI verification or production deployment performed.

Fixes #4617

AGENT GENERATED

@ymichael
ymichael merged commit c65a47f into main Oct 2, 2026
21 checks passed
@ymichael
ymichael deleted the bb/fix-github-issue-4617-thr_fw2jzgejxv branch October 2, 2026 00:15
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.

Claude context meter shows / 200,000 at the start of every turn for Opus/Sonnet that actually run with 1M

1 participant