Repository navigation
Fix Claude context meter's incorrect 200K fallback - #4664
Merged
Merged
Conversation
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.
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
pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code: 354 tests passed across 25 files; lint and typecheck passed.git diff --checkpassed. No live UI verification or production deployment performed.Fixes #4617