AI
AI coding agents rarely need to write new tests to fix bugs, study finds
An analysis of 5,000 runs by LLM-based agents shows test-writing behavior varies widely but doesn't reliably predict whether code fixes succeed.
Researchers examining how AI coding agents tackle real software defects discovered something counterintuitive: whether an agent writes tests while solving repository-level issues bears little relation to whether it actually succeeds in fixing the bug. The finding raises questions about how much time and compute these agents should spend on test generation.
The Study#
A team analyzed 5,000 recorded agent runs conducted by six capable large language models (LLMs) using the SWE-bench Verified benchmark, a dataset of repository-scale programming challenges. They tracked test-writing behavior, task resolution rates, and resource consumption across models using the lightweight mini-SWE-agent framework.
The results paint a nuanced picture. While most models frequently generated new test files as part of their problem-solving workflow, their propensity to test varied dramatically—from rarely writing tests at all (like GPT-5.2, which still achieved near-top resolution rates) to doing so routinely. Across different LLMs, the variability in testing behavior was substantial.
Tests Don't Predict Success#
Here's the key insight: within any single model, test-writing frequency didn't meaningfully differ between tasks the agent ultimately resolved and those it failed to fix. Encouraging or discouraging test writing through revised prompts did shift agent behavior on 36.8%-93.2% of tasks, yet resolution outcomes stayed nearly identical—varying by 0–13 successful fixes per 500 tasks, with no statistical significance. This suggests that agents can achieve the same success rate whether they test heavily or not.
Hidden Resource Differences#
The catch: while final success counts looked similar, the cost of achieving them diverged sharply. Three of the four models tested showed substantial differences in API calls and token consumption depending on whether they were prompted to write tests. Similar resolution totals can therefore mask wildly different patterns of testing and resource expenditure.
Inside the Tests#
When agents did write tests, the quality and intent varied. Test files contained significantly more statements that printed runtime values for inspection than assertions that checked whether conditions were true—a sign that the generated tests may function more as diagnostic tools than true validations.
The research suggests that agent-written tests, while common, are not a prerequisite for successful code repair and may represent an inefficient use of computational resources for many models.

