all posts

Shadow testing AI agents: try a change on real traffic

Shadow testing runs a new version of an agent on copies of real requests and throws its replies away. This guide covers how it works, what it catches, how to handle tools that write, what it costs, and where it fits before a live test.

Guide 11 min read Updated
“Update these contacts from the trade-show list.”
Live version14: replies to the person
Shadow version15: replies thrown away
Planned writes3 live, 9 shadow, none applied

The shadow runs on real requests, and nobody sees its replies.

What is shadow testing for an AI agent?

The safest place to find out that a change breaks an agent is on real requests that no person ever sees the answer to.

Shadow testing runs a new version of an agent on copies of real requests, alongside the live version. The live version answers the person as usual. The new version’s replies are recorded and thrown away, so nobody reads them. Running the new version this way in production is often called a shadow deployment, and the new version is the shadow.

MethodRequests it runs onWho sees new repliesWhat it can show
ReplayRecorded conversationsNobodyWhat the new version says on known cases
Shadow testCopies of live requests, as they arriveNobodyBreakage, cost and planned actions on today’s traffic
Small live shareLive requests from a few peopleThose peopleEarly friction and errors with real replies
A/B testLive requests, split between versionsEveryone in version BWhether more tasks finish

Replay and shadow testing both keep the new version away from people. The difference is the traffic. Replay uses conversations that already happened. A shadow test uses requests as they come in, including the kinds nobody thought to record.

How does shadow testing work?

A shadow test sits at the point where a request reaches the agent. A small piece of code copies the request and sends it to both versions. Only one reply goes back.

  1. Receive the person’s turn and pass it to the live version as usual.
  2. Copy the same turn, with the same conversation history, to the shadow version.
  3. Send the live version’s reply to the person.
  4. Record the shadow version’s reply, its tool calls, its cost and its errors, then discard the reply.
  5. Compare the 2 records for that turn, and for the whole conversation once it ends.

On a web service this is the whole idea. An agent adds a problem: conversations have many turns, and each turn depends on what was said before it.

Take the running example on this site, the AI assistant inside a CRM. A person asks it to “update these contacts from the trade-show list”. Getting it done takes 3 steps: find the contacts, update them, then log the activity. The update itself happens at turn 6. Before that, the agent asks which contacts and the person says “Great, go ahead”. A shadow that only sees turn 1 never reaches the step that matters.

The shadow cannot hold its own conversation either. The person replies to the live version, not to the shadow. Once the shadow says something different, the person’s next turn no longer answers it. There are 2 ways to handle this.

  • Fork at each turn. Before every live turn, give the shadow the live conversation so far and ask for its next move. It never builds a conversation of its own. This shows what the new version would do at each point, given the live history.
  • Shadow the first reply only. Compare just the opening response. This is cheap and works for single-turn agents, but it misses most of a multi-step task.

For an agent like the CRM assistant, fork at each turn. The comparison at turn 6 is the one that tells the team something.

What can a shadow test catch?

A shadow test is good at problems that show up on the version’s own output, without anyone reacting to it. Those are mostly breakage and cost. They appear on almost every request that hits them, so a modest sample finds them. When the shadow version gets something wrong, work out which part of the agent is failing before you change anything.

SignalWhat to compareExample on the CRM agent
CrashesTurns where the shadow fails to return a replyThe shadow throws on a contact with no email
Tool errorsFailed or malformed tool calls per turnupdate_contacts called with a field it does not accept
CostTokens and tool calls per turn and per attemptA lookup by name adds 6 calls to find_contacts
Reply lengthWords per replyReplies grow from one line to a full paragraph
RefusalsTurns where the shadow declines the requestThe shadow refuses to edit existing contacts
Planned actionsWhat each version would write, and to which recordsLive writes 3 contacts; the shadow would write 9

Set a line for each signal before the test starts. For example: no more tool errors than the live version, cost per attempt no more than a third higher, and zero writes to real records. Written down first, the lines decide the result. Written afterwards, they tend to fit it.

Read a sample of the turns where the 2 versions differ, by hand, before computing any rate. A longer reply may be a clearer one. A refusal may be correct. The counts say where to look, and the reading says what happened.

What happens when the agent’s tools change real data?

A shadow’s replies are easy to throw away. Its tool calls are not. If the shadow CRM agent calls update_contacts against the real CRM, it changes real contacts, and nobody approved that version. The person sees nothing wrong until their records are.

The CRM’s MCP server has 3 tools: find_contacts, update_contacts and log_activity. Only find_contacts just reads. The other 2 write, so the shadow needs somewhere else to send those calls.

OptionWhat the shadow gets backWhat it costsMain risk
Real systemsReal resultsNothing extraWrites real records twice, from an unapproved version
A copy of the CRMResults from the copyKeeping the copy in step with the real oneA stale copy gives different results
A stub that recordsA made-up result shaped like the real oneWriting the stubThe shadow reacts to a reply that never happened
BlockedAn errorNothingThe shadow stops at every write, so the test shows little
Shadow writes go to
Real contacts changed
3, all by the live version.
What the shadow gets back
A reply shaped like the real tool’s: 6 emails didn’t match.
What to watch
A stub that drifts from the real tool. The shadow then reacts to replies that never happen.
Turn 6 of the trade-show task. Each square is 1 of the 9 contacts. Version 15 looks up unmatched contacts by name, so it plans 9 writes: an example, not a measured result.

A common setup stubs the writes and lets the reads through. The stub records the call it received: which tool, which records, which fields, what values. It then returns what the real tool would most likely have said, so the shadow can carry on.

A write the stub recorded instead of applying

{
  "conversation": "c_7f3a91",
  "turn": 6,
  "version": 15,
  "tool": "update_contacts",
  "applied": false,
  "contacts": 9,
  "matched_by": { "email": 3, "name": 6 },
  "fields": ["stage", "source", "last_event"]
}
  • Check every write tool. Agent memory, sending an email and logging an activity are writes too. Each one needs a stub or a copy.
  • Keep reads honest. Reads such as find_contacts can usually reach the real CRM. They still add load, so watch rate limits.
  • Make the stub answer like the real tool. A stub that always returns success hides the failure the shadow was meant to handle. For the CRM agent, it should report the 6 contacts whose emails don’t match.
  • Mark shadow calls. Tag every call from the shadow with its version, so a missed stub shows up in the real system’s logs.

How do you compare what each version would do?

With writes recorded, the most useful comparison is not between replies. It is between planned actions: what each version would have changed in the world, given the same turn. Judge both versions by the same task completion rate, not by how a single reply reads.

On the live CRM agent today, 6 of the 9 contacts don’t match on email and are skipped. The update_contacts call still returns success, and the agent reports the other 3 as done. At the update step, 528 of the 2,308 attempts that reach it stop, a 22.9% stop rate.

Say the team writes version 15, in which the agent looks up unmatched contacts by name before updating. The shadow test then answers a plain question at turn 6: would it have written 9 contacts, or 3?

ContactsLive version 14Shadow version 15What to read
3 matched on emailUpdatedWould updateSame fields and values on both
6 not matched on emailSkippedWould update, matched by nameIs each name match the right person?
Total written39, none appliedWhether the 6 new writes are correct

These figures are an example, not a measured result. The 9 is not good news by itself. A name can match the wrong contact, or 2 contacts. The shadow shows that version 15 would write 6 more records. A person still has to open those 6 and check each match before anyone treats the change as a fix.

  • Same plan. Both versions would make the same writes. The change is safe at this step, and probably does nothing here.
  • More writes. The shadow would change records the live version skips. Read the extra records first.
  • Fewer writes. The shadow would skip records the live version changes. Check whether it is being careful or broken.
  • Different records. Both write, but not to the same contacts. Treat this as a bug until reading shows otherwise.

Count each outcome across the sample, then read the differences. A version that plans more writes on most attempts and gets the extra ones right is ready for a small live share.

How much does a shadow test cost?

Every shadowed request is paid for twice: once for the live version and once for the shadow. Forking at each turn means every turn of a shadowed conversation runs twice. Read calls to tools also run twice, so the systems behind them see extra load. To estimate it, multiply the copied requests by your model’s current token prices.

There is no need to shadow everything. Breakage shows up often, so a share of traffic finds it. Pick a share and a stopping point before starting.

  • Sample by conversation. Shadow every turn of a chosen share of conversations, so each shadowed conversation is complete. Shadowing 17% of the 2,400 attempts on the CRM task gives 408 shadowed attempts, and about 392 of them reach the update step.
  • Shadow only the turns that matter. If the change only touches the update step, fork only at turns where the live version calls update_contacts. This cuts cost by skipping turns the change cannot affect.
  • Stop at a count, not a feeling. Decide how many shadowed attempts at the step the test needs, and end it there.
  • Watch the systems behind the tools. A shadow that adds 6 lookups by name per attempt can hit the CRM’s rate limit before it hits a budget.

The shadow also adds a little delay if the live version waits for it. Run the shadow after the live reply is sent, or in parallel without waiting, so the person never waits on a version they cannot see.

How do you run a shadow test, step by step?

The engineer wires the copy and the stubs. The product lead decides what the test must show and reads the differences. Both agree the lines before any traffic is copied. Change one part of the agent harness at a time, so any difference has one clear cause.

  1. Write down the change, the new version number, and the step it targets.
  2. List every tool the shadow can call, and mark each one as read or write.
  3. Point each write tool at a stub that records, or at a copy of the system.
  4. Set the lines: tool errors, crashes, cost per attempt, refusals, and zero real writes.
  5. Choose the share of conversations and the number of shadowed attempts at the step.
  6. Start the copy, and check the real system’s logs for any call tagged with the shadow version.
  7. Read a sample of the turns where planned actions differ.
  8. Decide: fix and shadow again, or move to a small live share.

Tag every conversation with both version numbers. Then the shadow records can be split by cohort later. If the shadow refuses more often on enterprise accounts, that shows up without planning for it.

The live side needs the same split. Where tasks stop today, by step and cohort, is the baseline that every shadow difference is read against. The baseline can come from abracadabra, which labels each conversation with its task and the step where it stopped.

Where does shadow testing fit next to evals and A/B tests?

A shadow test is one stage on the way from a change to everyone. It comes after replay on recorded conversations and before any person meets the new version. Shadow tests work best next to offline evals. Evals check the cases you already know about, and a shadow test shows what you did not think of.

StageWho meets the new versionQuestion it answers
ReplayNobodyDoes the change do what the hypothesis says on known cases?
Shadow testNobodyDoes it break, cost too much or plan wrong actions on today’s traffic?
Small live shareA few peopleDo people hit new errors or friction with real replies?
A/B testA split of peopleDo more tasks finish?
RolloutEveryoneDoes the gain hold at full volume?

The shadow test cannot say whether more people finish the task, because nobody reads the shadow’s replies. Only the live stages can. Here is an example, not a measured result. If the stops at update them fell by half, from 528 to 264, the task would rise from 64% to 75%. Only an A/B test can show whether version 15 gets there.

Skip the shadow test when the change cannot break anything a shadow would catch. A wording change to one reply carries little risk of crashes or wrong writes, and its effect lives entirely in how people respond.

When should you not use shadow testing?

“Nobody affected” holds for replies. It holds less well for everything around them. Know the limits before relying on a shadow result.

  • The question is whether people finish more tasks. Nobody reads the shadow, so its finish rate does not exist. Use an A/B test.
  • Most of the effect comes after the first difference. Forking at each turn shows the next move, not where a whole conversation would have gone. A change that pays off over several turns needs live traffic.
  • Reads still touch real systems. Read calls reach the real CRM and add to its load and rate limits. A shadow can slow the live version down.
  • Copies carry real data. Shadow records hold copies of real requests, which may include personal data. Store and delete them under the same rules as the live conversations.
  • A write slips through. One unstubbed tool, or a new tool added mid-test, writes for real. Tag shadow calls and watch for them.
  • Traffic is low. With few attempts at the step, a shadow test runs slowly and costs the same per request. Replay and careful reading may be enough.
  • The cost doubles where it is already high. On long, expensive conversations, a large shadow share can cost more than a short live test on a small share.

Common questions about shadow testing AI agents

What is shadow testing?

It is a way to try a changed system on live traffic without anyone seeing the result. Each real request is copied to the new version, and its output is recorded and discarded. The comparison shows whether the new version breaks, costs more or behaves differently on real traffic before any person meets it.

What is the difference between shadow testing and A/B testing?

In a shadow test nobody sees the new version’s replies, so it can show breakage, cost and planned actions but not whether people finish more tasks. In an A/B test, real people get the new version, so it can show whether the change helps. A shadow test usually comes first.

What is a shadow deployment?

A shadow deployment is running a new version in production next to the live one, fed the same requests, with its output kept from users. Shadow testing is what the team does with it: compare the 2 versions’ errors, costs and actions.

How do you shadow test an AI agent that writes data?

Point the shadow’s write tools at a stub that records each call, or at a copy of the system, and let read tools through. Make the stub answer the way the real tool would. Then compare what each version would have written.

Does shadow testing cost more?

Yes. Every shadowed request runs twice, so its model and tool costs are paid twice. Shadowing a share of conversations, or only the turns the change can affect, keeps the cost down.

all posts

Read the results when people see the new version.

Abracadabra compares task success for each version and links every drop to its conversation.