feat(coding-agent): add tokens/sec to the working loader - #1179
Conversation
Track output token rate in AgentActivityTracker by recording when the first output token arrives and computing tokens/second from the delta. The working loader message now shows the rate alongside the token count, e.g. 'Thinking · 5s · ↓ 1.2k tokens (240 tok/s)'. The rate only appears after 500ms of streaming to avoid jitter on short responses.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dfb501a. Configure here.
| if (this.streamingStartedAt === undefined && this.currentTokens() > 0) { | ||
| this.streamingStartedAt = Date.now(); | ||
| this.streamingStartTokens = this.completedTokens; | ||
| } |
There was a problem hiding this comment.
Stale tokens/sec across stream gaps
Medium Severity
streamingStartedAt is set on the first output tokens but never cleared on message_end, so computeTokensPerSecond keeps dividing by wall time through tool runs and waits. The loader then shows a decaying tok/s while idle or executing, and later streams inherit that inflated elapsed time instead of measuring active output throughput.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit dfb501a. Configure here.
There was a problem hiding this comment.
We probably should only consider TokensPerSecond when generations are actually happening. It might be slightly misleading otw


Summary
Adds tokens/sec to the working loader message so the user can see output throughput while the model is streaming.
Changes
agent-activity.ts: AddedtokensPerSecondtoAgentActivityStatus, tracked viastreamingStartedAtandstreamingStartTokensfields. The rate is computed asdelta_tokens / elapsed_secondsand only reported after 500ms of streaming to avoid jitter.interactive-mode.ts: UpdatedgetWorkingLoaderMessage()to append(N tok/s)after the token count when a rate is available.agent-activity.test.ts: UpdatedtoEqualassertions for the newtokensPerSecondfield.Example
Testing
npx vitest run test/agent-activity.test.ts— 13/13 passnpx vitest run test/interactive-mode-status.test.ts— 151/151 passnpm run check— cleanNote
Low Risk
UI-only activity tracking and loader text; no auth, persistence, or protocol changes.
Overview
The interactive working loader now shows output throughput while the model streams, e.g.
Thinking · 5s · ↓ 1.2k tokens (240 tok/s).AgentActivityTrackergainstokensPerSecondonAgentActivityStatus, measured from the first output of the current turn using the same monotonic token count as the existing loader. The rate stays 0 until at least 500ms of streaming so early numbers do not flicker.getWorkingLoaderMessage()appends(N tok/s)only when a positive rate is available; tests and the changelog are updated accordingly.Reviewed by Cursor Bugbot for commit dfb501a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add tokens/sec display to the coding agent working loader
tokensPerSecondfield toAgentActivityStatus, computed from streaming start time and token count delta inagent-activity.ts.interactive-mode.tsappends the rate in parentheses, e.g.↓ 1.2k tokens (45 tok/s), when the rate is positive.Macroscope summarized dfb501a.