fix(agents-server-ui): show uncached input tokens in the meta row#4567
Open
kevin-dp wants to merge 1 commit into
Open
fix(agents-server-ui): show uncached input tokens in the meta row#4567kevin-dp wants to merge 1 commit into
kevin-dp wants to merge 1 commit into
Conversation
The input side of the token-usage label summed input + cacheRead + cacheWrite, so on warm-cache turns it re-counted the entire conversation on every step and read as a runaway cumulative number. Surface the uncached side instead (fresh input + cache writes, cache reads excluded) so the label reflects the new work each response did. Steps recorded before this change keep their stored totals — the fields are optional and the display sums what's persisted, so no migration is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4567 +/- ##
==========================================
+ Coverage 56.67% 56.69% +0.02%
==========================================
Files 327 327
Lines 37935 37931 -4
Branches 10938 10935 -3
==========================================
+ Hits 21498 21506 +8
+ Misses 16401 16389 -12
Partials 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Electric Agents Mobile BuildLocal mobile checks ran for commit The EAS Android preview build was skipped because the |
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.
Summary
Follow-up to #4502. The input side of the per-response token-usage label summed
input + cacheRead + cacheWrite, butcacheReadre-counts the entire conversation history on every warm-cache step — so the label ballooned into a cumulative number that said nothing about the work the response actually did.The adapter now surfaces only the uncached input side: fresh prompt tokens plus cache writes, with prompt-cache reads excluded.
cacheWriteis counted because cache-enabled providers report newly appended prompt tokens there (withinputcollapsing to ~0); excluding it would surface tiny "3 ↑" labels instead. This matches the accounting the #4552 goal-budget progress bar uses, so the two displays stay consistent.Changes
pi-adapter.ts: dropusage.cacheReadfrom the input sum (legacy flatinputTokensfallback unchanged — no cache split means the whole side counts as uncached)outbound-bridge.ts,entity-schema.ts,entity-timeline.tsandTokenUsage.tsxto document the uncached semantics ofinput_tokensinput: 50, cacheRead: 1200, cacheWrite: 100now persists150, not1350Notes
pi-adapter.tsblock (it splits total vs. uncached for budget enforcement) and will need a small rebase after this merges.🤖 Generated with Claude Code