Repository navigation
fix(tps): hold live rate across tools and steps - #1
Merged
Merged
Conversation
The live estimate kept decaying after the stream-end event while tools ran, and step settlement swapped it for the run-wide average. Capture the live value at the stream-end (or content) boundary, clamp the live clock there, and fall back to the held rate between steps. Final run average and token accounting are unchanged.
Hosts without session.step.streamed settle against the last content boundary, which can predate the newest live sample. Capturing the hold there counts those newer bytes but divides by a duration clamped to the 250 ms minimum — a half-second burst shows double or worse (probe: 1600 vs 250 t/s). Skip capture when the boundary predates the newest sample and leave any prior hold alone. Display-only: token and duration accounting are unchanged.
The running-display semantics were stated twice in tps.ts and again in the footer timer comment; settleActiveStep and value() restated their fallback chains. Keep the invariants the code cannot express and the test arithmetic that pins the magic numbers.
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.
The TPS label kept decaying while tools ran, and step settlement replaced it with the run-wide average — the rate slid downward during tool waits or jumped mid-run. It now freezes the live estimate at the stream-end boundary and holds it across tool execution and between steps; only new observable bytes resume the live calculation. The completed run still freezes to the weighted run average. Display-only: token and duration accounting are unchanged.
What changed
markStreamedcaptures the live rate at the host'ssession.step.streamedboundary. For hosts that never publish it,settleActiveStepfalls back to the last content boundary — and skips the capture when that guess predates the newest sample, since those newer bytes would be divided by a duration clamped to the 250 ms minimum and inflate the hold (probe: 1600 t/s held vs 250 t/s on screen moments earlier).Validation
bun test— 613 pass, including newTpsTrackerunit tests and a footer render test covering hold across tools, settlement, and the frozen run average.