DEV Community

Cover image for Day 91: Why I stopped using GenAI for budgeting math
Eric Rodríguez
Eric Rodríguez

Posted on

Day 91: Why I stopped using GenAI for budgeting math

When building AI-powered apps, you have to know when to turn the AI off.

Today, I was testing my Serverless Financial Agent. I asked it a simple question: "How much can I spend today without breaking my goal?"

The Amazon Bedrock LLM gave me a beautifully written, highly confident answer. The only problem? The math was completely hallucinated.

The Problem: LLMs predict the next best word; they don't do arithmetic. If you let GenAI calculate daily limits based on raw transaction data, it will eventually confidently authorize spending that bankrupts your user.

The Fix: I added a deterministic interceptor in my AWS Lambda backend.

Instead of passing the prompt directly to the AI, my Python router now uses regex to catch specific intents. If the user asks about their daily limit, Python takes over:

Deterministic Math > AI Hallucinations

safe_daily_limit = (recorded_monthly_income / days_in_month) - daily_savings_goal

If the system detects 0 recorded income for the month, it hard-stops and refuses to calculate a limit. The AI is only used to format the final delivery in its designated "tough love" persona, but the underlying numbers are strictly governed by standard code.

I also decoupled my public landing page from my authenticated React SPA.
If you want to use Google OAuth in your app, GCP requires publicly accessible /privacy and /terms pages. By splitting the routing, unauthenticated users hit a lightning-fast static landing page cached by AWS CloudFront, while authenticated users get routed directly to the heavy dashboard.

Route language to the LLM. Route math to Python. Code for intelligence, but architect for accuracy!

Top comments (0)