diff options
Diffstat (limited to 'packages/frontend')
| -rw-r--r-- | packages/frontend/src/lib/cache-warming.svelte.ts | 7 | ||||
| -rw-r--r-- | packages/frontend/src/lib/tabs.svelte.ts | 7 | ||||
| -rw-r--r-- | packages/frontend/tests/cache-warming.test.ts | 17 |
3 files changed, 28 insertions, 3 deletions
diff --git a/packages/frontend/src/lib/cache-warming.svelte.ts b/packages/frontend/src/lib/cache-warming.svelte.ts index cda3fd1..0253c08 100644 --- a/packages/frontend/src/lib/cache-warming.svelte.ts +++ b/packages/frontend/src/lib/cache-warming.svelte.ts @@ -41,6 +41,12 @@ export interface WarmRequestParams { keyId: string | null; modelId: string | null; agentModels: AgentModelEntry[] | null; + /** + * The SAME reasoning effort the next real turn would use. It drives the + * Anthropic thinking providerOptions, which is a message-cache key — warming + * must match it so it refreshes the bucket the real message reads. + */ + reasoningEffort: string | null; } /** Reactive, per-tab warming UI state (read by the Chat Settings debug strip). */ @@ -177,6 +183,7 @@ export function createCacheWarmingStore() { ...(params?.keyId ? { keyId: params.keyId } : {}), ...(params?.modelId ? { modelId: params.modelId } : {}), ...(params?.agentModels ? { agentModels: params.agentModels } : {}), + ...(params?.reasoningEffort ? { reasoningEffort: params.reasoningEffort } : {}), }), }); // A newer cancel/fire superseded this request — drop its result so it diff --git a/packages/frontend/src/lib/tabs.svelte.ts b/packages/frontend/src/lib/tabs.svelte.ts index a0125ef..ca04e62 100644 --- a/packages/frontend/src/lib/tabs.svelte.ts +++ b/packages/frontend/src/lib/tabs.svelte.ts @@ -251,7 +251,12 @@ export function createTabStore() { cacheWarming.setRequestResolver((tabId) => { const t = getTabById(tabId); if (!t) return null; - return { keyId: t.keyId, modelId: t.modelId, agentModels: t.agentModels }; + return { + keyId: t.keyId, + modelId: t.modelId, + agentModels: t.agentModels, + reasoningEffort: t.reasoningEffort, + }; }); $effect.root(() => { diff --git a/packages/frontend/tests/cache-warming.test.ts b/packages/frontend/tests/cache-warming.test.ts index 012efb1..583d563 100644 --- a/packages/frontend/tests/cache-warming.test.ts +++ b/packages/frontend/tests/cache-warming.test.ts @@ -98,7 +98,12 @@ describe("firing cadence", () => { const fetchMock = makeFetchOk({ inputTokens: 1000, cacheReadTokens: 900 }); vi.stubGlobal("fetch", fetchMock); - store.setRequestResolver(() => ({ keyId: "k", modelId: "m", agentModels: null })); + store.setRequestResolver(() => ({ + keyId: "k", + modelId: "m", + agentModels: null, + reasoningEffort: "high", + })); store.setEnabled("tab-1", true); await vi.advanceTimersByTimeAsync(WARM_INTERVAL_MS); @@ -108,7 +113,15 @@ describe("firing cadence", () => { const [url, opts] = (fetchMock as unknown as { mock: { calls: unknown[][] } }).mock .calls[0] as [string, { body: string }]; expect(url).toContain("/chat/warm"); - expect(JSON.parse(opts.body)).toMatchObject({ tabId: "tab-1", keyId: "k", modelId: "m" }); + // The request forwards the SAME effort the real turn uses — it's an + // Anthropic message-cache key, so warming must match it to refresh the + // bucket the next real message reads. + expect(JSON.parse(opts.body)).toMatchObject({ + tabId: "tab-1", + keyId: "k", + modelId: "m", + reasoningEffort: "high", + }); const s = store.stateFor("tab-1"); expect(s.lastPct).toBe(90); // 900 / 1000 |
