AI agents have started spending money for people. Kavach decides what they are allowed to do — and proves it afterwards. An AI agentA program that acts for a person — browsing, filling a cart, asking for a refund — without a human clicking each step. now turns up on both sides of the counter: one arrives at your checkout holding a MandateThe permission slip a person signs for their agent: what it may buy, up to how much, and for how long. Kavach checks every action against it. you have no way to check, and one sits inside your own dashboard issuing refunds. Razorpay solved how an agent pays. Kavach answers the question that comes first — should it?
refund rfnd_Hx9pQ2 — one refund, two different answers. The gap between them is where the same ₹5,000 gets paid out twice.
what the The railThe payment network that actually moves the money — Razorpay, then the card networks and banks behind it. Kavach sends instructions to it and cannot see inside it. says
PROCESSING
Razorpay took the instruction and sent it onward
settled by seq 17 · webhook, HMAC verified
what is still ObligationMoney you owe someone but they do not have yet. A refund stays an open obligation until something proves the customer was actually credited.
OPEN · ₹5,000
nothing yet confirms the customer actually got the money
In plain EnglishAn AI agentA program that acts for a person — browsing, filling a cart, asking for a refund — without a human clicking each step. is a program that shops, pays or issues refunds on someone’s behalf, without a person clicking each step. Kavach sits between that agent and your money. Before anything moves it checks three things — who authorised this (the buyer’s signed MandateThe permission slip a person signs for their agent: what it may buy, up to how much, and for how long. Kavach checks every action against it.), what is really in the cart, and what you already owe — then does one of three things: allow it, stop and ask a human, or refuse. Whichever it picks, it writes down the reason and the evidence, so you can check the decision later.
What you can do on this site, in the order it happens
Five minutes, ten steps, nothing to set up. Nothing here is a mock-up: every decision you see is made by the real code, every payment runs in Razorpay’s test mode (no real money), and every step is written into a tamper-evident Hash chainEach entry in the log carries a fingerprint of itself and of the entry before it. Change any old entry and every fingerprint after it stops matching — so tampering is visible. you can try to break yourself at the end.
02 — where the money goes missing
“Done” is not the same as “the customer has the money.”
In plain EnglishWhen an agent asks for a refund, the payment system replies almost instantly. That reply only means the instruction was accepted — the money can take days to reach the customer’s bank. The agent reads the reply as “done”, tells the customer so, and when the customer says the money never arrived, asks for the refund again. Two refunds leave. One was owed.
agentcreate_refund(pay_Nx3f9K2, 500000)
api200 OK {"id":"rfnd_Hx9pQ2", "status":"processed"}
agent“Done — I’ve refunded ₹5,000.”
truththe customer has not been credited, and may not be for days
Usually, Razorpay moves a refund to the processed state before receiving the ARN / RRNThe tracking number the banking network issues once a refund is genuinely on its way to the customer. Until it exists, nobody can say the money is moving. from the Gateway.
Razorpay refund documentation
what processed means
the rail dispatched it
something we can see and verify — certain
One field cannot carry both.
what the agent read
the customer has the money
not visible from here — and untrue for hours
So the customer complains again. The agent does not retry the old request — it makes a brand-new one: “the refund didn’t work, issue another.” Different words, different session, so every duplicate-blocking trick built into payment systems sees two unrelated requests. In money terms it is one debt, paid twice.
03 — the controls that exist
Every one of them guards a different door.
idempotency keystops the same request arriving twicethis is a new request, with a new key
AP2 mandatestops unauthorised spendingthe customer did authorise it. Twice.
issuing spend capstops too much going out₹5,000 again, well inside a ₹50,000 cap
MCP --read-onlystops the agent touching moneyissuing refunds is its actual job
Thirdwatchstops human fraud patternsa well-behaved agent looks well-behaved
0requests in flight₹0money nobody can yet vouch for · ₹5,000 each
Every control stops the same request twice.
None stops the same debt twice.
The question nothing on the market asks: is this brand-new request, in different words, actually money we already owe and have already sent?
03 — the shape of the fix
Sort the system by how much of it can be proven.
Signature checks and plain arithmetic at the entrance. Bookkeeping rules that cannot be broken at the exit. The AI sits in the middle, where the genuine ambiguity is — and it is only ever allowed to make the system morecareful, never less.
fixed rules — no AI, everAI — can advise, cannot decidepolicy — makes the final callopen any layer for what it cannot do
How to read thisEight layers of checking, in the order they run. Each row gives the layer’s name, what it looks at, whether AI is involved, roughly how long it takes, and whether it is already written. Click any row to see what that layer cannot do — because a layer whose limits are hidden is a layer nobody should trust.
GATE · inbound
RAIL · outbound
The order is strict: no layer is allowed to depend on one further down the list. That is also the order of how provable each layer is — certainty first, judgement last.
State, stated. ①②③④⑤⑥⑦⑧ are in the tree and under test. The timings are targets we designed to, not stopwatch readings. The only measured numbers on this page are in Evidence.
What is this agent allowed to do?
05 — four inputs, five checks, strongest rule first
TRUTHrail PROCESSINGobligation OPEN · evidence [12, 17]
Even when the AI is wrong, it can only make Kavach more careful.
Try it yourself. The duplicate-risk model gives every request a score between 0 (surely new) and 1 (surely something we already owe). Drag it to 1 and watch the decision climb toward a human. Drag it to 0 and watch nothing open up: no score can lift a spending cap, overrule a Permission tierWhether an agent is allowed only to look things up (read) or also to move money (write)., or talk its way past the bookkeeping rules. The AI can add caution. It cannot remove it.
pay_Nx3f9K2 · ₹50,000 captured · this session has spent ₹3,200 · today ₹22,400 Policy defaults from governor.Policy: autonomous limit ₹1,000 · session cap ₹5,000 · daily cap ₹25,000.
1bookkeeping rulesclear
2permission levelwrite tier
3how certain we arecertain
4duplicate-risk AIbelow threshold
5spending capswithin caps
the same five checks, running at speed
replay · made-up test data · not real traffic
allowed
0
escalated
0
denied
0
decided in this replay
0
These are invented refunds, not real ones — but the wording, the mix, and every rule being applied come straight from the shipped code. Roughly 12% of them are money already owed. A line travels across each row while the decision is open, and closes the moment the verdict lands.
and how the no-AI half chooses
Four options. It picks the cheapest mistake.
Blocking a good customer costs you a sale. Letting a bad one through costs you the cart. So Kavach does not pick a verdict off a score threshold — it works out the Expected lossThe average money each choice costs you, once you weigh what it might save against how often it goes wrong. Kavach picks the cheapest of the four. of all four options, using prices you set, and takes the smallest bar. Move the two sliders and watch the winner change.
ALLOW₹120
STEP_UP₹81
HOLD₹146
DENY₹338
EL(step_up) = c_step + p · (1 − r_step) · L
Read it as: what asking the buyer costs you, plus what still slips through when asking does not work.
c_step ₹45 — the message, plus the checkout it interrupts c_hold ₹140 — a reviewer’s minutes, plus a delayed order r_step 0.70 · r_hold 0.95 — how many bad carts each option actually catches margin 18% of cart — the profit lost when a good cart is refused
These four prices are our estimates, not measurements. They are printed here so you can disagree with them.
06 — the only place Kavach touches money
KAVACH
PROPOSEDthe intent, recorded before it is judged
APPROVEDwrite-ahead — the reservation, committed before the call
EXECUTEDsettled, carrying the refund id the rail returned
did ₹5,000 leave?
trust boundary
RAZORPAY
The payment rail. We do not own it, and nothing on this page pretends we can see past it. What follows is the honest shape of that limit:
the national payments networknot observable
the customer’s banknot observable
when the money actually landsnot observable
POST /refunds · X-Refund-Idempotency: kavach-…
201 · {"id":"rfnd_Hx9pQ2"}
Write down what you are about to do, before you do it.
Kavach saves the decision to disk first, and only then calls Razorpay. If the machine dies a millisecond later, that saved note survives and something knows ₹5,000 was about to move. A note written after the call would not have been there to find. This is called Write-aheadWrite down what you are about to do before you do it. If the power cuts mid-way, the note survives and you know what to go and check., and it is the difference between a gap you can investigate and money that vanished silently.
One request leaves, tagged so it can never be sent twice.
It carries an Idempotency keyA tag on a request so that sending it twice by accident only charges once. It stops repeats of the same request — it cannot stop a second, differently-worded request for the same thing. built from this request’s own id — kavach-<intent_id> — so if the network hiccups and we send it again, Razorpay refunds once. Note what that does not cover: an agent that asks again in different words is a new request with a new key. Which is exactly why the duplicate had to be stopped further upstream, before it ever got here.
Razorpay answers. We record that answer — we don’t believe it.
A success response carrying a refund id means the gateway accepted the instruction and sent it onward. It does not mean the customer has the money. So the reply is filed as one more piece of evidence, and the debt stays open until something actually proves it was paid.
In the gap between those two steps, the server can die.
Then our records say “about to pay” and nothing in them knows whether ₹5,000 actually left. No amount of retrying or clever ordering closes that gap — it is a fact about talking to another company over a network. It closes one way only: by going and looking, which is what chapter 08 does.
07 — the other side of the boundary
Theonlylegwecanproveistheshortone.
One hop is ours: our request to Razorpay and its signed reply, both written into our own log. Everything after that belongs to banks and clearing systems we have no connection to, running on a schedule nobody tells us. The five threads on this map are where your ₹5,000 might currently be. Kavach will not pick one and call it the answer — it says AMBIGUOUS, out loud, and refuses to guess.
we can see this
1 leg · signed at both ends
we cannot see these
5 legs · nothing reports on them
One bank on each of five continents, drawn to show the proportion rather than a real route — nothing in our log names a destination, so nothing here does either. An agent that reads processed as the customer has the money has just described all five of those unlit threads as if they were the one lit one.
08 — don’t trust what you asked for; check what happened
webhook · refund.processed · sig_verified
intentsAPPROVEDour reservation, written before the call
providerrfnd_Hx9pQ2notes.intent_id matches the key we sent
event logseq 17refund.processed · HMAC verified
intent EXECUTED · result_id rfnd_Hx9pQ2 · reconciled against the rail
obligation OPEN · ₹5,000 — no event states the customer was credited
The truth arrives on its own schedule.
Razorpay sends a WebhookA message the payment provider sends you when something happens — "refund created", "payment failed". It arrives whenever it arrives, sometimes hours later. — a “this happened” message — minutes or hours later. Before Kavach reads a single word of it, it checks the HMAC signatureA short code attached to a webhook that proves it really came from Razorpay and was not faked or edited on the way. proving the message really came from Razorpay. A message that fails that check never becomes trusted evidence; it is filed as an unverified claim and labelled as one.
And when nothing arrives, we go and look.
Anything still marked “about to pay” past its deadline gets swept up: Kavach asks Razorpay directly which refunds exist on that payment, and matches them using the id we attached on the way out. Matching on our own id is a fact. Matching on amount and timestamp would be a guess — and guessing is how you refund twice.
Three records. One question settled — and one still open.
The request settles: the money did leave, and it stops counting as unknown exposure. The debt does not close, because still nothing says the customer was credited. Holding those two apart, instead of collapsing them into one “done”, is the entire product.
one refund, read end to end
Thenextninehundredandtwenty-fivedonotgetread.
About 12% of them ask for money that has already been sent. The other 88% are ordinary, legitimate work — and a system that blocks those has not helped anybody.
09 — measured, on cases the model had never seen
Samehumancost.Thirteentimeslessmoneyoutthedoor.
Any system can catch every duplicate by sending every request to a human — and no merchant would run it. So this test forces all five systems to interrupt exactly the same number of people, and then asks the only question left: with the same staff cost, how much money still walked out the door?
Reading the tablePrecisionOf everything the system flagged, how much really was a problem. Low precision means it interrupts people for nothing. — of everything it flagged, how much really was a duplicate (higher is fewer false alarms). RecallOf everything that really was a problem, how much the system caught. Low recall means money leaves quietly. — of the real duplicates, how many it caught (higher is less missed). Escalated — how often a human is interrupted, held equal on purpose. Leaked — the money that got paid twice anyway. That last column is the one that matters.
Duplicate-obligation detection on 925 held-out intents at a fixed review budget
system
precision
recall
escalated
leaked
B0 escalate everythingsend every single request to a human — catches everything, and no merchant would run it
0.166
1.000
100.0%
₹0
B1 exact text matchflag it only if the wording matches letter for letter — real duplicates are reworded, so it finds none
0.000
0.000
0.0%
₹0
B2 rule: amt+open+24hsame amount, still open, within 24 hours — what a good engineer writes without any AI
0.187
0.221
19.7%
₹0
B3 learned, no textAI, but it is never shown the reason the agent gave
0.659
0.779
19.7%
₹0
B4 learned + reads textAI that also reads the reason text — this is Kavach
0.813
0.961
19.7%
₹0
B2 and B4 escalate the same 19.7% — identical human cost. The rule leaks ₹1,84,636. The model leaks ₹14,257.
how many customers you are willing to interrupt — and what it buys you
escalated
0.0%
recall
0.000
precision
0.000
still leaked
₹0
What these numbers are not.
The test data is made up. It was built to be hard — duplicates reworded so no text match finds them, near-identical amounts designed to fool a rule — but it is not real merchant traffic.
“12% of requests are duplicates” is an assumption, not a measurement. No public figure exists. The slider above exists so you can see what happens if we guessed wrong.
Precision 0.813 means roughly one escalation in five delays a perfectly good refund. That is a real cost to a real customer, and it is why the system asks a human rather than refusing outright.
B1 scoring zero is the test working as designed: duplicates here are reworded, so matching text letter-for-letter finds nothing. We get no credit for beating a deliberately weak opponent.
10 — the shared record
Everyfactcitestheeventsbehindit.
Kavach never simply stores a conclusion. Every statement it makes is worked out, on the spot, from an Append-only logA record you can only add to, never edit or delete. Every fact Kavach states points back to the entries in it. — a record you can add to but never edit or delete. Run the same decision again months later against the same events and you get the same verdict, with the same reasons. That is what you need when a bank asks you to justify a payment an AI made.
what each step of this page wrote into the log
INTENTan intents row, PROPOSED, before anything judges it
TRUTHa FinancialFact citing events [12, 17]
OBLIGATIONexposure recomputed from the log, never stored
RISKscore 0.951, recorded as advisory
GOVERNORESCALATE, with the reasons that produced it
PROVIDERone request, keyed kavach-<intent_id>
WEBHOOKseq 17, sig_verified over the raw body
RECONCILEEXECUTED, matched on notes.intent_id
PROOFSHA-256 over every row and its predecessor
The final fingerprint is recomputed live in the console, not printed here. A hash typed into a static web page proves nothing about the records it claims to cover.
What this does and does not proveA tamper-evident log proves that nobody quietly rewrote the history after the fact. It does not prove the history was true when it was written — a mistake recorded honestly is still a mistake. Kavach states both, in the same breath, below.
proves
the ordered event log has not been altered since it was written: every row reproduces its stored SHA-256 over its own immutable fields and its predecessor's hash
does not prove
who wrote an event. Provenance for rail events comes from the HMAC signature check on the webhook, recorded separately as sig_verified
limit
an attacker with write access could rewrite the chain from the point of an edit forward. Externally anchoring the head would close that, and is not implemented
the evidence behind the refund this page opened with
The debt is still open because nothing in the record closes it — not because some model had a hunch.
DERIVED_CERTAIN
a signed, verified message says this in so many words
DERIVED_PROBABLE
worked out indirectly, or from a source we cannot verify
UNKNOWN
the evidence contradicts itself, or has gone silent too long — and Kavach says so rather than assuming nothing changed
how you would actually install it
Kavach ships as an MCPModel Context Protocol — the standard way an AI agent is handed a set of tools it may call. Kavach ships as one of these tool servers, so an agent can use it without any code change. server using the same tool names Razorpay’s own already uses. Adopting it is one line of config — the agent’s code does not change at all. The difference is what comes back: answers that separate what the rail did from what the customer got, and tools that are allowed to say no.
fetch_paymentread-onlya FinancialFact, not a raw entity
fetch_refundread-onlyrail state and obligation state, separately
list_open_obligationsread-onlywhat money is still in flight
check_refundread-onlythe verdict, without acting on it
create_refundwritebounded, write-ahead, idempotency key from the intent id
approval_queueread-onlywhat is waiting on a human
audit_trailread-onlythe events behind every decision
verify_audit_trailread-onlycryptographically verify the event log integrity
verify_agentread-onlythe delegation envelope, checked over the raw bytes
admit_cartread-onlydoes this cart entail the mandate it arrived under?
create_payment_linkwritea request for money, recorded before it is sent
fetch_payment_linkread-onlythe link and the payments made against it
create_orderwritean order for Checkout, recorded as an event
fetch_orderread-onlythe order, as the rail reports it
Everything except create_refund is marked read-only: checking and verifying move no money at all. create_refund is the single tool that can, which is why it is also the single tool that can refuse.
11 · ENTER
Everythingaboveischeckable—bydoingit.
Everything behind these three doors runs the same code this page has been describing — the same rules, the same checks, the same models. Nothing is a mock-up. Where a screen is showing a fixed demo instead of live data, it says so on the screen.
01
Take the five-minute tour
Hand an agent a budget, watch it try to spend beyond it, watch Kavach stop it, approve the borderline case on your phone, pay for real in test mode — then try to tamper with the evidence and see it caught.
The merchant’s control room: what money is still owed, what is waiting on a human, the tools agents can call, eleven ways to attack the system, and the tamper-check run live in front of you.