You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Claude Code context usage remains unavailable or stale throughout a multi-step agent turn, even while assistant responses and tool calls complete. bb already extracts per-request context counts from assistant messages, but only emits the context-window snapshot when it processes the final result. Emit updates during the turn when those counts arrive.
Versions and environment
bb CLI 0.42.1; local npm-installed bb-app on Linux/WSL.
Provider: claude-code; installed Claude CLI 2.1.263 (the CLI version does not establish the bundled SDK version).
Source inspected at 06aeaa994942ae7527dc49d2268c1f801e8542a0.
Observed in an active personal-workspace thread and an active managed-worktree thread. A local stats plugin reads bb's public thread-event API; the missing data is confirmed directly through that API.
Existing live threads were inspected; a fresh controlled reproduction on this source commit has not been run.
Start a Claude Code thread with a task requiring several sequential model/tool cycles, for example: Inspect this repository, run its checks, investigate failures, and summarize what you find.
While assistant messages and tool calls are completing, query the events on the running bb server:
Compare with turn/started and item/completed events. Check again after the provider's final result.
Expected vs actual
Observed on thr_j3r5kg9m79 while active:
One turn/started at sequence 9.
The newest 100 events included 18 item/completed, 17 item/started, and 8 item/agentMessage/delta events.
The filtered context/token-usage/turn-completed query above returned exactly [].
A second active Claude thread, thr_ra6tsbrfyy, likewise had no context or token-usage events during its first ongoing turn.
Expected: context-window updates during the turn when the SDK provides a request usage sample, without waiting for the entire agent run to finish. This need not be a token-by-token counter. Missing readings should remain unknown; cumulative tokens must not be substituted for context occupancy.
Evidence
The source suggests the reporting boundary is the cause:
Suggested direction: emit a context-window delta when a valid top-level assistant request sample arrives, preserving model capacity, estimated status, and turn attribution. Do not count subagent context as the parent context. Add a regression test that observes context events before the final result.
Investigation thread (reporter's local bb instance): http://127.0.0.1:38886/threads/thr_68imcxrdav . All relevant observations are included above so access to that instance is unnecessary.
What was ruled out
Not merely a rendering or polling problem: the usage events themselves are absent from the public event API.
Completed assistant messages/tool calls are not being mistaken for a persisted turn/completed: the latter was explicitly queried and absent.
No claim that the provider lacks intermediate usage: the adapter already extracts it from assistant messages.
Suggested priority and effort
Medium: context pressure is invisible during long Claude tool loops, especially a first run or one extended by steering. Waiting for a final result is a workaround; no data loss was established.
Summary
Claude Code context usage remains unavailable or stale throughout a multi-step agent turn, even while assistant responses and tool calls complete. bb already extracts per-request context counts from assistant messages, but only emits the context-window snapshot when it processes the final result. Emit updates during the turn when those counts arrive.
Versions and environment
claude-code; installed Claude CLI 2.1.263 (the CLI version does not establish the bundled SDK version).06aeaa994942ae7527dc49d2268c1f801e8542a0.Steps to reproduce
Suggested minimal reproduction (not separately executed):
Start a Claude Code thread with a task requiring several sequential model/tool cycles, for example:
Inspect this repository, run its checks, investigate failures, and summarize what you find.While assistant messages and tool calls are completing, query the events on the running bb server:
curl -sS 'http://127.0.0.1:38886/api/v1/threads/<thread-id>/events?types=thread%2FcontextWindowUsage%2Fupdated,thread%2FtokenUsage%2Fupdated,turn%2Fcompleted&order=desc&limit=20'Compare with
turn/startedanditem/completedevents. Check again after the provider's final result.Expected vs actual
Observed on
thr_j3r5kg9m79while active:turn/startedat sequence 9.item/completed, 17item/started, and 8item/agentMessage/deltaevents.[].thr_ra6tsbrfyy, likewise had no context or token-usage events during its first ongoing turn.Expected: context-window updates during the turn when the SDK provides a request usage sample, without waiting for the entire agent run to finish. This need not be a token-by-token counter. Missing readings should remain unknown; cumulative tokens must not be substituted for context occupancy.
Evidence
The source suggests the reporting boundary is the cause:
Suggested direction: emit a context-window delta when a valid top-level assistant request sample arrives, preserving model capacity, estimated status, and turn attribution. Do not count subagent context as the parent context. Add a regression test that observes context events before the final result.
Investigation thread (reporter's local bb instance): http://127.0.0.1:38886/threads/thr_68imcxrdav . All relevant observations are included above so access to that instance is unnecessary.
What was ruled out
turn/completed: the latter was explicitly queried and absent.Suggested priority and effort
Medium: context pressure is invisible during long Claude tool loops, especially a first run or one extended by steering. Waiting for a final result is a workaround; no data loss was established.