all posts

How to A/B test an AI agent safely on live traffic

An A/B test sends some people to a changed agent and the rest to the current one, then compares how often each finishes the same task. This guide covers what to change, how to split traffic, what to measure, how many conversations it takes, and how to read the result.

Guide 9 min read Updated
“Update these contacts from the trade-show list.”
A · 50%The agent as it runs today
B · 50%Looks up unmatched contacts by name
Measured onAttempts at the task that finish
Guarded byCost per task · tool errors · turns

Both versions run the same task in the same period, with one change.

What is A/B testing for an AI agent?

A change to an agent is a guess about what will help people finish a task. An A/B test tells you whether the guess was right, on the task it was meant to fix, before everyone gets it.

A/B testing an AI agent means running two versions of the agent at once and sending each person to one of them at random. It then compares how often each version gets the same task done. Version A is the agent as it runs today. Version B carries one change: a new prompt, a different model, a reworked tool.

PartWeb page testAgent test
Who is splitA visitorA person, across all their conversations
What changesA pageA prompt, a model, a tool, or the code around them
Main numberA click or a purchaseThe share of attempts at one task that finish
GuardrailsPage speed, bouncesCost per task, tool errors, dissatisfaction, turns
Evidence for one resultAn eventThe conversation, turn by turn

How is testing an agent different from testing a web page?

The split works the same way as on a web page. 5 things about agents change how you use it.

  • There is no conversion event. A page logs a click. Nothing logs that a person got their contacts updated. That has to be read from the conversation. The test is only as good as the way each conversation is labelled with its task and where it stopped.
  • The same version answers differently twice. Two people with the same request can get different replies from the same version. The test has to run long enough for that variation to average out.
  • One task spans many turns. The CRM task in this guide takes 9 turns and goes wrong at turn 7. A measure that scores single replies would count that attempt as 9 fine replies.
  • Every conversation has a cost. A version that finishes more tasks by calling a larger model can cost twice as much per task. Cost belongs in the result, not in a spreadsheet later.
  • People come back. Someone who meets version B in one conversation and version A in the next has learned from both. Keeping each person on one version keeps the comparison clean.

What should you change in version B?

Version B should change the update step, the step that loses the most people. The agent used across this site is the assistant inside a CRM. Its task “update these contacts from the trade-show list” finishes in 1,536 of 2,400 attempts, 64%. The step that loses the most people is update them. 528 of the 2,308 attempts that reach it stop there, a 22.9% step failure rate. Version B in this guide goes after that step. If the change is to a tool, a prompt or a rule, treat it as a harness change and keep everything else fixed.

Change one thing per test. If version B has a new prompt and a new model, a better result cannot tell you which one did it.

ChangeExample on the CRM agentWhat it tends to move
Instructions“When an email doesn’t match, look the contact up by name before skipping it”Where the task stops
ModelA larger model for the update step onlyFinish rate and cost per task
Toolupdate_contacts returns the 6 skipped contacts and the reason, not just successWhat the agent tells the person
Agent loopRetry a skipped write once before reporting backTurns and tool calls per task

Write down, before the test starts, the change and the step it should move. A test of “version B is better” has no step to check, so it cannot teach you anything when it fails.

How do you split traffic between the two versions?

  • Split by person, not by conversation. Assign each person to A or B once and keep them there for the whole test. Assigning per conversation lets one person see both versions, which blurs both.
  • Start small. Send 5% of people to version B first, to catch anything broken. Then move to an even split, which reaches an answer fastest.
  • Run both in the same window. A test that runs B in a different period from A measures the period. Same window, same task mix, same provider.
  • Tag every conversation with its version. A version field in the session metadata lets every later count be split by A and B, including counts nobody planned.

A stable split takes a few lines. Hashing the test name with the user ID keeps each person on one version, and keeps one test’s split independent of the next:

Assigning a person to a version

import hashlib

def version_for(user_id: str, test: str = "update-step-v2", share_b: float = 0.5) -> str:
    digest = hashlib.sha256(f"{test}:{user_id}".encode()).hexdigest()
    bucket = int(digest, 16) % 10_000 / 10_000
    return "B" if bucket < share_b else "A"

Raising share_b from 0.05 to 0.5 keeps everyone already in B where they are, because a bucket below 0.05 is also below 0.5.

What should you measure in an agent A/B test?

Pick one task and one number before the test starts: the share of attempts at that task that finish. For the CRM agent that is the trade-show contacts update, at 64% today. Choosing the number after the results are in turns any test into a win. If cost is a guardrail, work it out per finished task using current model prices.

Measure the task, not the conversation. One conversation can hold a contacts update and a billing question. If B helps with contacts, counting whole conversations dilutes the gain with billing questions B never touched. The task is the unit the abracadabra workspace is built around for the same reason.

Then set guardrails: numbers that must not get worse while the main one improves.

GuardrailWhat it catchesPause B if
Cost per taskA better finish rate bought with a larger modelB costs more per finished task than the gain is worth to you
Tool errorsA prompt that calls a tool the wrong wayB’s error rate rises above A’s
DissatisfactionTurns like “Where are the rest? Can you try that again?”B’s share of such turns rises
Turns per taskA version that finishes by dragging the conversation outB needs more turns for the same task

Write each pause rule as a number before the test starts. The guide to measuring agent performance covers how each of these is counted. The same finish rate is what product analytics for agents tracks on every attempt. An eval is how you check the change on known cases before anyone meets version B.

How many conversations do you need?

The smaller the change you want to detect, the more attempts each version needs. Starting from 64%, with the usual 5% chance of a false win and an 80% chance of catching a real change:

B finishesChangeAttempts per versionBoth versions
66%+2 points8,92717,854
68%+4 points2,2014,402
70%+6 points9631,926
75%+11 points274548

Count attempts at the task, not conversations. A conversation about billing adds nothing to a test of the contacts update. Pick the smallest change worth shipping and your weekly attempts to see how long the test runs:

B finishes

Attempts a week

Per version
2,201 attempts
Both versions
4,402 attempts
At an even split
8 weeks
Based on a 64% finish rate today. The bar fills over 12 weeks; a test longer than that is a sign to look for a bigger change or a busier task.

The counts come from the standard formula for comparing two rates. Use your own starting rate: the same change needs more attempts the nearer the rate is to 50%.

How do you run the test?

  1. Write the plan. The task, the main number, the smallest change worth shipping, and each guardrail’s pause rule.
  2. Work out the length. Attempts needed per version, divided by the attempts each version will get each week.
  3. Start B at 5%. Keep it there until it has handled a few dozen attempts with no broken tool calls.
  4. Move to an even split and leave the setup alone until each version reaches its count.
  5. Watch the guardrails throughout the test and pause B if one breaks its rule.
  6. Read the main number once, at the planned count.

Checking the finish rate after every batch of attempts and stopping on the first good result produces false wins. Each look is another chance for noise to cross the line. Decide the count first and read once, or use a method designed for repeated looks, such as a sequential test.

Before anyone meets version B, a shadow test can run it on copies of real requests and throw its replies away. That catches breakage, but it cannot show whether people finish more tasks, because nobody reads B’s replies. For a CRM agent, a shadow run must not write to real records: point its tools at a copy.

How do you read the result?

Read the gap in finish rate, how sure that gap is, and whether a guardrail broke. Here is a worked example on the running example, not a measured result. Version B changes update_contacts so it returns the 6 contacts it skipped, and the agent looks them up by name. Suppose that halves the stops on update them. Then 264 more attempts finish, and the rate moves from 64% to 75%. Before you ship, scan for silent failures that the main number would not show.

VersionAttemptsStopped on update themFinishedRate
A2,4005281,53664%
B2,4002641,80075%
  • The difference. 11 points, or 17% more finished tasks than A.
  • How sure. The 95% interval for the difference runs from about 8 to 14 points. Even its low end clears a 4-point bar.
  • The guardrails. If B finds contacts by name with an extra tool call, check its cost per task and its turns before shipping.
  • The conversations. Open 20 attempts that stopped on B and 20 on A. If B’s stops are a new kind, such as the wrong contact matched by name, the rate hides a problem the next test has to fix.

A rate tells you that B did better. The conversations tell you why, and whether the why will hold. Here, abracadabra splits each task by any session field, a version tag included, and opens the turns behind every count. The features page lists how, and comparison is on every plan.

When should you not use an A/B test?

  • Too little traffic. At 200 attempts a month, detecting a 4-point change takes 4,402 attempts, nearly 2 years. Read the conversations and compare before and after the change instead, and accept that the evidence is weaker.
  • Changes you cannot hold back. When a provider retires a model, both versions change at once. Compare the periods before and after.
  • Writes that cannot be undone. Updated records, refunds and sent emails stay done. A bad version B touches real data, so keep its share small and its guardrails tight.
  • Safety fixes. A fix for a harmful reply ships to everyone. Keeping half of your users on the harmful version to measure the fix is not a fair trade.
  • Rare tasks. A test answers for common tasks. A task with 30 attempts a month is a case for reading every conversation.

Common questions about A/B testing AI agents

What is A/B testing for AI agents?

It is a live comparison between the current agent and a copy with one change, such as a new prompt, model or tool. People are assigned to one of the two at random, and the team compares how many attempts at the same task each version finishes.

Can you A/B test prompts?

Yes. A prompt change is the most common version B. Keep the model and tools the same, and split people at random. Compare the finish rate of the task the prompt was meant to help, with cost per task and turns as guardrails.

What should you measure in an AI agent A/B test?

One main number decided in advance: the share of attempts at one task that finish. Add guardrails that must not get worse: cost per task, tool errors, dissatisfaction turns and turns per task.

How long should an AI agent A/B test run?

Until each version reaches the number of attempts worked out before the start. From a 64% finish rate, detecting a 4-point change takes 2,201 attempts per version; at 600 attempts a week that is 8 weeks.

What is the difference between an A/B test and an eval?

An eval grades fixed test cases before release, so it catches regressions early. An A/B test measures real people after release, so it shows whether more of them finish the task. Most teams use both: evals to decide what is safe to test, A/B tests to decide what to ship.

all posts

See which version finishes more of each task.

Abracadabra splits task success by version and links each stop to the conversation that explains it.