Skip to content

fix(agents-server-ui): show uncached input tokens in the meta row#4567

Open
kevin-dp wants to merge 1 commit into
mainfrom
kevin/uncached-input-tokens
Open

fix(agents-server-ui): show uncached input tokens in the meta row#4567
kevin-dp wants to merge 1 commit into
mainfrom
kevin/uncached-input-tokens

Conversation

@kevin-dp

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #4502. The input side of the per-response token-usage label summed input + cacheRead + cacheWrite, but cacheRead re-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. cacheWrite is counted because cache-enabled providers report newly appended prompt tokens there (with input collapsing 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: drop usage.cacheRead from the input sum (legacy flat inputTokens fallback unchanged — no cache split means the whole side counts as uncached)
  • Comments updated across outbound-bridge.ts, entity-schema.ts, entity-timeline.ts and TokenUsage.tsx to document the uncached semantics of input_tokens
  • Test updated: input: 50, cacheRead: 1200, cacheWrite: 100 now persists 150, not 1350

Notes

  • Steps recorded before this change keep their stored cache-inclusive totals — both fields are optional and the display sums what's persisted, so no migration is needed.
  • feat(agents): add /goal slash command with token-budget enforcement #4552 touches the same pi-adapter.ts block (it splits total vs. uncached for budget enforcement) and will need a small rebase after this merges.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Desktop Builds

Build artifacts for commit e3fb647.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Passed Installer
Linux x64 Passed AppImage / deb

Workflow run

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.69%. Comparing base (73c6f89) to head (e3fb647).
✅ All tests successful. No failed tests found.

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              
Flag Coverage Δ
packages/agents 71.37% <ø> (ø)
packages/agents-mobile 75.49% <ø> (ø)
packages/agents-runtime 82.46% <100.00%> (-0.01%) ⬇️
packages/agents-server 75.02% <ø> (+0.16%) ⬆️
packages/agents-server-ui 6.25% <ø> (ø)
packages/electric-ax 46.42% <ø> (ø)
typescript 56.69% <100.00%> (+0.02%) ⬆️
unit-tests 56.69% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Electric Agents Mobile Build

Local mobile checks ran for commit e3fb647.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant