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
During a Pi run with multiple assistant/tool subturns, bb does not refresh the context-window meter until the entire agent run finishes. The meter should update after each Pi turn_end, when the assistant response and its tool results have entered the context used by the next request.
Versions and environment
bb 0.39.0 (packaged app), also confirmed in source at 05cc16d140e40c2e901de1046b07738fff89eb9f
macOS 26.5.1 (25F80)
Pi provider using bundled @earendil-works/pi-coding-agent 0.84.0
Worktree environment; browser connected remotely through bb Connect
Steps to reproduce
Start a Pi thread.
Send a prompt that requires more than one model/tool cycle, for example: Read package.json, run git status, then summarize what you found.
While Pi performs the tool calls and subsequent assistant responses, watch the context-window meter.
After the run finishes, inspect the thread's persisted event ordering:
sqlite3 ~/.bb/bb.db "SELECT sequence, type, item_kind, json_extract(data, '$.contextWindowUsage.usedTokens') FROM events WHERE thread_id = '<thread-id>' ORDER BY sequence;"
The context-window update arrives only after turn/completed, so the meter remains stale throughout the tool loop. Expected: one thread/contextWindowUsage/updated snapshot after every Pi SDK turn_end, including intermediate assistant responses followed by tool results.
Evidence
Base commit: 05cc16d140e40c2e901de1046b07738fff89eb9f
Persisted context snapshots on thr_25drjv95tn show that Pi's values do move across completed runs: 4909, 5084, 5202, 5329, 5467. The broken part is the reporting cadence within a multi-tool run, not getContextUsage() itself.
Summary
During a Pi run with multiple assistant/tool subturns, bb does not refresh the context-window meter until the entire agent run finishes. The meter should update after each Pi
turn_end, when the assistant response and its tool results have entered the context used by the next request.Versions and environment
05cc16d140e40c2e901de1046b07738fff89eb9f@earendil-works/pi-coding-agent0.84.0Steps to reproduce
Start a Pi thread.
Send a prompt that requires more than one model/tool cycle, for example:
Read package.json, run git status, then summarize what you found.While Pi performs the tool calls and subsequent assistant responses, watch the context-window meter.
After the run finishes, inspect the thread's persisted event ordering:
Expected vs actual
Actual, trimmed from
thr_25drjv95tn:The context-window update arrives only after
turn/completed, so the meter remains stale throughout the tool loop. Expected: onethread/contextWindowUsage/updatedsnapshot after every Pi SDKturn_end, including intermediate assistant responses followed by tool results.Evidence
05cc16d140e40c2e901de1046b07738fff89eb9fcreateOnPiEventreports context only foragent_endandcompaction_end.thr_25drjv95tnshow that Pi's values do move across completed runs:4909,5084,5202,5329,5467. The broken part is the reporting cadence within a multi-tool run, notgetContextUsage()itself.What you ruled out
Suggested priority and effort (optional)
Medium — affects Pi users during every multi-tool run; no data loss, but the live context indicator is misleading. Effort is low.
Checks
main, or I say above that I could not.> AGENT GENERATED: by <model>and links the thread or report.