Skip to content

How to Test AI Agents Before Production

How to test AI agents before production: build a sample-file test set, set pass thresholds by risk, and gate go-live. Includes an illustrative cost model.

Dheeraj GuptaFounder, Anthiva7 min read

TL;DR: Test an AI agent the way a bank tests a new control. Build a test set from your own files (about 200 is enough to start), label the right answers, run every file more than once, and set pass thresholds by the cost of each kind of error. A named person signs off, and the agent goes live only when it clears the gate. Skip the gate and you find the errors in production, where they reach payments, customer letters and filings.

Generic benchmarks tell you how a model does on someone else’s tasks. A sample-file test tells you whether this agent will handle your invoices, statements and claim packs without sending errors downstream.

This matters commercially. Gartner predicts that over 40% of agentic AI projects will be canceled by the end of 2027, citing escalating costs, unclear business value or inadequate risk controls. A pre-production gate addresses all three: it puts a number on value, caps rework, and leaves evidence for risk and audit.

Why do AI agents fail after a good demo?

A demo uses clean, cherry-picked inputs. Production sends scanned pages at an angle, a file with a missing page, a carrier invoice in a layout nobody has seen, and a customer who changes the question halfway through a chat. The agent that looked perfect on ten files meets the real mix and fails on the tail.

The business effect is concrete. Wrong values reach approvers, who stop trusting the output and recheck everything, which erases the hours the agent was meant to free. Or wrong values slip past review into a payment, a customer letter or a filing. Either way the cost of the error is paid after launch, when it is most expensive.

What do the top testing guides cover, and what is missing?

The common guides are good on method. IBM’s AI agent testing overview lists component tests, trajectory tests and end-to-end tests, plus scoring by a large language model (LLM-as-a-judge) and simulated environments. Splunk’s agent testing guide adds repeated trials and release gates, and makes a point worth keeping: thresholds should be “tied to real failure costs, not arbitrary round numbers.”

What a regulated back office still needs is the part around the method:

Need Typical guide What to add
Test data Generic benchmarks, synthetic cases Your own files, including the ugly ones
Pass criteria Example targets such as an overall success rate A threshold per field, set by cost of error
Go-live decision “Meet the bar for deployment” A written gate with a named signer
Evidence Test dashboards A stored result tied to the agent version, for audit
Human review Recommended Approval of the gate, then approval of each decision

What goes into a sample-file test set?

Start with about 200 files per workflow. Fewer than that and one odd file moves the result too much. More is better once the first gate is passing. Mix them on purpose:

Group Files What it checks
Typical 120 The normal case, in the proportions you really see
Messy 50 Skewed scans, low resolution, handwriting, stamps over text, missing pages
Exceptions 20 Cases that should be sent to a person, not decided
Wrong inputs 10 A document of the wrong type, a duplicate, a file with nothing usable

A person who does this work today labels the correct answer for each file: the values, the decision, and whether it should have been escalated. Keep the labeled set out of sight of whoever tunes the agent, and refresh it each quarter so it does not go stale. The exceptions and wrong inputs matter most. An agent that always answers is dangerous. One that says “this needs a person” is the one you can trust.

What pass thresholds should you set?

Set thresholds per field and per decision, not as one overall score. A 97% average hides the fact that the 3% of misses may all be on the payment amount. The example below is a starting point for a document-heavy back office. Change the numbers to fit your own cost of error.

Check Example gate Why
Amounts, account numbers, dates 99% or better, zero silent errors A wrong payment is expensive and hard to reverse
Descriptive fields 95% or better Errors are cheap to correct at review
Correct escalation on exception files 100% of the 20 Missing an exception is the worst failure
Wrong-input files rejected or flagged 100% of the 10 Prevents garbage in, decision out
Repeat consistency Same answer on 3 of 3 runs All trials must succeed, not any one
Every value shows its source location 100% A reviewer can check it in seconds

“Silent error” means a wrong value that the agent presented as confident and did not flag. A wrong value that was flagged for review is a cost, but a bounded one.

How does it work step by step?

The gate runs the same way every time, so a result today can be compared with a result next quarter.

  1. 01Describe the process; the agent is built as a readable workflow
  2. 02Load your labeled sample files, answers hidden from the agent
  3. 03Run every file more than once and compare runs
  4. 04Score each field against the written thresholds
  5. 05Block or release: no pass, no go-live
  6. 06Record the result with the version; a named approver signs the release

A team writes the process in plain words, and Anthiva builds the agent as a readable workflow, so each rule can be checked by the people who own the process. Agentic vision AI reads the scans, PDFs and photos, and every miss is shown next to the source value. If the agent fails, the team fixes the workflow and reruns the whole set. After launch, every decision goes to a named person with the source beside each value.

You can see how this works on the tests page, how sign-off works on approvals, and how the agent is built on the platform page. The same gate applies in lending and logistics back offices.

What is the business case? An illustrative cost model

This is a model, not customer data. Replace every input with your own.

Formula: monthly error cost = documents per month × share handled wrongly × cost to correct one after the fact

Input No gate With sample-file gate
Documents per month 10,000 10,000
Share handled wrongly in production 6% 1.5%
Cost to correct one error after the fact $25 $25
Monthly error cost $15,000 $3,750

The gap is $11,250 a month, or $135,000 a year, for one workflow. The 6% and 1.5% rates are assumptions chosen to show the mechanism: a test set finds most failure patterns before customers do, so fewer of them reach production. The $25 figure assumes about 30 minutes of staff time per correction at a loaded rate of $50 an hour. Your own pilot data will give better numbers than these.

The model leaves out the larger costs: a payment sent in error, a regulatory finding, or a launch that is pulled back and costs the program a quarter.

When should the agent be retested?

Retest on any change to the workflow, the model, the prompt or the upstream document formats, and on a fixed schedule even when nothing changed. A carrier that redesigns its invoice or a bank that updates a statement layout breaks an agent that passed last quarter. Keep a small regression set of the files that failed before, and run it on every release.

Frequently asked questions

How do you test an AI agent before production?

Build a labeled test set from your own files, run each file several times, score per field against written thresholds, and release only when the agent clears the gate. Keep the result with the agent version.

How many test cases do you need?

About 200 per workflow is a practical start. It is enough to cover typical, messy, exception and wrong-input files in proportion. Add more as you find new failure patterns.

What accuracy should an AI agent reach before go-live?

It depends on the cost of the error. A common pattern is a very high bar on money and identity fields with zero silent errors, a lower bar on descriptive fields, and 100% correct escalation of exceptions. Set the numbers with the process owner and risk, and write them down.

Can an AI model grade the agent’s output?

It can help with open-ended text, but judge models make mistakes of their own, so calibrate them against human labels. For fields with a known right answer, use exact checks, not a judge.

Do we need synthetic data?

Synthetic files help with rare edge cases, but they should not replace real files. The messy real-world mix is what breaks agents, and it is hard to invent.

Who should approve the release?

The process owner and a risk or control owner, by name. Their sign-off, with the test result and the workflow version, is the evidence an auditor will ask for later.

How often should we retest?

On every change to the workflow, model or prompt, when upstream document formats change, and on a regular schedule. Run a regression set of past failures every time.

Does testing remove the need for human approval after launch?

No. The gate lowers the error rate before launch. Approval handles the cases that remain. In Anthiva, every decision still goes to a named human approver with the source beside each value, and an audit trail records who decided, when and why.

Want to see the gate run on your own files? Bring one job and a sample set. Leave with your own numbers. Book a demo.

See it on your own files.

A working session on your sample files. You leave with your own run time and first-pass rate.