<?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: Kiran Hooli</title>
    <description>The latest articles on DEV Community by Kiran Hooli (@kiran_hooli_01).</description>
    <link>https://dev.to/kiran_hooli_01</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%2F4235306%2F86424fc7-22a1-4764-b5f5-6a3b31f7bed6.jpg</url>
      <title>DEV Community: Kiran Hooli</title>
      <link>https://dev.to/kiran_hooli_01</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kiran_hooli_01"/>
    <language>en</language>
    <item>
      <title>Why I Made Hindsight Question Past Invoice Decisions</title>
      <dc:creator>Kiran Hooli</dc:creator>
      <pubDate>Mon, 09 Nov 2026 14:42:37 +0000</pubDate>
      <link>https://dev.to/kiran_hooli_01/why-i-made-hindsight-question-past-invoice-decisions-23lf</link>
      <guid>https://dev.to/kiran_hooli_01/why-i-made-hindsight-question-past-invoice-decisions-23lf</guid>
      <description>&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%2F5a9rf8wgi8e5ty8lwidm.png" 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%2F5a9rf8wgi8e5ty8lwidm.png" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;br&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%2Fsxg4efb2trf2hywvxqx3.png" 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%2Fsxg4efb2trf2hywvxqx3.png" alt=" " width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  An Invoice Can Be Wrong. But What Happens Next?
&lt;/h2&gt;

&lt;p&gt;Imagine a finance team receiving an invoice from a supplier.&lt;/p&gt;

&lt;p&gt;The purchase order says ₹1,800 per unit, but the supplier's invoice says ₹1,872. Detecting that 4% difference is straightforward. Any reasonable invoice-matching system can identify it.&lt;/p&gt;

&lt;p&gt;But detecting the discrepancy raises a more difficult question: &lt;strong&gt;What should the finance team actually do about it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Should the invoice be corrected? Rejected? Escalated? Has something similar happened before? And if it has, is that earlier decision still consistent with the company's current policy?&lt;/p&gt;

&lt;p&gt;These questions led us to build &lt;strong&gt;LedgerMind&lt;/strong&gt;, a policy-aware invoice exception resolution system that combines deterministic validation, persistent decision memory, and human oversight.&lt;/p&gt;

&lt;p&gt;We started with a simple observation: an AI system that remembers earlier decisions is not necessarily an AI system that makes better decisions.&lt;/p&gt;

&lt;p&gt;It also needs to know when those memories should not be trusted.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Gap We Wanted to Address
&lt;/h2&gt;

&lt;p&gt;Accounts payable teams commonly compare three documents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Purchase Order (PO): What the company agreed to purchase.&lt;/li&gt;
&lt;li&gt;Goods Receipt Note (GRN): What the company actually received.&lt;/li&gt;
&lt;li&gt;Supplier Invoice: What the supplier wants to be paid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is known as three-way matching.&lt;/p&gt;

&lt;p&gt;Matching can identify incorrect prices, quantity differences, missing receipts, duplicate invoices, and other exceptions.&lt;/p&gt;

&lt;p&gt;Existing financial software already provides various matching and exception-management capabilities. Our aim wasn't to claim those systems cannot detect discrepancies.&lt;/p&gt;

&lt;p&gt;We wanted to explore a different challenge: how can an AI assistant use an organization's previous resolution decisions without treating old behavior as unquestionable authority?&lt;/p&gt;

&lt;p&gt;Historical decisions may be scattered across systems or attached to individual reviewers. Some may reflect outdated policies. Others may have been exceptional approvals that should never become general rules.&lt;/p&gt;

&lt;p&gt;Our idea was to connect historical decision context with current policy and show the reasoning to a human reviewer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Built
&lt;/h2&gt;

&lt;p&gt;LedgerMind is a Python application with a Streamlit interface.&lt;/p&gt;

&lt;p&gt;Its architecture brings together several components.&lt;/p&gt;

&lt;p&gt;Python matching engine: Compares invoices, purchase orders, and goods receipts using deterministic rules. Financial calculations do not depend on a language model guessing the answer.&lt;/p&gt;

&lt;p&gt;SQLite: Stores vendors, purchase orders, goods receipts, invoices, and human reviews. It provides a local business-record database separate from agent memory.&lt;/p&gt;

&lt;p&gt;Hindsight: Provides persistent memory capabilities for retaining previous decisions and retrieving relevant historical context.&lt;/p&gt;

&lt;p&gt;Policy engine Retrieves applicable written policies and checks whether a historical precedent is consistent with those rules.&lt;/p&gt;

&lt;p&gt;Groq-hosted language model: Helps produce understandable explanations and proposed resolution actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human review workflow:&lt;/strong&gt; Allows a person to evaluate and record the final decision. LedgerMind does not automatically pay invoices.&lt;/p&gt;

&lt;p&gt;The prototype includes synthetic historical decisions and test invoices. It also supports adding new invoices through manual entry and structured CSV intake.&lt;/p&gt;

&lt;p&gt;We intentionally separated transaction storage from institutional memory.&lt;/p&gt;

&lt;p&gt;SQLite answers, "What invoice did we receive?"&lt;/p&gt;

&lt;p&gt;Hindsight helps answer, "What have we learned from similar decisions?"&lt;/p&gt;

&lt;p&gt;They serve different purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Hindsight Became Central to the Design
&lt;/h2&gt;

&lt;p&gt;Most of the interesting questions appeared after the initial invoice matching was complete.&lt;/p&gt;

&lt;p&gt;If an invoice contains an exception, we want the system to find relevant earlier resolutions.&lt;/p&gt;

&lt;p&gt;For example, the agent could retrieve previous decisions involving a similar supplier, exception category, or pricing discrepancy.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://github.com/vectorize-io/hindsight" rel="noopener noreferrer"&gt;Hindsight&lt;/a&gt;, we developed a workflow around persistent experience.&lt;/p&gt;

&lt;p&gt;The important concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retain: Store useful information from reviewed outcomes.&lt;/li&gt;
&lt;li&gt;Recall: Retrieve relevant past information when another case appears.&lt;/li&gt;
&lt;li&gt;Reflect: Derive broader insights from accumulated experiences, where supported by the memory system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In LedgerMind, retain and recall are particularly important. A reviewed outcome can become part of the decision history, while later investigations can use previously retained information as context.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://hindsight.vectorize.io/" rel="noopener noreferrer"&gt;Hindsight documentation&lt;/a&gt; explains the memory system's capabilities. The broader motivation is also discussed in Vectorize's guide to &lt;a href="https://vectorize.io/what-is-agent-memory" rel="noopener noreferrer"&gt;agent memory&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But using memory exposed a subtle risk.&lt;/p&gt;

&lt;p&gt;An agent can retrieve something that looks relevant and still misunderstand what that evidence means.&lt;/p&gt;

&lt;p&gt;That problem shaped several of our most important engineering decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Innovation One: Memory Does Not Override Policy
&lt;/h2&gt;

&lt;p&gt;Consider our synthetic Prabhav Infosystems invoice scenario.&lt;/p&gt;

&lt;p&gt;The purchase order specifies ₹1,800 per unit. The supplier charges ₹1,872 instead.&lt;/p&gt;

&lt;p&gt;For 100 units with the scenario's 18% GST assumption:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected total: ₹212,400&lt;/li&gt;
&lt;li&gt;Invoiced total: ₹220,896&lt;/li&gt;
&lt;li&gt;Financial discrepancy: ₹8,496&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A traditional rule-based matcher can detect this discrepancy.&lt;/p&gt;

&lt;p&gt;LedgerMind goes further by combining the current policy with available historical resolution evidence.&lt;/p&gt;

&lt;p&gt;In this scenario, the applicable policy supports correcting the invoice to the agreed purchase-order rate. The system proposes an edited payable amount of ₹212,400 for human review.&lt;/p&gt;

&lt;p&gt;The critical principle is that &lt;strong&gt;a historical approval is evidence of what happened, not automatic permission to repeat it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Even if an earlier reviewer accepted a similar increase, that decision should not silently override the policy applicable today.&lt;/p&gt;

&lt;p&gt;We built policy–precedent conflict detection around this principle.&lt;/p&gt;

&lt;p&gt;This is the part of LedgerMind we consider most interesting: memory supports decision-making, but current policy remains an independent constraint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Innovation Two: A Memory Is Only as Reliable as Its Metadata
&lt;/h2&gt;

&lt;p&gt;During development, we discovered a surprising bug.&lt;/p&gt;

&lt;p&gt;A historical review from Zenith Precision Engineering appeared with metadata identifying it as a Prabhav Infosystems decision.&lt;/p&gt;

&lt;p&gt;The original review content was not the problem. The issue came from how our application matched vendor names before storing the memory.&lt;/p&gt;

&lt;p&gt;Common company-name suffixes such as "Pvt Ltd" caused unrelated vendors to be treated as possible matches.&lt;/p&gt;

&lt;p&gt;That meant a correctly written review could still receive an incorrect vendor tag.&lt;/p&gt;

&lt;p&gt;We changed the vendor identification logic to avoid relying on such weak matches.&lt;/p&gt;

&lt;p&gt;The lesson was immediate: &lt;strong&gt;retrieval accuracy begins before retrieval&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If incorrect labels are attached when a memory is stored, even a good retrieval engine can return misleading evidence.&lt;/p&gt;

&lt;p&gt;We also made it clearer when a recalled precedent belongs to a different vendor.&lt;/p&gt;

&lt;p&gt;Cross-vendor evidence can be useful, but it shouldn't be presented as if it came from the same supplier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Innovation Three: Five Facts Are Not Five Decisions
&lt;/h2&gt;

&lt;p&gt;Another issue involved how memory information was displayed.&lt;/p&gt;

&lt;p&gt;One historical review could produce several extracted facts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The supplier name&lt;/li&gt;
&lt;li&gt;The invoice discrepancy&lt;/li&gt;
&lt;li&gt;The relevant policy&lt;/li&gt;
&lt;li&gt;The reviewer action&lt;/li&gt;
&lt;li&gt;The review rationale&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Initially, those facts could appear as separate evidence cards.&lt;/p&gt;

&lt;p&gt;This created a misleading impression that multiple independent decisions supported the same outcome.&lt;/p&gt;

&lt;p&gt;We changed the interface to group related facts under their original review.&lt;/p&gt;

&lt;p&gt;A single review now represents one logical historical precedent, with supporting details available inside it.&lt;/p&gt;

&lt;p&gt;This matters because apparent evidence volume can affect how confident a proposed recommendation looks.&lt;/p&gt;

&lt;p&gt;Five observations about one decision should not be interpreted as five independent decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Innovation Four: An Invoice Must Not Validate Itself
&lt;/h2&gt;

&lt;p&gt;One of our more subtle problems involved previous human feedback.&lt;/p&gt;

&lt;p&gt;Suppose an invoice is reviewed, and its outcome is retained in memory.&lt;/p&gt;

&lt;p&gt;When the same invoice is reopened, the memory system may retrieve that previous review.&lt;/p&gt;

&lt;p&gt;That's useful for the audit trail.&lt;/p&gt;

&lt;p&gt;But there is a problem if the agent treats its own earlier review of that invoice as independent evidence supporting a new recommendation.&lt;/p&gt;

&lt;p&gt;The reasoning becomes circular.&lt;/p&gt;

&lt;p&gt;We updated the resolution workflow to separate the current invoice's previous review from independent historical precedents.&lt;/p&gt;

&lt;p&gt;The earlier review can still appear under the audit history, but it should not inflate precedent-based confidence.&lt;/p&gt;

&lt;p&gt;This taught us that reliable memory needs boundaries, not just persistence.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happens With a Newly Created Invoice?
&lt;/h2&gt;

&lt;p&gt;We also wanted LedgerMind to work beyond a fixed set of prepared examples.&lt;/p&gt;

&lt;p&gt;In one user-created Nova Tech Supplies scenario, the purchase order specified ₹1,000 per unit, while the invoice charged ₹1,100.&lt;/p&gt;

&lt;p&gt;For ten units with 18% GST:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected purchase-order total: ₹11,800&lt;/li&gt;
&lt;li&gt;Supplier invoice total: ₹12,980&lt;/li&gt;
&lt;li&gt;Difference: ₹1,180&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LedgerMind identified the price mismatch using its deterministic matching logic.&lt;/p&gt;

&lt;p&gt;The invoice record was saved in SQLite and could be accessed again after refreshing the application.&lt;/p&gt;

&lt;p&gt;From there, the Resolution Workbench could present the discrepancy, applicable policy context, available historical evidence, and a proposed next action.&lt;/p&gt;

&lt;p&gt;The final outcome remains subject to human review.&lt;/p&gt;

&lt;p&gt;This distinction matters to us. We want the system to assist with investigation and consistency, not silently replace financial accountability.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Learned About Live Memory and Fallbacks
&lt;/h2&gt;

&lt;p&gt;One practical challenge was making memory retrieval reliable.&lt;/p&gt;

&lt;p&gt;Our implementation includes a local JSONL fallback for situations where live Hindsight retrieval is unavailable.&lt;/p&gt;

&lt;p&gt;This keeps historical context accessible, but it also creates a responsibility to identify the actual source of that context.&lt;/p&gt;

&lt;p&gt;During testing, Hindsight's server logs confirmed successful recall operations from our memory banks, including one request that returned 51 facts and another that returned nine.&lt;/p&gt;

&lt;p&gt;We also encountered application requests where the interface used offline fallback.&lt;/p&gt;

&lt;p&gt;Those two observations are not interchangeable.&lt;/p&gt;

&lt;p&gt;A successful Hindsight server request does not automatically prove that a particular displayed recommendation used live retrieval.&lt;/p&gt;

&lt;p&gt;That's why our interface distinguishes evidence attributed to the Hindsight vector database from evidence loaded through the offline JSONL store.&lt;/p&gt;

&lt;p&gt;We learned that honest provenance is as important as the recommendation itself.&lt;/p&gt;

&lt;p&gt;A reviewer needs to know not only what an agent remembers, but where that evidence came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Comes Next
&lt;/h2&gt;

&lt;p&gt;LedgerMind is currently a working prototype using synthetic business scenarios.&lt;/p&gt;

&lt;p&gt;Its current capabilities demonstrate invoice intake, deterministic exception detection, local record persistence, policy-aware resolution proposals, historical memory integration, and human review.&lt;/p&gt;

&lt;p&gt;Production deployment would require further work, including enterprise ERP integrations, stronger access control, monitoring, security reviews, and validation against real organizational processes.&lt;/p&gt;

&lt;p&gt;Those limitations are important, but they don't change the central insight we gained from building the system.&lt;/p&gt;

&lt;p&gt;We originally wanted to give an AI assistant memory so that it could learn from earlier financial decisions.&lt;/p&gt;

&lt;p&gt;What we discovered was more interesting.&lt;/p&gt;

&lt;p&gt;An AI agent shouldn't simply remember what happened. It should know where that memory came from, whether it applies to the present situation, and whether following it is still justified.&lt;/p&gt;

&lt;p&gt;That's the principle behind LedgerMind.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
