Reconciliation is the best first domain for agentic AI in finance, and almost everyone picks it for the wrong reason. The attraction isn't "AI matches records" — a deterministic matcher already matches 95-98% on exact keys, for free, in milliseconds. The attraction is the residual: the 2-5% of breaks where a human spends 12-20 minutes reading two systems, forming a hypothesis, and writing an audit-grade explanation. This builds that agent end to end in LangGraph — with one cardinal rule enforced throughout: the LLM explains breaks; it never posts to the ledger.
Full original (canonical) on PrepStack: https://prepstack.co.in/blog/agentic-ai-reconciliation-break-resolution-langgraph
TL;DR
| What | How |
|---|---|
| Matching | Deterministic engine (exact + tolerance) — no LLM |
| Triage | Haiku classifies each break into a fixed taxonomy |
| Evidence | Read-only typed tools gather both sides + history |
| Explanation | Opus drafts hypothesis + rationale as a Proposal (data) |
| Grounding | Every claim must cite evidence IDs or the output is rejected |
| Execution | A human approves; a deterministic service posts adjustments |
| Audit | Hash-chained, signed log entry per break |
1. Matching is not an AI problem
The naive build feeds both files to a model and asks it to pair them. It's seductive in a demo and catastrophic at volume: non-deterministic pairings, token cost scaling with file size, no tolerance semantics, and — worst — unexplainable matches. "The model felt they matched" is not an answer an auditor accepts.
# Deterministic, auditable, free. Runs in the ETL layer BEFORE any agent exists.
def match_records(ours, theirs):
matched, breaks = [], []
theirs_by_key = index_by(theirs, key=lambda t: (t.ref, t.ccy))
for o in ours:
candidate = theirs_by_key.get((o.ref, o.ccy))
if candidate and abs(o.amount - candidate.amount) <= tolerance(o.ccy):
matched.append((o, candidate))
else:
breaks.append(Break(our_txn=o, their_txn=candidate,
kind="unmatched" if candidate is None else "amount_mismatch"))
return MatchResult(matched=matched, breaks=breaks)
The agent's input is the Break object, never raw files. If your matcher only clears 80%, fix keys/normalization/tolerances before buying tokens for breaks a regex would have prevented. Representative: deterministic matching clears 95-98%; the agent prices out at the residual 2-5% only.
2. Break triage — a small model, a closed taxonomy
Not every break deserves Opus. Triage classifies each into a fixed taxonomy on Haiku, because classification into known buckets is a decision, not reasoning.
TAXONOMY = ["timing", "fx_rounding", "fee_one_side", "duplicate", "unknown", "suspected_fraud"]
async def triage_break(brk):
result = await haiku.ainvoke(triage_prompt(brk), response_format=TriageLabel)
if result.label == "suspected_fraud":
await escalate_to_human(brk, reason=result.rationale) # no drafting, no delay
return result.label
The taxonomy is closed — the model picks from an enum, it can't invent categories. And suspected_fraud short-circuits: you never want an LLM helpfully drafting an innocent explanation over a fraud signal.
3. Evidence gathering — read-only, typed, sourced
The investigator gathers everything a human would open in four tabs — through read-only tools. There is no write tool in this agent's toolset. Every evidence item carries a source and an ID.
@tool
async def get_our_txn(ref: str) -> Evidence:
txn = await ledger.get_txn(ref)
return Evidence(id=new_id(), source="ledger", payload=txn.model_dump())
@tool
async def similar_resolved_breaks(brk: Break, k: int = 5) -> Evidence:
cases = await recon_history.similar(brk, k=k) # embeddings over past resolutions
return Evidence(id=new_id(), source="recon_history", payload=cases)
The history tool is the quiet workhorse: most breaks rhyme with past breaks. Representative: with history retrieval in the evidence set, unedited-draft acceptance rises from ~55% to ~80%.
4. Hypothesis — Opus, structured, cited
Opus receives the break, the taxonomy label, and the evidence set, and must return a typed proposal whose every claim cites evidence IDs.
class BreakExplanation(BaseModel):
hypothesis: Literal["timing", "fx_rounding", "fee_one_side",
"duplicate", "data_error", "other"]
explanation: str
cited_evidence: list[str] # evidence IDs backing the explanation — REQUIRED
is_adjustment: bool
adjustment: AdjustmentDraft | None = None # typed, validated amounts/accounts
confidence: float
Force the citation. Allow "I don't know" (hypothesis="other" routes to a human with evidence pre-gathered — still a win). And never let the model compute the adjustment loosely: AdjustmentDraft is re-validated in code (debit==credit? valid account? amount == break delta?).
5. The grounding guardian — no citation, no draft
def guard_explanation(proposal, evidence):
known = {e.id for e in evidence}
cited = set(proposal_citations(proposal))
if not cited:
raise Rejected("explanation cites no evidence")
if not cited <= known:
raise Rejected(f"cites unknown evidence: {cited - known}")
if proposal.payload:
validate_adjustment(proposal.payload) # debit==credit, valid accounts, delta match
return proposal
Cheap, deterministic, and it catches the failure mode that scares compliance: a fluent, confident, invented explanation. Representative: the guardian rejects ~2-4% of drafts — every one a hallucination that never reached a human.
6. The approval gate — the only writer
from langgraph.types import interrupt
async def resolve_node(state):
proposal = state.proposals[-1]
if proposal.requires_human:
decision = interrupt({"break_id": state.current_break_id,
"proposal": proposal.model_dump(), "needs": "approve|reject|amend"})
if decision["action"] != "approve":
return record_rejection(state, proposal, decision)
state.approvals[state.current_break_id] = decision["approver"]
if proposal.action == "post_adjustment":
await ledger.post_adjustment(proposal.payload) # validated, typed, idempotent
else:
await recon.close_break(state.current_break_id)
return append_audit(state, proposal, result="executed")
The analyst's job changed from investigating to reviewing — that's where 12-20 minutes becomes 2-4. Every break gets a hash-chained, signed audit entry: timestamp, break ID, evidence IDs, rationale, model + prompt version, approver, result.
Representative metrics
| Metric | Manual | Agentic (propose + approve) |
|---|---|---|
| Time per break | 12-20 min | 2-4 min |
| Breaks with one-click draft | n/a | ~70-85% |
| Explanation groundedness | analyst-dependent | enforced: cite or rejected |
| Audit completeness | ad-hoc notes | 100% — signed entry per break |
| Fraud-signal handling | analyst judgment | structural short-circuit, zero drafting |
When NOT to build this
- Match rate under ~90% — fix normalization/keys/tolerances first.
- Tiny break volume — this is a volume play.
- No golden set — no labeled resolutions means no evals.
- Unreliable sources — the agent will confidently explain data-quality bugs.
- Tempted to auto-post "high-confidence" adjustments — that's the cardinal rule breaking under convenience pressure.
The one mental shift: the agent is a break analyst, not a bookkeeper. Its entire job is to read evidence and draft an explanation a human can approve in one click. The moment you let it post to the ledger "because it's usually right", you've traded an audit-proof workflow for a non-deterministic component on the money path.
Originally published on PrepStack.
Top comments (0)