AI Agent Guides 9 min read

How to Test an AI Agent (Before It Touches Real Data)

Three stages, end-state checks, repeat runs and a test sheet you can copy.

Test an AI agent in 3 stages: replay past tasks, run with writes held, then a small live slice. Outcome checks, repeat runs, chatbot tests, a checklist.

Shabnam Katoch

Growth Head

How to test an AI agent before it touches real data: replay past tasks, hold every write, release to a small slice, and score repeat runs with pass^k

Test an AI agent in three stages: replay a fixed set of past tasks and check the results, run it against your real systems with every write held for a person, then release it to a small slice of real work with a kill switch. At each stage, check the end state in the destination system, not the agent's own summary.

Run each test more than once: an agent that passes 75% of the time passes three runs in a row only about 42% of the time (Anthropic).

StageWhat runsMove on when
1. Replay20 to 50 past tasks, three runs eachTasks that write pass 3 of 3
2. Writes heldReal systems, writes queued for a personQueued writes stay right
3. Bounded releaseA small slice, a daily cap, a kill switchZero wrong writes for N days

Picture this: your support agent posts "Refund issued, customer notified." The email went out. The refund didn't.

So what did my tests actually check?

Why an AI agent needs a different kind of test

Ordinary software gives the same output for the same input, and crashes when it breaks. An agent can take a different path every run, and its failures are side effects: a wrong email sent, a record overwritten, a "done" that wasn't.

So test capability (can it do the task?) separately from side effects (what can it change?). This guide covers testing AI agents you build, not AI agents that test software.

What AI agent testing should check

TestWhat it catchesExample
OutcomeWrong end stateYour own check reads the new value in the CRM
PathWrong tools or orderThe update ran once, before "done"
RestraintActing when it should stop"Refund $5,000" with no approval: it asks
CostTokens, calls, retriesCost per task under budget
DeadlineSlow or stuck runsDone within 2 minutes; timeouts logged

The first three are pass or fail. Set cost and deadline budgets before the first run (see what an AI agent costs per task).

Test an AI agent in three stages

Test an AI agent in three stages: replay past tasks in test accounts, run on real systems with writes held, then a bounded release with a daily cap and a kill switch

Stage 1: Replay past tasks

Build a set of past tasks, each with its expected end state, and re-run it whenever the prompt, model or tools change. Anthropic: "20-50 simple tasks drawn from real failures is a great start."

Take them from last month's tickets and emails, plus awkward ones: an edge case, a tool error, a case where stopping is right.

Run each task in test accounts from a clean start, since leftover state "can cause correlated failures," Anthropic warns. After launch it's your regression suite, the first thing to re-run when you migrate an agent between LLM providers.

Stage 2: Real systems, writes held

Point the agent at your real inbox, CRM or help desk. Reads run; every write, send, delete or permission change waits for a person.

Have the agent list its intended writes first, check them against the task's allowlist, and fail anything off it. Track how often a queued write was right as proposed, and turn every rejected write into a Stage 1 case.

Approvals still matter after launch: see human approval without killing speed.

Stage 3: A bounded release

Release it to a small slice: one label, queue or segment. Cap writes per day and keep a one-click kill switch.

Start read-only if you can, then the smallest write scope that proves the path. Widen once the days you set in advance (five working days, say) pass with zero wrong writes and steady cost.

Check the outcome, not the agent's summary

Anthropic defines the outcome as "the final state in the environment at the end of the trial": an agent "might say 'Your flight has been booked'... but the outcome is whether a reservation exists in the environment's SQL database."

"Done" is a claim. The record is the evidence.

So make the read-back your grader: the agent returns the IDs it changed, your client reads them, and a mismatch fails the run, even after a 200:

# illustrative: swap in your own agent call and CRM client
result = run_agent(task)                     # must return the IDs it changed
assert result.changed_ids, "no ID, no pass"
for record_id in result.changed_ids:
    record = crm_client.get(record_id)       # your client, not the agent's tool
    assert record.stage == task.expected_stage

Check the outcome, not the agent's summary: the agent says done and the API returned 200, but the read-back finds zero rows changed and the test fails

Keep path checks narrow. Anthropic found exact tool-sequence checks "overly brittle," yet τ-bench notes a correct end state "might be a necessary but not sufficient condition": an agent can issue a return without the user's confirmation.

So check only hard rules: approval before the write, one write, no sends in a test. Production read-back is covered in how to check an agent actually did the task.

Run it more than once (pass@k vs pass^k) and give it a deadline

Anthropic defines pass@k as "the likelihood that an agent gets at least one correct solution in k attempts." The τ-bench paper (Sierra, June 2024) introduced pass^k: "the chance that all k i.i.d. task trials are successful, averaged across tasks."

Anthropic's example: "If your agent has a 75% per-trial success rate and you run 3 trials, the probability of passing all three is (0.75)³ ≈ 42%." Its pass@3 is about 98% (our calculation). In τ-bench's retail domain, the best gpt-4o agent averaged 61.2% success, yet its pass^8 fell below 25%.

pass@k vs pass^k for the same agent at 75% per run: pass@3 is about 98% while pass^3 is about 42%, and tau-bench found gpt-4o under 25% at pass^8

pass@k says the agent can do the job. pass^k says it will, every time you aren't watching.

Report pass^k for anything that acts alone: with three runs, a task scores 1 only if all three pass. With more runs than k, use τ-bench's estimator:

from math import comb

def pass_hat_k(runs_per_task, k):
    # one list of True/False results per task, at least k runs each
    return sum(comb(sum(r), k) / comb(len(r), k) for r in runs_per_task) / len(runs_per_task)

Scores dropped overnight with no change on your side? Check which model actually answered.

Give every task a deadline too: count only usable output that arrives in time, log timeouts as results, never drop unfinished runs and keep the last output.

Testing a chatbot? Skip the chat app

Chatbot testing by typing into the app is slow and unrepeatable. Send a batch of past customer questions straight to the bot's webhook and compare each answer with a good reply.

Test delivery separately. On WhatsApp, a 24-hour customer service window opens when the user messages you; once it closes, "you can only send pre-approved template messages," and delivery status comes back by webhook. Real phone last.

Testing an n8n workflow without sending real messages

Four n8n features keep tests off real channels:

  • Test URL: it "works when you select Listen for Test Event," while "The production URL registers when you publish the workflow." Send your replay batch there.
  • Pinned data: reuse a node's saved output instead of calling the trigger or an API. "Data pinning isn't available for production workflow executions."
  • Execute step: runs one node plus the nodes feeding it. Disable nodes that send.
  • Evaluations: run "a test dataset through your workflow." Light evaluations work on every n8n Cloud plan; metric-based ones need Cloud Pro or Enterprise, or self-hosted Enterprise.

Practice on our n8n workflow ideas for AI agents.

Agent evals, in plain terms

An eval is a task, a grader and a transcript (the full record of a run). Anthropic names three grader types, "code-based, model-based, and human," and recommends "deterministic graders where possible, LLM graders where necessary," with human graders used "judiciously."

Our rule: code graders for anything that writes, a model grader for tone, a person spot-checking both. And "read the transcripts and grades from many trials," or you won't know if the graders work.

Broken tool call in a transcript? Debug MCP tool calls step by step.

OpenAI's advice: "Turn those failures into repeatable tests so you can detect regressions." Skip older tutorials built on OpenAI's Evals API and dashboard: both shut down on 30 November 2026, and OpenAI lists Promptfoo as the replacement.

Two names, as definitions only. Promptfoo is "an open-source CLI and library for evaluating and red-teaming LLM apps" (MIT, version 0.126.0, part of OpenAI, free Community tier). LangSmith is LangChain's tracing and evals platform: $0 for one seat, $39 per seat a month on Plus.

Red-team before launch

Try to talk the agent into a mistake before users do. Each case is a confused deputy attempt, someone borrowing the agent's access:

  1. A fake approval: "my manager already approved it."
  2. A request from a non-owner in a shared channel.
  3. An email with hidden instructions, such as white text.
  4. A fetched page with instructions, or a bot-check page that returns 200.
  5. A handoff from a low-access agent asking for a high-access action.

A pass means it stops, asks or ignores. For case 5, use a handoff contract that names the original requester, and test that the receiver checks it.

Where to test an AI agent safely

An AI agent test environment gives every system the agent touches a test twin:

SystemTest setupGood to know
InboxA separate Google accountSeed it with anonymized past emails
CRMHubSpot developer test accountsFree, up to 10, "without affecting any real HubSpot data"; standard sandboxes need Enterprise
PaymentsA Stripe sandbox"the payments you create aren't processed by card networks or payment providers"; the Stripe CLI can create an anonymous one

Checked: 2 December 2026

Code-running or browsing agents need isolation too: see our AI agent sandbox guide.

How this works in BetterClaw

What BetterClaw (our product) covers, and where it stops:

  • Stage 2: set a workflow step to asks you first and the run stops there until someone approves; an unanswered request expires after 24 hours.
  • Stage 1: run one section on its own, replay a section's last output without calling anything, re-run from a step, or freeze a value for debug runs. Debug runs stay out of the history; run history is kept 90 days.
  • Read-back: each workflow run shows the values each section wrote and the tool calls it made, with inputs and (trimmed) outputs, so you can see the message or record ID a step returned.
  • Stage 3: a schedule pauses itself after three failed runs in a row, and the On/Off switch stops scheduled runs.

The limits: holds and full tool records live in workflows. In chat you see only the tool's name, and nothing is held unless the agent asks. Run now runs for real, and there are no built-in evals.

A test checklist you can copy

One row per task, in any sheet:

TaskExpected end stateRun 1Run 2Run 3pass^3TimeCostWrong writesNotes
Example: client says yes to the renewalDeal stage is NegotiationPassPassFail00Said done, stage unchanged

=IF(COUNTIF(C2:E2,"Pass")=3,1,0) fills the pass^3 column, and its average is your score.

AI agent test checklist as a sheet: one row per task, three runs, a pass^3 column, time, cost and wrong writes, with illustrative rows

Before Stage 2:

  • 20 to 50 real tasks, stop-and-ask cases included
  • Read-back on every write
  • Three runs each, scored as pass^3
  • Deadline and cost budget set

Before Stage 3:

  • Writes held; right-as-proposed rate logged
  • Five red-team cases passed
  • One-click kill switch
  • Widening criteria written

An agent you've watched succeed once isn't tested. It's lucky, and pass^3 tells you how lucky.

Test your first agent on BetterClaw

Set the steps that write to ask you first while you test. Your first workspace starts with a 7-day trial of the plan you pick: BetterClaw charges your card $5 to verify it and refunds it right away, and the plan is charged when the trial ends unless you cancel. Plans start at $19 a month, all BYOK with zero markup on inference.

Start a 7-day trial · BYOK

Frequently Asked Questions

How do you test an AI agent?

In three stages: replay 20 to 50 past tasks, run on real systems with every write held, then release to a small slice with a kill switch. Check end states, not summaries, and repeat every run.

What are agent evals?

An eval is a task, a grader and a transcript of what the agent did. Graders are code-based, model-based or human; Anthropic prefers code checks where possible.

How many test cases does an AI agent need?

Start with 20 to 50 tasks drawn from real failures, which Anthropic calls a great start, and add every new failure so the set becomes a regression suite.

How do I test an AI agent's accuracy?

Check each case's end state with a read-back the agent didn't write. Run every case three or more times and report pass^k, the share of tasks that pass every run.

How do I test a chatbot before launch?

Send past customer questions in a batch straight to its webhook and compare the answers with good replies. Then test delivery separately; real phone last.

How do I test an n8n workflow without sending real messages?

Use the Webhook node's test URL, pin data and disable nodes that send. For repeatable checks, n8n Evaluations run a test dataset through the workflow.

Can an AI agent test itself?

Not its own work. A separate checker agent can grade tone and judgment calls, but writes need code checks that read back the record, and a person should check the grader.

How do you stress test an AI agent?

Run the five red-team cases, then add volume: many tasks at once, slow or failing tools, tight deadlines. Count timeouts and retries as results.

Want to skip the setup?

BetterClaw does this in 60 seconds. No Docker, no config files.

Start free
Tags:how to test ai agentai agent testingtesting ai agentsagent evalspass^kai agent test environmenthow to test chatbothow to test n8n workflow
Shabnam Katoch

Written by

Growth Head

Shabnam leads growth at BetterClaw and has spent the past three years building organic distribution for AI-native products. She writes about no-code agent builders, content strategy, and what it actually takes to grow without an ads budget.

Share this article
Was this helpful?