<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rishabh Saxena on Medium]]></title>
        <description><![CDATA[Stories by Rishabh Saxena on Medium]]></description>
        <link>https://medium.com/@rishabh.saxena2112?source=rss-80e1f43b4667------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W5k8uxSnhbByKAA2jkUMHg.jpeg</url>
            <title>Stories by Rishabh Saxena on Medium</title>
            <link>https://medium.com/@rishabh.saxena2112?source=rss-80e1f43b4667------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:01:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rishabh.saxena2112/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Bank Emails to a Finance agent that remembers — What I Learned Building it.]]></title>
            <link>https://medium.com/@rishabh.saxena2112/from-bank-emails-to-a-finance-agent-that-remembers-what-i-learned-building-it-fb800464d49d?source=rss-80e1f43b4667------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb800464d49d</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[context-engineering]]></category>
            <category><![CDATA[langmem]]></category>
            <dc:creator><![CDATA[Rishabh Saxena]]></dc:creator>
            <pubDate>Sun, 26 Apr 2026 14:02:42 GMT</pubDate>
            <atom:updated>2026-04-26T14:02:42.679Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IugiD-1tCbvKemIVMXhJqw.jpeg" /></figure><p>For a long time I had a problem that I suspect a lot of people share: having no real visibility into where their money is going.</p><p>Not because I wasn’t earning. Not because I wasn’t saving. Just because tracking felt like too much effort. I’d check my bank balance at the end of the month, feel vaguely anxious, and move on. There was no way to plan a budget when I didn’t know my baseline. There was no way to cut expenses when I didn’t know what I was actually spending on. Conscious spending, which is knowing what you’re buying and why, was completely missing from my life.</p><p>I looked for apps that could help. Most required manual entry. A few connected to banks but felt bloated. None of them gave me the kind of insight I actually wanted, the ability to ask a question and get a real answer from my own data.</p><p>So I built one.</p><p>The idea was simple: an app that automatically pulls in transactions from bank emails, Google Pay exports, and credit card statements, also giving leverage of adding manually. The data would just be there, clean and structured, ready to query. Plain and functional on its own. But I knew from the start that adding AI on top would be what made it genuinely useful — the difference between a spreadsheet and an assistant.</p><p>Getting the AI layer right took three distinct phases. Each one taught me something about how LLMs actually work, and where they break. This post walks through all three.</p><h3>The Starting Point: Getting the Data In</h3><p>Before any AI, the foundation is the data. Every transaction I make flows in from somewhere — Google Pay takeout files, HDFC credit card email alerts, ICICI notifications or some bank messages. The app parses all of these, categorizes the transactions, and stores everything in a database.</p><p>This alone was useful. I could finally see a clean history of every rupee spent, tagged by merchant and category. But insight still required manual effort. Stare at the list, try to spot patterns, export and calculate. The data was there. Making sense of it wasn’t.</p><p>The obvious next step: put an AI on top. Ask questions in plain English, get answers from real data.</p><p>Easier said than done.</p><h3>Phase 1: Just Stuff the Data In</h3><p>The first version was the simplest possible approach. Before every question, the backend fetched the last 30 days of transactions, summarized them, and injected that summary into Claude’s system prompt. Claude answered from what it was given.</p><p>For current-month questions, this worked well:</p><ul><li>“How much did I spend on food this month?” — accurate</li><li>“What’s my biggest expense category?” — accurate</li><li>“How many Swiggy transactions did I make?” — accurate</li></ul><figure><img alt="Example of my query with the AI response" src="https://cdn-images-1.medium.com/max/336/1*AT9WcyLG8XL-Zo2nsZbJqA.png" /><figcaption>My query with AI response using 30 day context window</figcaption></figure><p>For anything outside that 30-day window, it fell apart completely:</p><ul><li>“Am I spending more on food than last year?” — no historical data</li><li>“Which month do I typically overspend?” — needs multi-month view</li><li>“Is ₹40k on travel unusual for me?” — no baseline to compare against</li></ul><p>The root problem: I have years of data, but the AI only ever saw 30 days of it.</p><p>The obvious fix seems like, just send more. Send 6 months, send a year. But this hits a hard wall fast.</p><p>LLMs have a context window, a limit on how much text they can process in one call. A year of daily transactions can be 5,000 to 10,000 rows. That’s expensive, slow, and it actually makes the AI worse. There’s a well-documented phenomenon called <strong>lost in the middle, </strong>LLMs reason well over the beginning and end of a long context, but facts buried in the middle get missed. Dumping a year of raw data into a prompt and hoping the model finds the signal is not a strategy.</p><p>Phase 1 had a hard ceiling. Good enough but not useful as a real tool.</p><h3>Phase 2: Stop Pre-loading, Start Fetching</h3><p>The fix required a different mental model entirely.</p><p>Phase 1 treated the LLM like a student who needed to read the entire textbook before answering. The better analogy is a researcher who knows how to use a library so you don’t memorize everything upfront, you look up exactly what you need when you need it.</p><p>This is the core insight behind <strong>tool calling</strong>:</p><blockquote><em>LLMs are great at reasoning. Databases are great at storing data. Don’t make the LLM do the database’s job.</em></blockquote><p>Instead of pre-loading data, you give Claude a set of functions it can call during a conversation. Claude decides mid-reasoning which ones to invoke, with what parameters, and uses the results to form its answer.</p><p>For my expense tracker, that meant four tools:</p><ul><li>get_category_spend — total spend in a category over any date range</li><li>get_monthly_summary — full breakdown for a period</li><li>get_top_merchants — vendors ranked by spend</li><li>get_transactions — raw rows for detailed analysis</li></ul><p>These are thin wrappers around database queries I already had.The LLM doesn’t know SQL or Firestore, it just knows the tool names and what they return.</p><h3>The ReAct Loop : How It Actually Works</h3><p>Under the hood, a tool-calling conversation isn’t a single API call. It’s a loop.</p><p>Claude responds with either a final answer (stop_reason: end_turn) or a request to call tools (stop_reason: tool_use). When it&#39;s the latter, your code executes the tools and sends the results back. Claude reasons over them and either answers or calls more tools. This repeats until it has what it needs.</p><p>The pattern has a name: <strong>ReAct</strong> — Reason, Act, Observe, Reason again. Here’s what it looks like stripped down:</p><pre>User: &quot;Am I spending more on food vs last year?&quot;</pre><pre>Round 1:<br>Claude → calls get_category_spend(&quot;Food&quot;, &quot;Apr 2026&quot;)<br>       → calls get_category_spend(&quot;Food&quot;, &quot;Apr 2025&quot;)</pre><pre>Your code runs both queries, returns results.</pre><pre>Round 2:<br>Claude → &quot;You spent ₹9,200 on food this April vs ₹6,800 last April —<br>          35% higher. The increase is mostly dining out, not groceries.&quot;</pre><p>Claude made two targeted fetches. It got exactly what it needed from years of data. My backend touched four rows.</p><p>The loop runs server-side. From the frontend it’s still a single request. The user sees nothing different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*FAuK_EDgq1ufO-ZxQL0gjg.png" /><figcaption>Query now answers in more detail using tooling.</figcaption></figure><h3>What This Unlocked</h3><p>Questions that were impossible in Phase 1 became straightforward:</p><ul><li>“Compare my food spend this April vs last April” — two tool calls, Claude does the math</li><li>“Which month did I overspend most last year?” — twelve calls in one shot, Claude ranks them</li><li>“Is ₹40k on travel unusual for me?” — fetch 12 months of travel, compute average, compare</li><li>“What are my top 5 merchants this quarter?” — one call, instant answer</li></ul><p>Claude can also chain reasoning across tools. Ask “where can I cut expenses?” and it calls get_monthly_summary to see the full picture, then get_top_merchants to find the biggest offenders, then reasons over both before answering. That&#39;s exactly what the screenshot in Phase 1 was — not a guess, but real data fetched and reasoned over in real time.</p><p>One practical note: the loop needs a cap. Claude can theoretically keep calling tools indefinitely on complex questions. I cap it at 10 iterations, enough for any reasonable question, and a safeguard against runaway API costs.</p><p>Phase 2 felt like the real unlock. The assistant could now answer almost anything if the data existed. But there was still one significant gap.</p><p>Every conversation started from zero. If I corrected it, “that ₹9,904 in March was a return, ignore it” the next day it remembered nothing. If I said “I want to cut Amazon spend,” a week later it had forgotten I’d ever mentioned it.</p><p>The AI knew everything about my transactions. It knew nothing about me.</p><h3>Phase 3: Making It Remember You</h3><p>There’s a difference between an AI that answers questions and one that knows you.</p><p>After Phase 2, Claude could fetch any number from my database accurately. But every conversation was stateless. No continuity. No learning. The same way a brilliant analyst who reads your files fresh every morning still isn’t as useful as one who’s been working with you for six months.</p><p>The missing layer was memory.</p><h3>What Memory Actually Means Here</h3><p>Not memory in the sci-fi sense. Three specific types of information that change how useful the AI is over time:</p><p><strong>Semantic memory</strong> — facts about you “Swiggy Instamart counts as Grocery, not Food for me” “Salary arrives on the of each month”</p><p><strong>Procedural memory</strong> — how you want analysis done “Exclude SIP when calculating net spend” “Always compare to last month by default”</p><p><strong>Goals and corrections</strong> — things you’ve explicitly told it “I want to cut Amazon spend” “That ₹9,904 in March was a return — don’t count it”</p><p>Without these, Claude has to rediscover the same context every conversation. With them, it shows up already calibrated to how you think about your own money.</p><h3>How It Works</h3><p>The implementation is simpler than it sounds. No vector database, no embeddings. Just a chat_memories collection in firestore/mongodb and two additions to the system prompt.</p><p><strong>Saving:</strong> Claude gets a save_memory tool alongside the data tools. The system prompt tells it when to use it: when you state a goal, correct an assumption, reveal personal context, or when Claude notices a recurring pattern in your data. Claude decides. You don&#39;t have to say &quot;remember this.&quot;</p><p><strong>Loading:</strong> At the start of every conversation, all saved memories are fetched and injected into the system prompt:</p><pre>What you know about this user:<br>- [goal] User wants to reduce Amazon spending<br>- [correction] ₹9,904 charge in March 2026 was a return, exclude from averages<br>- [preference] Exclude SIP from net spend calculations<br>- [pattern] User orders heavily on Amazon, wants to track it regularly</pre><p>Claude reads this before seeing your question. It’s already in context.</p><h3>What This Looks Like in Practice</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*YW-UcO00T4mDbYUKnTDDPA.png" /><figcaption>Now it remembers my behavior.</figcaption></figure><p>What happened in the above exchange:</p><p>Claude fetched 3 months of Amazon spending from real transaction data and computed averages. I corrected it saying one March transaction was a return. Claude updated the calculation on the spot, revised the average to ₹14,853/month, and offered three budget targets. I said 12K. It confirmed how I’m tracking this month stating ₹6,870 spent, ₹5,130 remaining, 4 days left.</p><p>Then it said: <em>“I’ll keep an eye on this for you going forward.”</em></p><p>That line is Claude calling save_memory in the background. The next conversation I have, it already knows my Amazon budget is ₹12,000/month. I don&#39;t repeat myself.</p><h3>What It’s Not Yet</h3><p>This is honest LangMem-lite, not a full memory system. LangMem — the memory layer built for production AI agents — goes further: it deduplicates so saying “I want to cut food spend” five times doesn’t create five memories, detects contradictions and updates old facts when new ones conflict, and uses semantic search to inject only relevant memories rather than everything.</p><p>These are real gaps. Right now if you correct Claude twice about the same transaction, you get two memories. Over months that accumulates noise.</p><p>The dedup problem is solvable you check for near-duplicate content before inserting. Contradiction detection is harder. Semantic retrieval is overkill for a single-user app where total memories will stay under 50 for years.</p><p>For a personal finance app used by one person, this simpler version is surprisingly effective. The AI started feeling like a companion rather than a query engine after just a few conversations.</p><h3>What I’d Build Next</h3><p>Three things on the roadmap, in order of impact:</p><p><strong>Deduplication</strong> — before inserting a new memory, check if something similar already exists and update instead. Keeps the system prompt clean as months pass.</p><p><strong>Contradiction detection</strong> — if I said “I earn ₹1L/month” in March and “I got a raise, now ₹1.4L” in July, the system should retire the old memory and replace it. Claude can handle this with the right prompt.</p><p><strong>Passive extraction</strong> — instead of relying on Claude to decide what to save, run a background pass after every conversation: “here’s what was discussed, what’s worth remembering?” This catches goals buried in long messages, preferences mentioned in passing.</p><p>Beyond memory, the next step is injecting a compact 90-day merchant-level summary into every conversation as baseline context so Claude always has some foundation without needing tool calls for the simplest questions.</p><h3>What I Learned That Applies Beyond Finance</h3><p>The three phases aren’t specific to expense tracking. They’re a general pattern for building on top of any personal structured data.</p><p><strong>Context injection is a good prototype, a bad product.</strong> It gets you to a demo in an afternoon and hits a ceiling the moment questions outgrow the window you pre-loaded. Use it to validate the idea, then move on.</p><p><strong>Tool calling is the real foundation.</strong> The mental shift of LLMs reason, databases store is the unlock. Define what your data can answer, wrap those queries as tools, let the LLM decide what to fetch. This pattern works for any domain with structured personal data: health records, calendar history, workout logs, reading history.</p><p><strong>Memory is what makes it personal.</strong> Two people with identical spending patterns get very different value from the same AI if one has built up context over months of use. Building a basic version of this is not hard if you have a collection, a tool, and a few lines in the system prompt. The compound effect over time is real.</p><p><strong>None of these phases is impressive alone.</strong> Phase 1 is a fancy lookup. Phase 2 is a smarter lookup. Phase 3 is lookup with a notepad. Together they start to feel like something genuinely useful. An assistant that gets better the more you use it, built entirely on data you already had.</p><h3>The Stack, If You Want to Build This</h3><ul><li><strong>Data layer:</strong> any structured store — MongoDB, Firestore, Postgres</li><li><strong>LLM:</strong> Claude via the Anthropic API — tool calling is first-class</li><li><strong>Tool execution:</strong> a switch on tool name, calling your existing query methods</li><li><strong>Memory:</strong> a separate collection, injected as a block in every system prompt</li><li><strong>Frontend:</strong> a floating chat widget — a hundred lines of vanilla JS</li></ul><p><em>The source is on </em><a href="https://github.com/merishabh/expense-tracker"><em>GitHub</em></a><em> — fair warning, it’s a working project not a tutorial repo, so there’s some noise from experimentation. The relevant files for this post are </em><em>ai/claude.go, </em><em>ai/tools.go, </em><em>handlers/chat_tools.go, and </em><em>services/memory_service.go.<br></em>No frameworks. No vector databases. No orchestration libraries. The complexity is in understanding the pattern, not in the infrastructure.</p><p><em>Building something similar or have questions about any of these phases? Happy to discuss in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb800464d49d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>