feat(desktop): cache-aware, model-correct Spend in the inspector#162
Merged
Conversation
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]>
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.
Completes the prompt-cache work (#160) in the GUI and fixes a real cost bug.
The desktop inspector's Spend hardcoded
¥1/Minput +¥2/Moutput and ignored reasoning tokens — so it ignored prompt-cache savings and mispriceddeepseek-reasoner(output is ¥16/M, reasoning ¥4/M). Now it uses the sharedestimateCostutil.AgentEvent 'usage'carriescacheReadTokens(emitted from the per-turn + post-compaction sites); the desktop's localAgentEvtmirrors it.estimateCost, reading the live model through a ref — theagent.onEventsubscription is created once on mount, so a plain closure would bill at a stale model's rate../dist/providers/pricing.jsfrom@deepcode/core(leaf module, nonode:fs) so the renderer can importestimateCostwithout dragging in the index.typecheck clean across all workspaces; core 639 · desktop 54; repo-wide
format:checkclean.🤖 Generated with Claude Code