Skip to content

TddInAgentLoop

Dennis Lee edited this page Aug 17, 2026 · 1 revision

title: TDD in the Agent Loop radar_quadrant: Techniques radar_ring: Hold radar_position:

TDD in the Agent Loop

TDD in the agent loop is the practice of having an AI coding agent independently write a failing test and then its implementation, inside its own autonomous reasoning loop, rather than a human writing or reviewing the tests. The pattern was evaluated by Birgitta Böckeler in an exploratory study on the Martin Fowler site, comparing agent-driven TDD against agent-driven non-TDD across five task batches, using one model to generate code and a second model to judge output quality.

The study found no clearly discernible quality difference between the TDD and non-TDD workflows, and non-TDD solutions often scored higher. The author's working explanation is that TDD's incremental style locks in early design decisions before the agent has seen the full shape of the problem, producing narrower, less complete implementations than an agent that designs the architecture comprehensively up front. Mutation testing scores were similar regardless of workflow, suggesting the TDD discipline did not translate into measurably better regression coverage either.

Radar Assessment

Placed in Techniques / Hold.

This is a caution-flagging technique rather than a recommendation: the evidence available so far suggests that porting TDD discipline into an agent's own reasoning loop does not reliably produce better code, and may produce narrower designs than letting the agent plan the full architecture before implementing. Teams tempted to enforce "write the failing test first" as a rule for agents should treat that as unproven rather than assumed-beneficial.

The study itself carries real caveats: a small sample across five task batches, quality judged largely by another model rather than a human, and scope limited to greenfield business logic. It does not establish that TDD-in-the-loop is harmful, only that its benefit is not yet demonstrated. Hold reflects "proceed with caution," not "avoid" — a larger or more targeted study could move this to Assess or further clarify a Trial path.

References

Clone this wiki locally