Leander Peter is the CTO of Avallon, which builds AI-powered claims automation for insurers.

​Monday morning, 10:01 a.m. Eastern. An AI agent wakes up in its sandbox to test a new prompt. The agent’s job is simple: Analyze all the emails and calls that came in over the weekend, and route each one to its claim.

The agent finds a document on its virtual machine. It’s called evaluation.json. The agent opens it and finds the answers to its world. It concludes that using them would be cheating. Then it starts using them anyway.

Our engineers quickly realized the agent was cheating. The numbers didn’t add up. A run that usually takes 20 minutes took two.

Why were we replaying at all, you may ask? My company builds AI agents that do clerical claims work for insurers. To deploy and iterate AI agents reliably in a highly regulated environment, you need to evaluate every new agent version. This agent received 62 new versions in the last 30 days while handling 34,000 production runs. No one can test that by hand.

So what was the actual issue? It wasn’t the model. It was the test world we had built around it. Here’s what we encountered when building our evaluation system.

Faking The World Is The Hard Part

You roughly know what success looks like: A successful agent routes an email to claim C, or it ends its run by creating a claim with the right claim details. But you can’t test against the real thing because the real thing is a carrier’s claims system full of live claims. You have to fake the world around the agent.

Take a doctor’s report attached to an email from the doctor’s office. The agent has two tools. “Search claim” returns the correct claim. “Attach document to claim” takes a claim ID and a document ID.

How do you stop the agent from searching the real claims management system, and from attaching the document to a production claim over and over? You use mocks.

The beauty of mocks is that the agent doesn’t know whether it is talking to a real production system or a replayed, stored response from that system. The agent just knows it called a function called search claim. We return a prerecorded answer for this function call to the agent. When the agent calls the function attach document to claim, we do nothing. We just record which claim ID and document ID the agent chose to use when calling that function. After the run, we check whether it chose the right claim ID and document ID.

This breaks when you switch models, for example from Opus 4 to Opus 5.

A new model might check its environment and first see whether there’s another email. If we don’t have a mock for that function, which we likely don’t, the mock fails and the agent starts to wonder why the email search isn’t working. This hurts the ground truth of our evaluation runs.

A Replay Has To Hide That It’s A Replay

Those prerecorded answers lived in a file called evaluation.json, on the agent’s own virtual machine. Putting the file there was a mistake. It was hidden in a deep folder structure, and the agent still searched for it. Seeing the agent’s transcript was eye-opening:​

It eroded trust and reinforced how little we know about these black boxes.

Since then, we grade not only the result but also the number of function calls necessary for a run to succeed.

As a preliminary change, the answers now live only in the agent’s virtual machine memory. The learning is to move this information outside and build a virtual machine for the virtual machine the agent runs in.

It wasn’t the only leak. A mocked response returned a file pointer to a presigned S3 URL, and that URL expired 15 minutes after the mock was created. When the eval ran two days later, the agent tried to download the data and failed. We had to replace these links before every eval run, which was a quick fix rather than a long-term solution. Old run IDs leak the same way.

What It Gives Us

Building the first version of the replay system for our agents was fast, around one week and five PRs. It sped up our model changes and gave us more trust in production changes.

Before, life for an FDE (a forward deployed engineer who builds and tunes the agents for a customer) meant testing for up to several hours after a change to confirm a model and its configuration still performed reliably. An FDE can now execute a set of evaluations and go on to the next task. We can stop promotions that would otherwise have had a negative production impact. If v65 had gone live, the mailroom agent would have put some patients’ medical records on someone else’s claim and lost track of others, because the model behind it wasn’t capable enough. The eval caught it in testing, so no real patients were affected.

The Biggest Lesson

No test caught our cheating agent. The clock did: A run that usually takes 20 minutes was done in two. So monitor all your agents, in evaluations and in production, and check for anomalies: run time, number of tool calls, which tools get called.

I believe evaluations will become increasingly important as companies build custom AI agents for their workflows. The more complex these agents become, the harder it is to know whether a change actually improves them. Teams that figure out how to evaluate their agents early can iterate faster, adopt new models with more confidence and catch problems before they reach production.

We know from software engineering that tests are important but cumbersome. With agents, faking the world is the hard part. Start building your testing framework now.

Forbes Technology Council is an invitation-only community for world-class CIOs, CTOs and technology executives. Do I qualify?

Share.
Leave A Reply

Exit mobile version