I am an auditor, not a software engineer. I wanted to know whether AI agents could run a monthly procure-to-pay controls review to a standard I would sign, so I built one and then tried to break it.
The result: 31 planted exceptions, 31 handled exactly as the answer key expects, and no false findings sent to a control owner. This article explains how it works, how it was built, and where its limits are. The limits matter as much as the score.
One thing first. Everything in this experiment is fictional. The company, its vendors, people, bank details and amounts are invented. No employer data was used. That was a deliberate choice, and I come back to why at the end.
The question I wanted answered
Most "AI in audit" demonstrations show a model reading a document and summarising it. That is useful, but it is not auditing. An audit finding has to be reproducible. If I show a CFO a duplicate payment, I must be able to show the two documents, the amount, and the test that found them, and get the same answer tomorrow.
Language models are not built for that. Ask the same question twice and you can get two different answers. So the real question was narrower than "can AI audit?" It was: can I design a system where AI does the work it is good at, and is structurally prevented from doing the work it is bad at?
The test bed: a company where I know every answer
You cannot grade an auditor unless you know what is in the books. So before building any agent, I built the company.
Wadi Daqa Biscuits & Confectionery is a fictional manufacturer in Muscat, with a plant, four sales depots and export distributors across the GCC. I generated five months of procure-to-pay activity for it, January to May 2026:
- 49 vendors
- 250 purchase orders and 243 goods receipts
- 423 invoices, around half a million rials a month
- 363 payments
Into that data I planted 31 exceptions on purpose, each one recorded in an answer key with the expected amount, severity and control owner.
Then I added the part most demonstrations skip: 10 look-alike traps. These are transactions that look wrong and are actually fine. A caterer who bills the same fixed fee twice a month. An invoice that resembles a duplicate but belongs to a different delivery. A system that flags all of these is not an auditor. It is a noise generator, and control owners stop reading its emails within a month.
The twelve tests
The detection logic is twelve tests that any accounts-payable auditor will recognise:
- Same invoice paid twice
- Near-duplicate invoice, such as a typo in the reference
- Same invoice billed by two vendors
- Invoiced quantity above quantity received
- Paid with no goods receipt at all
- Invoice price above the purchase order price
- Purchase order price above the contract price
- Purchase order raised after the invoice arrived
- A large purchase split to stay under an approval limit
- Bank details changed shortly before a payment
- Payment to a blocked or inactive vendor
- Paid early with no discount taken
Each test is fixed SQL. Same data in, same answer out, every time. There is no AI inside any of them. Before any agent existed, I ran the twelve rules alone against the answer key to prove they worked. Only then did I build the agents around them.
The one rule: AI explains, code decides
This is the design decision everything else rests on.
The AI may: explain a finding in plain English, cite the evidence rows, critique a weak argument, and write the summary each control owner receives.
Code must: run the tests, calculate every amount, score severity, assign the owner, and re-run evidence to verify it.
Never left to the AI: deciding that an exception exists, any amount, date or count, the severity, who owns it, or whether a finding is closed.
A person signs off every month before anything is sent.
The important word is structurally. This is not a prompt that asks the model to behave. The system compares every number in a finding against the rule engine's own output and rejects anything that differs, whatever the narrative says. The model has no tool that can write a number.
Four agents and a gate after each one

The pipeline runs once a month, in four stages.
The Data Agent extracts ten tables from the ERP as at month-end, masks bank account and tax numbers, reconciles row counts and totals back to the source, runs data-quality checks, and seals the snapshot with a hash. Every later step works on that exact sealed copy.
The Analytics Agent runs the twelve tests on the snapshot, builds each finding with its amount, severity and evidence, and writes a plain-English explanation.
The Reviewer Agent does not trust the Analytics Agent. It re-runs the evidence for every finding and checks the result matches. It recomputes the amount independently. It looks at the live ERP to see whether anything changed after the cut-off, such as a refund or a late goods receipt. It checks that every document number mentioned in the explanation actually exists in the evidence. It can reject a finding or send it back for rework. It can never edit one.
The Reporting Agent groups approved findings by control owner, builds one pack per owner, holds the packs until the audit lead releases them, sends each once, and records the owner's response.
No agent talks to another directly. Each hands a sealed package to an orchestrator, which validates it before the next agent may start. The orchestrator contains no AI at all.
People make three kinds of decision. A data steward steps in only if the data is blocked. An audit senior steps in only if a finding is stuck. The audit lead releases the packs every month, without exception.
How I tried to break it
A system that only works when nothing goes wrong has not been tested. So I injected faults.
February: a made-up explanation. I forced the explanation of one finding to cite a purchase order number that did not exist, simulating an AI hallucination. The Reviewer's grounding check caught the unsupported reference and sent it back. The second attempt passed.
February: a duplicate that was already refunded. One duplicate payment was refunded two days after month-end. The snapshot still showed it as a problem. The Reviewer's live spot-check saw the reversal and stopped the finding. Nobody received an alert about money that had already come back.
March: damaged data. Nine invoices lost their vendor reference in a simulated scanning error, so they could not be tested for duplicates. The run continued, and the accounts-payable manager's pack said so in plain words: these nine could not be tested. A silent gap in coverage is worse than a finding.
April: an extract that quietly stopped early. The goods-receipt extract ended on the 27th. Testing on it would have produced a wave of false "paid without receipt" findings. The Data Agent blocked the run until a data steward chose to re-extract.
May: a finding the agents could not settle. Goods arrived two days after the cut-off. The Reviewer asked for more evidence, the rework could not change the sealed snapshot, and the system recognised it was making no progress. It escalated to a person, who rejected it as a timing difference.
In every case, the bad output never reached a control owner.
The results

Across the five months:
- 31 of 31 planted exceptions handled as the answer key expects
- 25 findings sent to control owners, worth about 110,000 rials of exposure
- 6 correctly stopped before reaching anyone: four by an approved exclusion, one refunded after cut-off, one timing difference
- 0 false findings across the ten traps
The largest single item was the one auditors worry about most: a vendor's bank details changed shortly before a payment of 27,615 rials.
It gets sharper each month
The twelve tests never change on their own. What changes is the context around them.
In January, the system flagged the caterer's twice-monthly invoices as a near-duplicate. The control owner replied that both were valid. The audit lead approved a formal exclusion, and from February onward the Reviewer stopped that pattern, citing the exclusion by number. The lesson went through a person and into a register. The system did not quietly rewrite its own rules.
Repeat offenders are scored higher. A vendor whose purchase order was raised after the invoice in January, and again in March, moved from medium to high severity the second time, with the history stated in the explanation.
What it missed, and why that is the best finding
In April, a duplicate vendor record was created. None of the twelve tests looks at vendor master data on its own, so nothing was flagged. In May, the same invoice was paid under both records, 12,600 rials, and the duplicate-payment test caught it after the fact.
The system caught the consequence, not the cause. A thirteenth rule on vendor master data would have caught it a month earlier. I left that gap visible in the write-up because that is what an honest test bed is for: it shows you where your rule set is thin before real money does.
How I actually built it
I did not write this code line by line. I built it with Claude, in the way people now call vibe coding, but with an auditor's discipline about the order of work.
- Architecture first. Before any code, a full design document: the principles, what each agent may and may not do, the format of every handoff, the human decision points, the failure modes.
- The answer key before the agents. The fictional ERP and its planted scenarios came first, so that every later step could be graded.
- Rules proven alone. The twelve tests had to pass against the answer key with no AI involved.
- Agents with written instructions. Each agent has an operating document, like a work programme: its tools, its procedure, its decision table, and what it must never do.
- Break it on purpose. Hallucinations, truncated extracts, late-changing data, a simulated crash and resume.
- A scorecard, not an impression. Every run ends with an automated comparison against the answer key.
My contribution was not the Python. It was knowing what a reviewer checks, what a control owner will tolerate, what an audit trail must contain, and when a person has to decide. That is audit judgement, and it turned out to be the scarce input.
Every run also keeps a log in which each event carries the hash of the one before it, so the trail cannot be altered without detection, and any finding can be replayed later from its stored evidence.
What this does not prove
This is synthetic data with known answers. Real systems are messier than any test bed.
- The ERP is simulated. Real extracts, real master data and real volumes will produce problems I have not imagined.
- Every document here has a single line. Real invoices do not.
- Delivery writes packs to a folder. It does not yet send email or sit inside a case-management tool.
- A perfect score on planted exceptions says the system finds what I knew to plant. It says nothing about what I did not think of.
I used fictional data for a reason. An experiment with AI agents has no business touching live vendor and payment data until the design has been shown to hold. The next step is a controlled run on a real ERP, with the same answer-key discipline wherever possible.
Three things I would tell another auditor
Decide what the AI is not allowed to do before you decide what it does. The permission list was the most valuable page in the design.
Build the traps, not just the errors. Catching 31 exceptions is easy to demonstrate. Staying silent on ten things that only look wrong is what earns trust.
Keep people where judgement lives. The three human decision points are not a concession. A timing difference and a control failure can look identical in the data, and someone accountable has to say which one it is.
Which control would you hand to an agent first? And which one never?