diff --git a/src/app/api/insights/chat/__tests__/route-followups.test.ts b/src/app/api/insights/chat/__tests__/route-followups.test.ts index ca522c9cd..72188cc93 100644 --- a/src/app/api/insights/chat/__tests__/route-followups.test.ts +++ b/src/app/api/insights/chat/__tests__/route-followups.test.ts @@ -314,7 +314,7 @@ describe("a model chip", () => { ]); }); - it("continues a forced reply with the question it left unfinished", async () => { + it("continues a forced reply, pointing at the question it left unfinished", async () => { conversationWithChips(); world.storedFollowUps = [{ ...chip("f1", "continue"), anchor: undefined }]; world.storedProvenance = { @@ -340,8 +340,11 @@ describe("a model chip", () => { await tap("f1"); const system = providerCalls[0].system; expect(system).toContain( - 'CONTINUE: the person asked you to keep looking. Unfinished answer for: "How was my blood pressure last month?"', + "CONTINUE: the person asked you to keep looking. The unfinished question is their message before that request, in CONVERSATION.", ); + // The question stays the person's own turn; it never reaches the + // system role. + expect(system).not.toContain("How was my blood pressure last month?"); expect(system).toContain( "Already fetched: get_metric_table(bp, last30days, week) → m1.r1", ); diff --git a/src/lib/ai/coach/eval/__tests__/scenarios.test.ts b/src/lib/ai/coach/eval/__tests__/scenarios.test.ts index 9e801da8a..4b605f2ec 100644 --- a/src/lib/ai/coach/eval/__tests__/scenarios.test.ts +++ b/src/lib/ai/coach/eval/__tests__/scenarios.test.ts @@ -465,11 +465,15 @@ describe.each(["de", "en"] as const)("in %s", (lang) => { ([args]) => args as { from: Date; to: Date }, ); expect(reads.length).toBeGreaterThan(0); - // The range ends about a year before now, not now. - for (const read of reads) { - const daysBack = (h.NOW.getTime() - read.to.getTime()) / 86_400_000; - expect(daysBack).toBeGreaterThan(360); - expect(daysBack).toBeLessThan(370); + // The table's range ends about a year before now. The only other read + // is the current window, which the summary compares it with. + const daysBack = reads.map( + (read) => (h.NOW.getTime() - read.to.getTime()) / 86_400_000, + ); + const yearAgo = daysBack.filter((d) => d > 360 && d < 370); + expect(yearAgo.length).toBeGreaterThan(0); + for (const d of daysBack) { + if (!(d > 360 && d < 370)) expect(d).toBeLessThan(1); } const broken = await run(scenario, {