From 48b481999dd91557d5ddef0a2b9df583e86ba44e Mon Sep 17 00:00:00 2001 From: Vijayakanth Manoharan Date: Mon, 23 Mar 2026 22:11:45 -0400 Subject: [PATCH] Fix AI insight prompt passing raw cents instead of dollar amounts recentExpenses and chart were JSON-stringified with raw amountCents/ expensesCents/paychecksCents values, causing the model to read e.g. 10000 as $10,000 instead of $100. Both arrays are now mapped through centsToDisplay() before inclusion in the prompt, matching the pattern already used for totals and category breakdown. Co-Authored-By: Claude Sonnet 4.6 --- src/lib/insights.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/insights.ts b/src/lib/insights.ts index ffb1af2..1a1ac6c 100644 --- a/src/lib/insights.ts +++ b/src/lib/insights.ts @@ -112,8 +112,8 @@ function buildInsightPrompt(snapshot: Awaited ({ title: e.title, amount: centsToDisplay(e.amountCents), date: e.date, category: getCategoryLabel(e.category as CategoryValue) })))}`, + `Daily chart points: ${JSON.stringify(snapshot.chart.map((p) => ({ date: p.date, expenses: centsToDisplay(p.expensesCents), paychecks: centsToDisplay(p.paychecksCents) })))}`, "Do not mention missing data unless it materially affects the advice.", ] .filter(Boolean)