From 7ffb6b28f5b6bdbfc53ebed94fc68af557612189 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 11 Jun 2026 14:11:13 +0900 Subject: fix(cache-warming): accurate cache rate + expectedCacheRate (retention) metric The Claude cache % read 100% whenever anything was cached, because the metric's denominator (inputTokens) excluded cached tokens on Anthropic. Fixed upstream in ../claude/provider-anthropic (inputTokens = total prompt); this commit adds the companion retention metric and exposes it: - transport-contract: WarmResponse += expectedCacheRate - transport-http: POST /chat/warm returns expectedCacheRate = cacheRead/(cacheRead+cacheWrite) - cache-warming: computeExpectedCacheRate + a per-conversation 'cache retention' surface stat - handoff: documents the fix + cache-rate vs expected-cache (cross-turn) for the FE Live-verified vs claude haiku: real turn cache rate 61% (was inflated 100%); warm within TTL expectedCacheRate=100%, after expiry=0%. --- packages/cache-warming/src/extension.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'packages/cache-warming/src/extension.ts') diff --git a/packages/cache-warming/src/extension.ts b/packages/cache-warming/src/extension.ts index 26d429b..802618a 100644 --- a/packages/cache-warming/src/extension.ts +++ b/packages/cache-warming/src/extension.ts @@ -77,7 +77,12 @@ export function activate(host: HostAPI): void { return buildDefaultSpec(); } const state = warmer.getState(convId); - return buildConversationSpec(state.enabled, state.intervalMs, state.lastPct); + return buildConversationSpec( + state.enabled, + state.intervalMs, + state.lastPct, + state.lastExpectedPct, + ); } async function invoke( -- cgit v1.2.3