Agents fail to use test and verification techniques effectively

How well do agents use test/verification techniques?

Dan Luu tests whether simple instructions to coding agents to use specific testing techniques or libraries improve implementation correctness. Across 26 prompt conditions—including TDD, property-based testing, formal methods like Lean 4 and TLA+, and various skills—no technique significantly outperformed the default. Agents often apply techniques superficially, writing poor tests or proving irrelevant properties. The results suggest that without expert guidance, agents struggle to leverage verification tools effectively, highlighting a gap in current agentic coding practices.

For the most part, when a technique was named, they did what Gary described, but with respect to that technique (for example, for formal methods, they mostly proved irrelevant properties and with property-based testing, agents would lean heavily on totally random inputs and heavily hit invalid/rejection cases or find a trivial property to check and run low-value random cases against the trivial property).
  1. andai

    I'm doing indie game dev, so not sure how much my experience transfers, but I've been working on a browser game and the game kind of sucks, but there's a huge amount of tests (by my standards). So you can have crap software with loads of tests. (You can also have awesome software with very few tests!)

    Also, had a funny experience where AI implemented an architectural change completely backwards. The implementation was pointless and made things worse rather than better. But I still got "all tests green" lol, because it just proved that the incorrect thing worked properly.

    I noted with some amusement that formal verification wouldn't have helped there either, it would just have been an even stronger proof of the "correctness" of the thing that shouldn't exist to begin with.

  2. ivanzhaowy123

    In my experience, agents often think of more edge cases than humans when writing unit tests. But under the guidance of certain skills, they can become mechanical and lose sight of the business logic.

    For example, when I use the Superpowers skill set, the agent proactively adopts TDD for every new feature. But its understanding of testing often stays superficial: if the user asks for a screen with a “Send” button, it first writes a test checking whether the button exists. The test fails, so it adds the button to make it pass.

    As a result, the test suite fills up with low-value cases that check whether a property exists or a string matches exactly. The agent follows the “write a failing test, then implement the feature” workflow, but never really tests the business behavior: When should sending be allowed? What should happen after success or failure? How should duplicate submissions be handled?

    The problem isn’t that agents can’t write tests. It’s that they seem prone to reducing TDD to a rigid sequence of steps, struggling to independently derive meaningful test cases from business requirements and use them to drive development.

  3. siscia

    It is still early, but I find that this experiment makes little to no sense and it is barely useful.

    The way you test code cannot (and should not) be decoupled by the way in which you architect the code itself.

    80%+ of effective testing is not in the testing framework but in the code architecture.

    The author doesn't mention how the code is being architected and managed.

    For what it is worth, I found that forcing agents on DI/hexagonal architecture and forcing a trivial coverage check is quite useful and produce overall good enough code with relative little effort

  4. movpasd

    This is significantly more thorough than any testing I've done, and in a totally different domain, but my anecdotal experience getting agents to use Hypothesis was quite poor.

    The agent really, really struggled to bridge the gap between the code and the actual business rules it was meant to be modelling. It also struggled to work out which functions at which layer were appropriate to write tests for. So, its tests tended to be very brittle to changes to domain logic.

    Essentially, agents have always seemed to struggle with modularity and problem decomposition. Good testing is about finding the right things to test, which means working out how to subdivide the input state into an appropriate product state, and checking each behaviour independently. IMO, this is the most difficult and complicated thing about programming, so I won't say it struggled _more_ than a human would --- but humans have the advantage of being able to sleep on it?

    One minor thing I observed was that it tended to get really hung up on floating point edge cases (NaNs, infinities). Maybe floating point edge cases are over-represented in the property-testing training data, but it's essentially irrelevant for my usecase, at least as far as the business rules go.

  5. anitil

    You know how everyone thinks agents are bad at the thing they're good at and good at the thing they're bad at? It turns out I must be bad at testing, because I thought they do a reasonable job.

More from this day

2026-09-08