Skip to content

feat(desktop): cache-aware, model-correct Spend in the inspector#162

Merged
oratis merged 1 commit into
mainfrom
feat/desktop-cost-cache-aware
Jun 4, 2026
Merged

feat(desktop): cache-aware, model-correct Spend in the inspector#162
oratis merged 1 commit into
mainfrom
feat/desktop-cost-cache-aware

Conversation

@oratis
Copy link
Copy Markdown
Owner

@oratis oratis commented Jun 4, 2026

Completes the prompt-cache work (#160) in the GUI and fixes a real cost bug.

The desktop inspector's Spend hardcoded ¥1/M input + ¥2/M output and ignored reasoning tokens — so it ignored prompt-cache savings and mispriced deepseek-reasoner (output is ¥16/M, reasoning ¥4/M). Now it uses the shared estimateCost util.

  • AgentEvent 'usage' carries cacheReadTokens (emitted from the per-turn + post-compaction sites); the desktop's local AgentEvt mirrors it.
  • Repl.tsx computes per-turn cost via estimateCost, reading the live model through a ref — the agent.onEvent subscription is created once on mount, so a plain closure would bill at a stale model's rate.
  • Export ./dist/providers/pricing.js from @deepcode/core (leaf module, no node:fs) so the renderer can import estimateCost without dragging in the index.

typecheck clean across all workspaces; core 639 · desktop 54; repo-wide format:check clean.

🤖 Generated with Claude Code

The desktop inspector's "Spend" hardcoded ¥1/M input + ¥2/M output and ignored
reasoning tokens — so it ignored prompt-cache savings AND mispriced the reasoner
(output ¥16/M, reasoning ¥4/M). Switch it to the shared estimateCost util (#160),
which credits cache-hit input tokens and applies per-model rates.

- AgentEvent 'usage' now carries cacheReadTokens (emitted from both the per-turn
  and post-compaction sites); the desktop's local AgentEvt mirrors it.
- Repl.tsx computes per-turn cost via estimateCost, reading the live model via a
  ref (the onEvent subscription is created once on mount, so it would otherwise
  bill at a stale model's rate).
- Export ./dist/providers/pricing.js from @deepcode/core (leaf module, no
  node:fs) so the renderer can import estimateCost without pulling in the index.

typecheck clean across all workspaces; core 639 · desktop 54.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@oratis oratis merged commit c46cced into main Jun 4, 2026
3 checks passed
@oratis oratis deleted the feat/desktop-cost-cache-aware branch June 4, 2026 15:51
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