Skip to content

Live speed: /live reports the current generation speed - #346

Merged
fylorn merged 1 commit into
mainfrom
feat/live-speed
Oct 17, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/live-speed

Conversation

@fylorn

@fylorn fylorn commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

/live now reports how fast running requests are generating right now, instead of the average of requests that finished in the last minute. During a long request the menu bar had nothing to show before.

  • The gateway keeps reading a successful stream after its first token and estimates the output as it arrives (text, reasoning text, tool arguments; same rule as the input estimate), times a per-upstream, per-model ratio (tw_gateway::pace).
  • Every streaming request that finishes with reported usage calibrates the ratio (moving average, bounded 0.5..2; skipped when reasoning was hidden). Gemini's in-stream cumulative usage is used when higher.
  • Each running request has a meter on the event bus (tw_observe::Meter, 250 ms slots, 3 s window).
  • LiveView.tokens_per_sec = total of running requests (null when none runs, 0 when none is generating yet). RunningView gains tokens_per_sec and output_tokens (null before the first token / non-streaming).
  • The per-request speed recorded at the end (RequestFinished.tokens_per_sec) is unchanged.
  • Control protocol 48 -> 49. tw_engine::TextTokens is now public.

Tests: meter unit tests, pace unit tests, bus /live tests, tw-control /live test updated, and a new gateway integration test (tests/live_speed.rs) that reads /live halfway through a real stream and checks calibration after it ends.

🤖 Generated with Claude Code

/live used to give the speed of requests that finished in the last
minute, so during a long request the menu bar had nothing to show.

The gateway now keeps reading a successful stream after its first token
and estimates the output as it arrives (text, reasoning text and tool
arguments, with the same rule as the input estimate), multiplied by a
per-upstream, per-model ratio. Each streaming request that finishes with
reported usage calibrates that ratio (moving average, bounded 0.5..2,
skipped when reasoning was hidden). Gemini's cumulative usage in the
stream is used when it is higher.

Each running request has a meter on the event bus (250 ms slots, 3 s
window). /live gives every running request's tokens_per_sec and
output_tokens (null before the first token and for non-streaming), and
the total of all running requests: null when nothing runs, 0 when
requests run but none is generating. The per-request speed recorded at
the end is unchanged. Control protocol 49.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 9861aab into main Oct 17, 2026
6 checks passed
@fylorn
fylorn deleted the feat/live-speed branch October 17, 2026 06:32
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant