Anthropic researchers developed an AI agent that writes property‑based tests to find bugs in large Python projects. The agent reads type annotations, docstrings, and comments to infer properties, then uses Hypothesis to generate counterexamples. It was tested on over 100 popular packages, including NumPy, SciPy, and Pandas, and produced 984 bug reports, of which 56% were valid and 32% were reportable. The team manually reviewed and filed several bugs, many of which have already been patched.
Muhammad Maaz 1,2 , Liam DeVoe 3 , Zac Hatfield-Dodds 2 , Nicholas Carlini 2 1 MATS, 2 Anthropic, 3 Northeastern University
We developed an agent that can efficiently identify bugs in large software projects. To do this, our agent infers general properties of code that should be true, and then by applying property-based testing—a technique similar to fuzz testing—we are able to discover bugs in top Python packages like NumPy, SciPy, and Pandas. After extensive manual validation, we are in the process of reporting these bugs to the developers, several of which have already been patched.
For more information, read the full paper , take a look at the GitHub repository , or browse the bugs we found at our site .
Ensuring that programs are bug-free is one of the most challenging aspects of software engineering. Bugs frequently continue to lurk despite the developer’s best effort. The most common approach to testing code is with example-based tests : the developer writes out a specific example use-case, and then verifies that the actual output matches the expected output. For example, a developer might verify that a sort function called on the list [2, 10, 5, 4] would return the output [2, 4, 5, 10]. However, exhaustively covering a program with tests like this is challenging: bugs frequently remain in an edge case the developer did not test. After all, if a developer does not think to test an edge case, it is also likely the developer did not consider that case in the implementation!
In contrast, property-based testing is a software testing paradigm that aims to test whether a general property of the code holds for all (or most) inputs. A developer specifies a property or invariant about the program—for example, that JSON deserialization is the inverse of serialization—as well as a description of the kinds of inputs the property accepts (e.g., any JSON serializable objects). The property-based testing framework then automatically searches for a counterexample of this property by generating valid inputs as test cases using techniques similar to fuzzing. Since the developer specifies the general input domain, and not individual test cases, property-based testing frees developers from thinking of every edge case and allows them to operate at a higher level of abstraction.
In our paper that we presented at the 2025 NeurIPS Deep Learning for Code Workshop that was the result of a MATS project, we developed an AI agent that autonomously writes property-based tests for existing code. We directed the agent to discover properties by reading type annotations, docstrings, function names, and comments. The agent then wrote corresponding property-based tests using Hypothesis.
Demonstrates how large language models can automate sophisticated testing techniques, potentially reducing the burden on developers and improving software reliability across the AI ecosystem.