Repository navigation
Closed
Labels
app/corePackage: core (pkgs/ or apps/ in this repo)Package: core (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workMedium: expected under 1 day of workkind/featureNew feature or capability requestNew feature or capability requestpriority/lowNice to have; do when convenientNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Description
feat(routing): show cache savings in route_usage — the #9 part-3 remainder
Tracking issue for the unlanded remainder of #9 (prompt cache optimization via
compatibility.cacheFormat). Parts 1–2 of #9 have landed; this issue tracks
part 3 only, so the queue fix task can be minted under a fresh dedupe key
(the #9 fix dedupe key was consumed by completed task 2255 / PR #749).
Verified on main 01cf577 (2026-10-30, issue-sweep-rotating)
Landed (do NOT redo):
cache_formaton route targets and pools:
packages/schema/src/config/model-routes.ts:53,245- Resolver injects a target's cacheFormat as
compatibility.cacheFormat
for that resolution only:packages/core/src/model-resolver.ts:433-444,
called per-target at:624and:706.
Not landed:
- No savings figure exists anywhere: grep for
cost_saved|costSaved|savedUsd|savingsoverpackages/returns 0 hits. packages/core/src/tool/plugin/route-usage.tsoutput lines print
requests / failures / metered tokens /costUsdonly — no cache tokens,
hit ratio, or savings — even thoughModelUsagetotals already aggregate
cacheRead/cacheWrite(packages/core/src/model-usage.ts:18-19,42-44).SessionUsage.calculateCostalready prices cache reads at the cheaper
cost.cache.readrate (packages/core/src/session/usage.ts:22,32), so
reportedcostUsdis net; the missing piece is the counterfactual
savings:cacheRead tokens × (input price − cache-read price).
Scope
Implement part 3 only:
- Compute per-model cache savings in ModelUsage from the same catalog
pricing used for attempt costs; aggregate it alongsidecostUsd. - Display total USD saved plus cache hit ratio in the
route_usagetool
output (per target/pool/day lines where the data supports it). - First step: verify per-attempt pricing is recoverable for stored
route_attemptrows (model identity + pricing snapshot). If it is not
recoverable for historical rows, compute savings for new rows only and
park with findings rather than guessing prices.
Acceptance criteria
-
route_usageoutput shows cache-read tokens, a cache hit ratio, and
total USD saved via cache hits for the reported totals
(target/pool/day granularity where rows support it). - Savings = cacheRead tokens × (input price − cache-read price) using
the same catalog pricing asSessionUsage.calculateCost; a unit
test pins the arithmetic including a zero-cache case. - No change to
cache_formatschema, resolver injection, or net
costUsdaccounting. - If per-attempt pricing is not recoverable for stored rows, the task
parks with that finding instead of estimating.
Origin: #9 triage verdict by issue-sweep-rotating 2026-10-30
(comment on #9); outbox OB-2026-10-30-001 prepared the routing for this
tracking issue.
Metadata
Metadata
Assignees
Labels
app/corePackage: core (pkgs/ or apps/ in this repo)Package: core (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workMedium: expected under 1 day of workkind/featureNew feature or capability requestNew feature or capability requestpriority/lowNice to have; do when convenientNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
dezren39 commentedon Oct 30, 2026
🤖 Agent note · picked up
2 remaining items
dezren39 commentedon Oct 30, 2026
🤖 Agent note · parked
test/snapshot.test.ts: Snapshot > captures concurrently from independent processes(6384 pass / 1 fail; snapshot.test.ts is not in PR feat(core): report cache savings and hit ratio in route_usage (#952) #956 diff) — to be re-checked on resume, not treated as a PR regression on this evidence.dezren39 commentedon Oct 30, 2026
agent-note:v1 — parked (queue task 3836, worker
repo-worker-opencode, lanerepo-queue-worker-shift-opencodelane A)fc2d137c1a; rechecked 2026-10-30T07:32Z.Snapshot > captures concurrently from independent processes— verified in the job log; that test/file is not in PR feat(core): report cache savings and hit ratio in route_usage (#952) #956's diff, so it is an unrelated flake, not a PR regression.fc2d137,has_any_findings=false.dezren39 commentedon Oct 30, 2026
🤖 Agent note · picked up (resume — merge)
repo-worker-opencode), OpenChamber scheduled laneroute_usageMERGEABLE, headfc2d137c1aunchanged. Linux checks all green (typecheck/affected/standards/compliance/unit-linux, 08:16–08:31Z). Windows unit failure is the unrelatedSnapshot > captures concurrently from independent processesflake —snapshot.test.tsis not in the PR diff. No rulesets or required status checks onmain. PR diff reviewed:SessionUsage.calculateCostarithmetic unchanged (sharedselectCosthelper only), savings recorded per attempt viacache_savings_usd, nocache_format/resolver edits.bun test test/model-usage.test.ts test/model-route-log.test.tsin worktree~/git/fleet/3836-952— 42 pass / 0 fail.Merge pull request #956 from developing-today/queue/3836-952-route-ca…
dezren39 commentedon Oct 30, 2026
🤖 Agent note · done (merged)
repo-worker-opencode), OpenChamber scheduled laneroute_usage4548c43aee1ff2e7baf79dcec8883b4c51084ace(2026-10-30T08:41:38Z); issue feat(routing): show cache savings in route_usage — the #9 part-3 remainder #952 closed as completed. Targetedbun test(model-usage/model-route-log) 42 pass / 0 fail; linux CI green; windows unit failure was the unrelatedSnapshot > captures concurrently from independent processesflake.4548c43a