TDD-Agent: Test-Driven Reasoning for Code Generation

Hongyue Yu, Kefan Li, Jiakun Li, Hongzheng Chai, Yuan Yuan +2 more
8/17/2026
cs.SEcs.AI

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) have achieved remarkable progress in code generation, yet ensuring correctness in complex, repository-level tasks remains challenging. Existing approaches often use generated tests as static post-hoc validators, which limits their ability to guide implementation and may introduce misleading feedback when the tests themselves are incomplete or incorrect.

Show full abstract

In this paper, we introduce TDD-Agent, which operationalizes the test-driven development paradigm for code generation. TDD-Agent first prompts the model to generate executable tests, encouraging it to clarify expected behaviors before implementation, and then performs iterative dual-track refinement over both the generated code and tests using execution feedback. We first isolate the effect of test-first reasoning through a prompt variant TDD-prompt on LiveCodeBench, where it consistently improves upon reasoning-based prompting baselines. Building on this finding, we evaluate the full TDD-Agent framework on RepoEval, a repository-level benchmark, and show that it consistently outperforms retrieval-based and agent-based baselines. Additional analyses show that iterative refinement improves not only code correctness but also the effectiveness of the generated tests, yielding higher pass rates, coverage, and mutation scores, suggesting that tests can serve as evolving reasoning artifacts rather than fixed validators. Our source code is available at https://anonymous.4open.science/r/TDD-Agent-Framework-6370/.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yu2026tddagent,
  title  = {TDD-Agent: Test-Driven Reasoning for Code Generation},
  author = {Hongyue Yu and Kefan Li and Jiakun Li and Hongzheng Chai and Yuan Yuan and Rui He and Junyi Wei},
  year   = {2026},
  eprint = {2608.16742},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.16742v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2608.16742.svg)](https://codeofpaper.com/paper/2608.16742)

Discussion