Repository navigation
fix(agent): contextualize cached prefill metrics - #98
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_c1154316-89ff-4fd9-ac07-b8ef02741d48) |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Root cause
The agent footer retained only the native prefill and decode rates. On a warm Qwen session, prefill throughput is measured over the fresh suffix while TTFT also includes cache restoration and long-context first-token work. A small suffix such as 42 new tokens over a 114.6K-token cached prefix could therefore display
74.8 tok/swith no indication that it was not a bulk-prefill benchmark.The completed Pi message already contains the fresh input and cache-read counts, so this change adds that existing context without changing native metrics or public schemas.
Example:
Validation
yarn vp test packages/agent/__test__/performance-status.test.ts packages/agent/__test__/stream-adapter.test.ts packages/agent/__test__/events.test.ts(69 passed)yarn exec tsc -b packages/agent/tsconfig.json --pretty falseyarn vp lint packages/agent/src/provider/performance-status.ts packages/agent/__test__/performance-status.test.ts packages/agent/__test__/stream-adapter.test.tsyarn vp fmt --check packages/agent/src/provider/performance-status.ts packages/agent/__test__/performance-status.test.ts packages/agent/__test__/stream-adapter.test.tsNote
Low Risk
Display-only TUI status formatting with defensive validation; no auth, persistence, or inference behavior changes beyond what is shown in the footer.
Overview
The agent TUI mlx performance footer now adds TTFT and per-turn input context (fresh vs cached tokens) next to the existing prefill/decode throughput, so warm-cache turns do not look like bulk-prefill benchmarks when only a small suffix was prefilled.
PerformanceStatus.recordpulls optional TTFT from native metrics and input/cacheRead from the completed assistant message’s usage; formatting distinguishes “N new + M cached” whencacheRead > 0, otherwise a single input count. If TTFT or usage counts are invalid, the footer falls back to the previous rate-only line.Tests cover tiny vs bulk cached suffixes, malformed metadata fallback, and assert the stream adapter still attaches usage (
input/cacheRead) on the Pi assistant message used for recording.Reviewed by Cursor Bugbot for commit c851da8. Bugbot is set up for automated code reviews on this repo. Configure here.