DEV Community

Pulla Indira Keerthana
Pulla Indira Keerthana

Posted on

What If Your AI Agent Could Remember Why an Invoice Was Resolved?



Accounts Payable systems are already good at telling you that an invoice doesn't match a purchase order.

The harder question is:

What actually happened, and have we seen this before?

An invoice might be ₹55,000 while the purchase order says ₹50,000. A traditional matching system can flag the ₹5,000 difference.

But someone still has to investigate.

Was there an approved contract amendment? Was the delivery partial? Has this vendor had the same issue before? Did someone resolve a similar exception differently six months ago?

That investigation is where a lot of human knowledge gets trapped.

I built Vaulty — AI Exception Intelligence to explore a different approach:

Memory guides the investigation. Current evidence decides the outcome.

Vaulty is an agentic Accounts Payable exception investigation system that investigates invoice cases, recalls organizational experience using Hindsight, verifies that experience against current evidence, proposes a resolution, keeps payment release human-gated, and learns from the outcome.

The problem isn't matching. It's investigation.

Most AP workflows already have some form of invoice, purchase order, and receipt matching.

The problem starts after a mismatch is detected.

The investigator may need to connect:

Invoice data
Purchase orders
Receipts
Contracts
Contract amendments
Vendor history
Previous exception resolutions
Previous human decisions

The information exists, but the reasoning behind previous decisions often disappears once the case is closed.

So the next similar exception starts almost from scratch.

Vaulty focuses specifically on that investigation layer.

How Vaulty works

The system is organized as a multi-agent workflow.

There are five main agents:

Triage Agent

Triage determines whether the invoice actually needs investigation and identifies the type of issue that may be present.

Investigator Agent

The Investigator gathers relevant evidence and forms a hypothesis about what happened.

It can work with purchase orders, receipts, contracts, vendor history, amendments, and previous resolutions.

Resolution Agent

Vaulty doesn't stop at saying:

"There is a discrepancy."

It determines what should happen next.

Depending on the evidence, that can mean clearing the case, requesting clarification, holding payment, or proposing another resolution.

Orchestrator

The Orchestrator controls the workflow and maintains the human gate around payment release.

Reflection Agent

After a human decision, Reflection turns the outcome into organizational learning that can be used in future investigations.

The interesting part: Hindsight

The most important part of Vaulty isn't that it has five agents.

It's that the agents can learn from previous cases.

Without memory, the workflow looks like:

New case
↓
Investigate
↓
Resolve
↓
Done

The next case starts from scratch.

With Hindsight, the loop becomes:

Previous case
↓
Human decision
↓
Reflection
↓
Hindsight
↓
New case
↓
Recall previous experience
↓
Compare with current evidence
↓
Adapt investigation
↓
Resolve
↓
Learn again

Vaulty uses Hindsight as its organizational memory layer.

Hindsight on GitHub

Hindsight documentation

Memory is not the truth

This was one of the most important design decisions in Vaulty.

We didn't want the agent to behave like:

"I've seen this before, therefore I'll do the same thing again."

That can be dangerous in financial workflows.

Instead:

Memory can guide the investigation, but current evidence decides the outcome.

For example, imagine Vaulty remembers that a vendor previously had a price increase that was legitimate because an approved contract amendment existed.

A new invoice from the same vendor arrives with another price increase.

Vaulty can recall the previous experience.

But it still checks today's evidence.

If the current evidence supports the previous lesson:

Memory: CONFIRMED

If the current evidence contradicts it:

Memory: CONTRADICTED BY CURRENT EVIDENCE

The previous experience doesn't override the current purchase order or contract.

That distinction is important because organizational memory should provide context, not become an unquestioned rule.

A concrete example

Consider a clean invoice.

Vaulty checks the available evidence:

Invoice amount ₹50,000
Purchase order ₹50,000
Receipt Matches
Contract Consistent

There is no discrepancy.

Instead of escalating the case unnecessarily, Vaulty can communicate:

No issues found. The invoice matches the available purchase order and delivery evidence.

And:

Everything looks good. You can continue with the payment.

The human still controls the final payment release.

Now consider a price mismatch.

Invoice amount ₹55,000
Purchase order ₹50,000
Difference ₹5,000

Vaulty doesn't immediately assume that the invoice is wrong.

It investigates.

It can look for an amendment, contract terms, receipts, vendor history, and relevant previous cases.

The result is an evidence-backed recommendation rather than simply a discrepancy flag.

Human decisions become learning

Payment release is intentionally human-gated.

Vaulty can investigate.

Vaulty can recall.

Vaulty can reason.

Vaulty can propose a resolution.

But the final payment release remains under human control.

Once the human makes a decision, that outcome becomes part of the learning loop.

The exact implementation is wrapped inside Vaulty's memory and agent layers, but the important behavior is the loop:

investigate → decide → learn → remember → investigate better next time.

What changed after adding memory?

Before

A recurring vendor exception would require an investigator to rediscover the context.

Same vendor
↓
New exception
↓
Start investigation again
↓
Find previous information manually
After

Vaulty can retrieve relevant organizational experience:

Same vendor
↓
New exception
↓
Recall previous experience
↓
Verify against current evidence
↓
Adapt the recommendation

The improvement isn't simply that Vaulty stores more information.

The improvement is that previous decisions can influence how the next investigation is performed.

That's the behavior we wanted from agent memory.

Building the application around a single source of truth

The operational application uses a business repository as the source of truth for cases, invoices, purchase orders, receipts, contracts, amendments, and audit events.

That matters because a human decision shouldn't only change the button on the screen.

When someone approves or holds a case, Vaulty updates the persistent case state, records the audit event, updates the operational views, and feeds the outcome back into the learning loop.

So the application has a state transition rather than a cosmetic UI change:

AWAITING APPROVAL
│
├── APPROVE ──→ RESOLVED
│
└── HOLD ─────→ ON HOLD

The Case View, Home dashboard, Approvals queue, activity history, and other operational views can then reflect that state.

Why we kept payment human-gated

There is a tempting version of this project where an agent investigates an invoice and automatically releases the payment.

We deliberately didn't build that.

The agent can automate investigation and reasoning, but payment release remains a human decision.

That gives Vaulty a clear boundary:

AI investigates and recommends. Humans control financial commitment.

This also gives the system a useful audit trail: what evidence was available, what the agent remembered, what it concluded, and what the human ultimately decided.

What we deliberately didn't build

Vaulty isn't an OCR platform.

It isn't another three-way matching engine.

It isn't a generic AP chatbot.

It also doesn't depend on a simple hardcoded rule such as:

if difference > ₹5,000:
flag_invoice()

The focus was the investigation layer after the data is available.

For the prototype, invoice ingestion uses structured simulation data rather than full production-grade PDF/image OCR.

That was a deliberate scope decision.

We wanted to spend the build on the harder question:

Once an exception exists, can an agent investigate it, remember what the organization learned, and use that experience responsibly on the next case?

What I learned building Vaulty

  1. Memory is only useful when it changes behavior

A memory panel by itself isn't enough.

The interesting part is when recalled experience changes the investigation or recommendation.

  1. Memory should never blindly override evidence

Previous experience is valuable context.

It isn't current truth.

The current invoice, PO, receipt, contract, and other evidence must still be verified.

  1. Human feedback is valuable data

An approval, hold, correction, or resolution isn't just the end of a workflow.

It can become organizational knowledge for the next case.

  1. Agents need clear responsibilities

Breaking the workflow into Triage, Investigation, Resolution, Orchestration, and Reflection made it easier to reason about where memory should enter the process and where human control should remain.

  1. The real value of an AI agent can be what it remembers tomorrow

A stateless agent can solve a case.

A memory-enabled agent can potentially make the next case different because of what it learned from the last one.

What's next?

A production version of Vaulty could extend the same architecture with:

Real invoice/PDF ingestion
Enterprise ERP integrations
Stronger audit infrastructure
Production-grade access control
More sophisticated vendor-level organizational memory
More extensive evaluation of memory retrieval and investigation quality
Hybrid deterministic validation combined with agentic investigation

But the core idea remains the same:

Investigate. Resolve. Remember.

Vaulty started from a simple observation: businesses don't just accumulate transactions.

They accumulate decisions.

The interesting question is whether an AI system can turn those decisions into useful organizational memory — and then know when that memory should be trusted, when it should be questioned, and when today's evidence should win.

That's what I built Vaulty to explore.

Built with
Python
Streamlit
Multi-agent architecture
Groq / LLM reasoning
Hindsight for agent memory
Local business repository and persistent audit state
Learn more

Hindsight GitHub repository

Hindsight documentation

Vectorize — Agent Memory

Project GitHub: https://github.com/IndiraKeerthana/Vaulty-AI-Approval-Intelligencce

Top comments (0)