<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tarun Bajolge</title>
    <description>The latest articles on DEV Community by Tarun Bajolge (@tarun_41414).</description>
    <link>https://dev.to/tarun_41414</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4150072%2Fdc63c14a-c78a-4156-af51-13cbe0918e18.png</url>
      <title>DEV Community: Tarun Bajolge</title>
      <link>https://dev.to/tarun_41414</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tarun_41414"/>
    <language>en</language>
    <item>
      <title>I Built an Accounts Payable Agent That Knows When to Ask a Human</title>
      <dc:creator>Tarun Bajolge</dc:creator>
      <pubDate>Tue, 29 Sep 2026 15:12:09 +0000</pubDate>
      <link>https://dev.to/tarun_41414/i-built-an-accounts-payable-agent-that-knows-when-to-ask-a-human-3ahl</link>
      <guid>https://dev.to/tarun_41414/i-built-an-accounts-payable-agent-that-knows-when-to-ask-a-human-3ahl</guid>
      <description>&lt;h1&gt;
  
  
  I Built an Accounts Payable Agent That Knows When to Ask a Human
&lt;/h1&gt;

&lt;p&gt;Every invoice can look like a new problem.&lt;/p&gt;

&lt;p&gt;A vendor sends an invoice, the system checks it, and a human may have to review it. Then the next invoice from the same vendor arrives, and the process starts again.&lt;/p&gt;

&lt;p&gt;But what if the system could remember what happened before?&lt;/p&gt;

&lt;p&gt;That was the idea behind &lt;strong&gt;VendorSense&lt;/strong&gt; — an AI-powered Accounts Payable agent that uses &lt;strong&gt;Hindsight&lt;/strong&gt; to remember previous vendor experiences and use that context when evaluating future invoices.&lt;/p&gt;

&lt;p&gt;The goal wasn't to replace the human completely.&lt;/p&gt;

&lt;p&gt;It was to make the agent better at recognizing what is normal and, more importantly, knowing &lt;strong&gt;when something needs a human&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What VendorSense Does
&lt;/h2&gt;

&lt;p&gt;VendorSense is a Streamlit-based application that processes supplier invoices and decides whether they can be handled automatically or should be sent for human review.&lt;/p&gt;

&lt;p&gt;The overall flow is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Invoice → Hindsight Recall → AI Decision → Auto-process / Exception → Human Review → Hindsight Retain&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The application extracts important invoice information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vendor&lt;/li&gt;
&lt;li&gt;Invoice ID&lt;/li&gt;
&lt;li&gt;Amount&lt;/li&gt;
&lt;li&gt;Purchase order&lt;/li&gt;
&lt;li&gt;Payment terms&lt;/li&gt;
&lt;li&gt;Bank account information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It then combines the current invoice with relevant vendor history before making a decision.&lt;/p&gt;

&lt;p&gt;The important difference is that the agent isn't looking at the invoice in isolation.&lt;/p&gt;

&lt;p&gt;It can also ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"What do I already know about this vendor?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Our VendorSense interface
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi6zzxr17h1gn5so485wl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi6zzxr17h1gn5so485wl.jpeg" alt=" " width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The interface lets us see the invoice workflow, exceptions, vendor memory, and the learning process.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Memory Matters
&lt;/h1&gt;

&lt;p&gt;Imagine that we receive an invoice from:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apex Industrial Supplies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The invoice contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amount: ₹52,100&lt;/li&gt;
&lt;li&gt;Purchase Order: AIS-2419&lt;/li&gt;
&lt;li&gt;Payment Terms: Net 30&lt;/li&gt;
&lt;li&gt;Bank account ending: 7821&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Looking only at the current invoice doesn't tell us whether these details are normal.&lt;/p&gt;

&lt;p&gt;But suppose the system already remembers that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Previous Apex invoices were generally within a similar amount range.&lt;/li&gt;
&lt;li&gt;Their purchase orders followed the same format.&lt;/li&gt;
&lt;li&gt;Their payment terms were usually Net 30.&lt;/li&gt;
&lt;li&gt;Their bank account ending in 7821 had previously been verified.&lt;/li&gt;
&lt;li&gt;Previous invoices had been approved by a human.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the current invoice has context.&lt;/p&gt;

&lt;p&gt;This is where Hindsight becomes important.&lt;/p&gt;

&lt;p&gt;Before making its decision, VendorSense retrieves relevant experiences from Hindsight and gives that information to the reasoning agent.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Is this invoice okay?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the agent can reason about something closer to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Does this invoice match the history we have for this vendor?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That small difference is what makes memory useful.&lt;/p&gt;




&lt;h1&gt;
  
  
  Memory Is Evidence, Not Truth
&lt;/h1&gt;

&lt;p&gt;One of the most important ideas in our project is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Memory is evidence, not truth.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We didn't want the agent to blindly trust everything it remembered.&lt;/p&gt;

&lt;p&gt;Imagine the system remembers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verified bank account: XXXX7821&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then a new invoice arrives with:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bank account: XXXX9143&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even if everything else looks normal, the changed bank account should matter.&lt;/p&gt;

&lt;p&gt;The system should not think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I've seen this vendor before, so I'll approve it."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead, the change should result in:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXCEPTION → Human verification required&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is particularly important for financial workflows because a system becoming &lt;em&gt;too comfortable&lt;/em&gt; with a familiar vendor can be dangerous.&lt;/p&gt;

&lt;p&gt;Our idea was therefore to use memory to understand normal behavior, while still treating significant changes as reasons to slow down and involve a person.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Human Is Part of the Learning Loop
&lt;/h1&gt;

&lt;p&gt;Another important part of VendorSense is what happens after an invoice reaches the human-review queue.&lt;/p&gt;

&lt;p&gt;The human reviewer can look at the invoice, decide whether it should be approved or rejected, and add a note explaining the decision.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Invoice approved after checking the purchase order and confirming the vendor details."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That decision and explanation are then stored in Hindsight as a new experience.&lt;/p&gt;

&lt;p&gt;So the workflow becomes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent evaluates invoice&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human reviews when necessary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human makes a decision&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decision and reasoning become memory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Future invoices can use that experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means the human isn't simply correcting the agent.&lt;/p&gt;

&lt;p&gt;The human is also helping create better context for future decisions.&lt;/p&gt;




&lt;h1&gt;
  
  
  Before and After Memory
&lt;/h1&gt;

&lt;p&gt;The difference becomes clearer when we look at the same vendor over multiple invoices.&lt;/p&gt;

&lt;h3&gt;
  
  
  First time seeing a vendor
&lt;/h3&gt;

&lt;p&gt;If there is no useful history, the agent has very little evidence to work with.&lt;/p&gt;

&lt;p&gt;For a new vendor, the safer behavior is to send the invoice for human review.&lt;/p&gt;

&lt;p&gt;The human checks it and makes a decision.&lt;/p&gt;

&lt;p&gt;That decision then becomes part of the vendor's history.&lt;/p&gt;

&lt;h3&gt;
  
  
  Later invoice from the same vendor
&lt;/h3&gt;

&lt;p&gt;Now another invoice arrives.&lt;/p&gt;

&lt;p&gt;The agent can recall the previous experience and compare the new invoice against it.&lt;/p&gt;

&lt;h2&gt;
  
  
  If the amount, purchase-order pattern, payment terms, and verified details are consistent, the invoice can be treated as a routine case.
&lt;/h2&gt;

&lt;h1&gt;
  
  
  What the Agent Remembers
&lt;/h1&gt;

&lt;p&gt;We also didn't want to remember only a simple label such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Approved."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The reason behind the decision can be just as important.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approved&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;is useful.&lt;/p&gt;

&lt;p&gt;But:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approved after checking the purchase order and confirming the vendor's updated details&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;contains much more context.&lt;/p&gt;

&lt;p&gt;That context can help the agent understand &lt;em&gt;why&lt;/em&gt; something was approved or rejected when it encounters a similar situation later.&lt;/p&gt;

&lt;p&gt;This is one of the reasons Hindsight fits the problem well. The agent can retain experiences rather than forcing every previous decision into a rigid vendor-history table.&lt;/p&gt;




&lt;h3&gt;
  
  
  Vendor Memory
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6irbnp745hth6s44q9g3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6irbnp745hth6s44q9g3.jpeg" alt=" " width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This part of the application makes the idea of persistent memory easier to understand.&lt;/p&gt;

&lt;p&gt;Instead of the agent forgetting everything after processing an invoice, previous experiences can become part of the context for future work.&lt;/p&gt;




&lt;h1&gt;
  
  
  Keeping User Memory Separate
&lt;/h1&gt;

&lt;p&gt;Accounts Payable information can contain sensitive business data.&lt;/p&gt;

&lt;p&gt;Because of that, we didn't want all users to share one giant memory bank.&lt;/p&gt;

&lt;p&gt;VendorSense creates a separate Hindsight memory bank for each user.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User A → User A's memory → User A's vendor experiences&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User B → User B's memory → User B's vendor experiences&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This keeps the memory boundary tied to the user rather than treating all vendor experiences as one global collection.&lt;/p&gt;

&lt;p&gt;That became an important architectural decision because an agent that remembers everything isn't useful if it remembers the wrong user's information.&lt;/p&gt;




&lt;h1&gt;
  
  
  What We Learned
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. Memory should influence the decision
&lt;/h3&gt;

&lt;p&gt;Simply adding memory to an agent isn't enough.&lt;/p&gt;

&lt;p&gt;The useful part is retrieving relevant experience at the right point in the workflow and giving the agent enough context to use it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Human decisions are valuable learning signals
&lt;/h3&gt;

&lt;p&gt;The human review isn't just an exception-handling step.&lt;/p&gt;

&lt;p&gt;It can also become a source of future knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Familiar vendors can still have unusual invoices
&lt;/h3&gt;

&lt;p&gt;A good history shouldn't mean automatic trust forever.&lt;/p&gt;

&lt;p&gt;The current invoice still matters.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The agent should know when to stop
&lt;/h3&gt;

&lt;p&gt;For an Accounts Payable system, automation isn't the only goal.&lt;/p&gt;

&lt;p&gt;Knowing when to say &lt;strong&gt;"a human should check this"&lt;/strong&gt; is equally important.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Memory needs boundaries
&lt;/h3&gt;

&lt;p&gt;Using separate memory banks for users gave us a simple way to keep different users' experiences isolated.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Bigger Idea
&lt;/h1&gt;

&lt;p&gt;Although we built VendorSense for Accounts Payable, the pattern goes beyond invoices.&lt;/p&gt;

&lt;p&gt;The basic idea is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember the past&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understand the current situation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use previous experience as context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ask a human when necessary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn from the confirmed outcome&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use that experience next time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is what we wanted to explore with VendorSense.&lt;/p&gt;

&lt;p&gt;An ordinary AI workflow can process a document and produce an answer.&lt;/p&gt;

&lt;p&gt;An agent with memory can use what happened before to approach the next task with more context.&lt;/p&gt;

&lt;p&gt;For us, the interesting part wasn't simply making an AI read invoices.&lt;/p&gt;

&lt;p&gt;It was creating a system where &lt;strong&gt;past experience, current information, AI reasoning, and human judgment work together&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And that is what Hindsight allowed us to build into VendorSense.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
