cookbook proof · duplicate-payment-guard
Duplicate payment
An AP agent retries a $10K payment ten times on a flaky connection.
OpenClaw PAY_INVOICE
without kiff $100,000 10 debits on one invoice. Every retry pays again.
PAY_INVOICE state-aware gate ↓
with kiff $10,000 1 debit allowed. 9 retries refused.
1 Agent proposes
PAY_INVOICE on a Invoice.2 KIFF reads the Invoice's current state — before anything runs.
3 First call: state allows it → executed, receipt signed.
4 State is now
PAID → every repeat refused, receipt signed.The scenario
An agent pays a $10,000 invoice. A flaky connection drops the success response, so the transport retries the same call ~10 times. Each call is individually legitimate — same invoice, same amount — but only the first should ever debit.
Why it was refused
After the first debit the invoice advances to PAID. PAY_INVOICE is allowed only while the invoice is PENDING, so every retry is refused with state_not_allowed. A state-aware gate stops the emergent repeat that no single call looks guilty of.