feat(admin): show turn spend beside cache health in the metrics viewer - #647
Open
yzxcj797 wants to merge 2 commits into
Open
feat(admin): show turn spend beside cache health in the metrics viewer#647yzxcj797 wants to merge 2 commits into
yzxcj797 wants to merge 2 commits into
Conversation
…/metrics
The budget now debits the LlmCallUsage the harnesses meter, but an
operator planning which models to run qm on still had to join spend out
of session_llm_requests by hand: turn_metrics carried the cache columns
and no cost, no output tokens.
Harness turn results gain costUsage {outputTokens, costUsd} alongside
cacheUsage -- pi sums its per-call stats, claude reports the SDK's
running cost total with the fallback branch flagging unknown cost, and
the mock harness reports its deterministic usage. The orchestrator
lands both on TurnMetricSample, turn_metrics grows output_tokens and
cost_usd (ALTER TABLE ADD COLUMN IF NOT EXISTS, so existing deployments
migrate in place), and /v1/admin/metrics returns a spend block:
samples, turnsWithKnownCost, costUsdTotal, outputTokensTotal.
Follow-up to yc-software#586
The metrics endpoint grew a spend block, but the viewer still showed only the cache line -- an operator opening the page still could not see what the scope spends. renderSpend adds one statline under cache health: model spend as currency, turns with known cost, and summed output tokens, using the same fmtTokens/fmtPct vocabulary as its neighbour.
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
Completes #645's surface: the metrics endpoint grew a
spendblock, but the admin viewer still showed only the cache line — an operator opening the page could not see what the scope spends.Implementation
renderSpendadds one statline directly under cache health on the metrics page: model spend as currency (fmtUsd), turns with known cost, and summed output tokens — samestatline/fmtTokensvocabulary as its neighbour, same empty-scope vanishing behaviour.Stacked on #645 (the
spenddata lands there) — merge order: #645 first.Testing
tsc --noEmitclean against the stacked base.Follow-up to #586
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.