<?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: Kavya pamarthi</title>
    <description>The latest articles on DEV Community by Kavya pamarthi (@kavya_pamarthi).</description>
    <link>https://dev.to/kavya_pamarthi</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%2F4149731%2Fc9194823-b695-46bb-bd43-6a09a30ae1b5.png</url>
      <title>DEV Community: Kavya pamarthi</title>
      <link>https://dev.to/kavya_pamarthi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kavya_pamarthi"/>
    <language>en</language>
    <item>
      <title>An Accounts Payable Agent Needs More Than Invoice Extraction</title>
      <dc:creator>Kavya pamarthi</dc:creator>
      <pubDate>Tue, 29 Sep 2026 13:08:49 +0000</pubDate>
      <link>https://dev.to/kavya_pamarthi/an-accounts-payable-agent-needs-more-than-invoice-extraction-145e</link>
      <guid>https://dev.to/kavya_pamarthi/an-accounts-payable-agent-needs-more-than-invoice-extraction-145e</guid>
      <description>&lt;p&gt;An Accounts Payable Agent Needs More Than Invoice Extraction&lt;br&gt;
An invoice can be perfectly readable and still be the wrong invoice to approve.&lt;br&gt;
That became one of the most important engineering lessons for me while working on our Accounts Payable Agent.&lt;br&gt;
At first, accounts payable automation looks like a document-processing problem.&lt;br&gt;
Read the invoice.&lt;br&gt;
Extract the vendor.&lt;br&gt;
Find the invoice number.&lt;br&gt;
Find the amount.&lt;br&gt;
Find the purchase order.&lt;br&gt;
But extraction only answers one question:&lt;br&gt;
What information is present in the document?&lt;br&gt;
It does not answer:&lt;br&gt;
Does this information make sense in context?&lt;br&gt;
That is where validation, decision-making, and agent memory become important.&lt;br&gt;
From invoice to decision&lt;br&gt;
I designed the workflow around several stages:&lt;br&gt;
Invoice&lt;br&gt;
   ↓&lt;br&gt;
Extraction&lt;br&gt;
   ↓&lt;br&gt;
Normalization&lt;br&gt;
   ↓&lt;br&gt;
Validation&lt;br&gt;
   ↓&lt;br&gt;
Historical context&lt;br&gt;
   ↓&lt;br&gt;
Decision&lt;br&gt;
Each stage has a different responsibility.&lt;br&gt;
Extraction identifies information.&lt;br&gt;
Validation checks whether the information satisfies the required conditions.&lt;br&gt;
Memory provides relevant historical context.&lt;br&gt;
The decision layer determines what should happen next.&lt;br&gt;
Keeping these responsibilities separate makes the workflow easier to understand.&lt;br&gt;
Why extraction is not enough&lt;br&gt;
Imagine an invoice contains:&lt;br&gt;
Vendor: ABC Supplies&lt;br&gt;
Invoice Number: INV-2048&lt;br&gt;
PO: PO-8831&lt;br&gt;
Total: ₹72,000&lt;br&gt;
The extraction system may correctly identify every field.&lt;br&gt;
But suppose the purchase order expects ₹60,000.&lt;br&gt;
The invoice is readable.&lt;br&gt;
The extracted information is correct.&lt;br&gt;
Yet something still requires investigation.&lt;br&gt;
The agent needs context before deciding what to do.&lt;br&gt;
Validation with historical context&lt;br&gt;
This is where Hindsight becomes useful.&lt;br&gt;
Suppose the same vendor previously submitted an invoice with a similar discrepancy.&lt;br&gt;
The previous case may contain:&lt;br&gt;
Issue:&lt;br&gt;
Invoice amount differed from PO.&lt;/p&gt;

&lt;p&gt;Action:&lt;br&gt;
Escalated for review.&lt;/p&gt;

&lt;p&gt;Resolution:&lt;br&gt;
Additional goods were confirmed.&lt;/p&gt;

&lt;p&gt;Final result:&lt;br&gt;
Invoice approved.&lt;br&gt;
When another similar invoice arrives, the agent can retrieve this context.&lt;br&gt;
The workflow becomes:&lt;br&gt;
invoice = extract_invoice(document)&lt;/p&gt;

&lt;p&gt;history = memory.search(&lt;br&gt;
    vendor=invoice.vendor,&lt;br&gt;
    invoice_context=invoice&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;result = validate(&lt;br&gt;
    invoice=invoice,&lt;br&gt;
    history=history&lt;br&gt;
)&lt;br&gt;
Again, the exact code should correspond to the implementation in the project.&lt;br&gt;
The important point is that the current invoice and historical context are considered together.&lt;br&gt;
A before-and-after workflow&lt;br&gt;
Without memory&lt;br&gt;
Invoice&lt;br&gt;
   ↓&lt;br&gt;
Extract&lt;br&gt;
   ↓&lt;br&gt;
Validate&lt;br&gt;
   ↓&lt;br&gt;
Apply rules&lt;br&gt;
   ↓&lt;br&gt;
Decision&lt;br&gt;
With memory&lt;br&gt;
Invoice&lt;br&gt;
   ↓&lt;br&gt;
Extract&lt;br&gt;
   ↓&lt;br&gt;
Retrieve relevant history&lt;br&gt;
   ↓&lt;br&gt;
Validate current invoice&lt;br&gt;
   ↓&lt;br&gt;
Decision&lt;br&gt;
   ↓&lt;br&gt;
Save outcome&lt;br&gt;
The second workflow does not eliminate rules.&lt;br&gt;
It gives the rules and agent more context.&lt;br&gt;
Why relevant retrieval matters&lt;br&gt;
More memory does not necessarily mean better decisions.&lt;br&gt;
Suppose the system retrieves ten old invoices when only one is relevant.&lt;br&gt;
The agent now has more information but potentially more noise.&lt;br&gt;
For an AP workflow, useful retrieval can focus on:&lt;br&gt;
Same vendor&lt;br&gt;
Similar invoice issue&lt;br&gt;
Previous validation failure&lt;br&gt;
Previous escalation&lt;br&gt;
Previous human resolution&lt;br&gt;
Similar payment conditions&lt;br&gt;
The objective should be relevant context, not maximum context.&lt;br&gt;
Memory as evidence&lt;br&gt;
I found it useful to think about memory as evidence.&lt;br&gt;
For example:&lt;br&gt;
Current invoice:&lt;br&gt;
₹48,500&lt;/p&gt;

&lt;p&gt;Historical context:&lt;br&gt;
A similar invoice from the same vendor had a&lt;br&gt;
PO mismatch and was manually verified.&lt;/p&gt;

&lt;p&gt;Current validation:&lt;br&gt;
PO mismatch exists again.&lt;br&gt;
The memory doesn't tell the agent:&lt;br&gt;
Approve this invoice.&lt;br&gt;
Instead, it tells the agent:&lt;br&gt;
This situation has happened before, and here is what happened then.&lt;br&gt;
The agent can then evaluate the current case.&lt;br&gt;
That distinction prevents old decisions from becoming automatic rules.&lt;br&gt;
Human review is still part of the architecture&lt;br&gt;
One of the most important parts of an automated financial workflow is knowing when to stop.&lt;br&gt;
A simple decision structure is:&lt;br&gt;
Information sufficient?&lt;br&gt;
        │&lt;br&gt;
    ┌───┴───┐&lt;br&gt;
   Yes      No&lt;br&gt;
    │        │&lt;br&gt;
 Validate   Review&lt;br&gt;
    │&lt;br&gt;
Decision&lt;br&gt;
If the information is incomplete or conflicting, the agent can escalate.&lt;br&gt;
That is not a failure of automation.&lt;br&gt;
It is a deliberate boundary.&lt;br&gt;
Why the decision should be explainable&lt;br&gt;
An AP system should not only produce:&lt;br&gt;
{&lt;br&gt;
  "status": "approved"&lt;br&gt;
}&lt;br&gt;
It is more useful if the system preserves a reason:&lt;br&gt;
{&lt;br&gt;
  "status": "approved",&lt;br&gt;
  "reason": "Validated against the available invoice and purchase-order context."&lt;br&gt;
}&lt;br&gt;
The exact fields should follow the actual application.&lt;br&gt;
The broader idea is to preserve enough information to understand the decision later.&lt;br&gt;
That also makes the resulting memory more useful.&lt;br&gt;
Hindsight as part of the architecture&lt;br&gt;
Hindsight provides the persistent memory layer around the agent.&lt;br&gt;
The overall architecture can be represented as:&lt;br&gt;
             ┌──────────────┐&lt;br&gt;
             │   Invoice    │&lt;br&gt;
             └──────┬───────┘&lt;br&gt;
                    ↓&lt;br&gt;
             ┌──────────────┐&lt;br&gt;
             │  Extraction  │&lt;br&gt;
             └──────┬───────┘&lt;br&gt;
                    ↓&lt;br&gt;
             ┌──────────────┐&lt;br&gt;
             │ Validation   │&lt;br&gt;
             └──────┬───────┘&lt;br&gt;
                    ↓&lt;br&gt;
          ┌────────────────────┐&lt;br&gt;
          │ Hindsight Memory   │&lt;br&gt;
          │ Relevant history   │&lt;br&gt;
          └─────────┬──────────┘&lt;br&gt;
                    ↓&lt;br&gt;
             ┌──────────────┐&lt;br&gt;
             │ AP Decision  │&lt;br&gt;
             └──────┬───────┘&lt;br&gt;
                    ↓&lt;br&gt;
             ┌──────────────┐&lt;br&gt;
             │   Outcome    │&lt;br&gt;
             └──────┬───────┘&lt;br&gt;
                    ↓&lt;br&gt;
             Store useful&lt;br&gt;
                memory&lt;br&gt;
I used the Hindsight GitHub repository⁠� and its documentation⁠� as the basis for the agent-memory integration.&lt;br&gt;
The practical lesson&lt;br&gt;
The biggest lesson from this part of the project was that agentic automation is not simply:&lt;br&gt;
LLM + Invoice&lt;br&gt;
A useful workflow is closer to:&lt;br&gt;
Current data&lt;br&gt;
+&lt;br&gt;
Validation rules&lt;br&gt;
+&lt;br&gt;
Historical context&lt;br&gt;
+&lt;br&gt;
Decision boundaries&lt;br&gt;
+&lt;br&gt;
Human escalation&lt;br&gt;
Each part solves a different problem.&lt;br&gt;
Extraction tells us what the document contains.&lt;br&gt;
Validation checks the current information.&lt;br&gt;
Memory tells us whether relevant situations have occurred before.&lt;br&gt;
Decision-making determines the next action.&lt;br&gt;
Escalation handles uncertainty.&lt;br&gt;
Three reusable lessons&lt;br&gt;
Separate extraction from decision-making&lt;br&gt;
Correctly extracting a value does not mean the value should automatically be trusted.&lt;br&gt;
Treat memory as context&lt;br&gt;
Previous interactions should inform current decisions rather than blindly determine them.&lt;br&gt;
Design escalation from the beginning&lt;br&gt;
An agent should have a clear path when information is incomplete or contradictory.&lt;br&gt;
Final thought&lt;br&gt;
The hardest part of an AP Agent isn't teaching it to read invoices.&lt;br&gt;
It is teaching the system to understand when an invoice is routine, when it resembles something that happened before, and when it needs additional review.&lt;br&gt;
That's where validation and memory become valuable.&lt;br&gt;
The result is not simply an invoice-processing script.&lt;br&gt;
It is a workflow that can use previous context while still evaluating every new invoice on its own terms.&lt;/p&gt;

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