Skip to content

AI engineering · 28 June 2026 · 6 min read

Who checks the AI’s homework? How to verify code written by coding agents

When an AI agent writes both the code and the tests, a green build proves less than you think. Here's how we verify AI-written software, with a real example from a live market-data engine.

  • AI engineering
  • Testing
  • AI coding agents
  • Code review
  • Real-time data
  • For CTOs and tech leads
  • For engineers
In this article
  1. Why isn't a passing test suite enough?
  2. What does real verification look like? Kill everything and compare
  3. The day the reference was wrong
  4. Six rules for verifying AI-written code
  5. What does this mean for your business?
  6. What should your team do first?
  7. FAQ

The short answer: when an AI agent writes the code and the tests, both come from the same understanding of the problem, so they share the same blind spots. A green build tells you the code does what the agent thought it should do. It doesn't tell you the agent was right. To trust AI-written code, you need evidence that doesn't come from the author: a definition of "correct" written before the code, checks run by something other than the agent, and failures you cause on purpose.

Agents now write most of our code at Daedalus. That makes verification the part of engineering we think about hardest. Here's how we do it, with a real example.

Why isn't a passing test suite enough?

Three reasons, all of which we've run into.

The author marks its own homework. If an agent misunderstands a requirement, it misunderstands it consistently: in the code, and in the tests it writes for that code. Everything passes, and everything is wrong in the same way.

Agents can claim checks they never ran. Not often, and not out of malice, but "I've run the tests and they all pass" sometimes means "I expect they would". We keep a deliberate test case, a canary, in our own agent instructions that checks for exactly this, because it's the kind of thing you only need to miss once.

Agents are very good at hitting targets. Tell an agent to raise coverage to 90% and it will, with tests that touch every line and check very little. Our engineering rules now say it plainly: never write a test to satisfy a counter. Coverage is a useful smell, not a goal.

What does real verification look like? Kill everything and compare

Here's a real example. We're building a real-time engine that lets trading teams define calculations over live market data, things like moving averages or volume-weighted prices over sliding windows. If one of those numbers is wrong, someone trades on it. So "the tests pass" was never going to be the bar.

Our end-to-end run works like this:

  • Real data, real infrastructure. Live trades from a crypto exchange, for 30 minutes, across 50 trading pairs, flowing through the whole system on a three-node Kafka cluster, the same way it will in production.

  • Changes mid-flight. Calculations are switched on and off partway through, because that's what users do.

  • Failures on purpose. Every worker in the pipeline is killed outright, mid-stream, and restarted. No graceful shutdown, no warning.

  • Three independent answers. Every result the engine committed is compared with a second engine that recomputes everything from the logged history, and with an independent reference implementation written from the specification, not from the code.

The rule for the reference comparison is strict: every result, in order, must match. No difference is excused. Even the trades each side refuses as arriving too late must be the same trades.

In the latest runs, every result matched. That's a good day. The more interesting days were the ones before.

The day the reference was wrong

In earlier runs, a handful of results differed, all in one calculation that was switched on partway through the run. The natural assumption was a bug in the engine.

It wasn't. The reference had the bug: it didn't handle a calculation that starts mid-stream correctly. The engine was right.

We like this story because it shows what independent verification is actually for. It isn't a machine that declares the engine correct. It's a way of making disagreement visible, so a person has to find out who's wrong and why. Sometimes it's the code. Sometimes it's your idea of the answer. Either way, you learn something a green build would never have told you.

Six rules for verifying AI-written code

These are the rules we work by. Most of them need no special tooling.

1. Define "correct" before the code exists

Write down what the right answer is, as a specification, golden test data or a simple reference implementation, before the agent writes the production code. If the reference is written from the code, it'll share the code's mistakes.

2. Make wrong states impossible to write

Where the language allows it, impossible input is refused with a named error, or better, can't be represented at all. A value with a valid range becomes a type whose constructor checks it. An agent can't forget to validate something the compiler won't let it skip. And never let code hide an error to keep itself simple: a value that's too big is refused, not capped, and a missing one is refused, not defaulted. AI agents are especially prone to those quiet fallbacks, because they make code look careful.

3. Break it on purpose

Kill processes. Cut connections. Deliver data late and out of order. If your system only works when nothing goes wrong, you've verified a system nobody will ever run.

4. The reviewer is never the author

The model that wrote the code never reviews it. Reviews run read-only on a frozen copy of the code, by a different model, told exactly which rules to check and to quote the code for every finding. Serious findings are fixed, not filed as known bugs.

5. Re-run what the agent says it ran

Treat "tests pass" from an agent as a claim, not a fact. Re-run the checks yourself, or have your pipeline do it, every time. It costs minutes. Missing a false claim can cost a great deal more.

6. Say what you haven't checked

Our end-to-end report has a section called "Not checked". For example, no run has yet lasted long enough to close a daily window, so we don't claim daily calculations are verified end to end. Being explicit about the gaps is what lets people trust everything else in the report.

What does this mean for your business?

"All the tests pass" is something you'll hear from every team using AI, and on its own it tells you very little. The real risk for a business isn't a crash. It's a wrong number that reaches a customer: a payment, a price, a report, a balance.

You don't need to read code to test how seriously a team takes this. Ask three questions. Who checked this, other than the thing that wrote it? What did they check it against? And what hasn't been checked yet? A team that can answer the third one honestly is a team you can trust with the first two.

What should your team do first?

  • Pick your most expensive mistake, the number or record that would hurt most if it were wrong, and build an independent check for that one first.

  • Separate the author from the checker: different people, different models, or both.

  • Add one failure test that kills something mid-operation and checks nothing was lost or duplicated.

  • Stop rewarding coverage numbers, and start asking which behaviour a test actually pins down.

FAQ

Can AI-generated code be trusted in production? Yes, on the same terms as human-written code: when there's independent evidence it does the right thing. The difference is that agents produce code much faster, so verification has to keep up, which means automating as much of it as you can.

Should AI write its own tests? It can write a lot of them, and it's good at it. But the definition of "correct" and the most important checks should come from somewhere else: a specification, a person, or an independent reference.

Isn't building a reference implementation twice the work? For the parts that matter most, it's cheap insurance. A reference only has to be correct, not fast, so it's usually a fraction of the size of the real thing, and agents can help write it too, from the specification rather than from the code.

How do you know the independent check is right? You don't, entirely. That's the point of the story above. When two independent answers disagree, a person investigates, and both sides get better.


We embed engineers who build and verify AI-written software for teams where being wrong is expensive. If that sounds like your team, we're happy to talk.

All articles

Read something that sounds like your problem?

A free 15-minute intro with our CEO. Bring the article, and he’ll tell you which service fits, if any. If a spreadsheet and two rules would do the job, we’ll say so.