Source note2 min read

TDD-Agent: Test-Driven Reasoning for Code Generation

Source

arXiv

arxiv.org/abs/2608.16742v1

Read the source

Source

  • Source name: arXiv
  • Source kind: paper
  • Authors / organization: Hongyue Yu, Kefan Li, Jiakun Li, Hongzheng Chai, Yuan Yuan, Rui He, Junyi Wei
  • Venue: arXiv: cs.SE
  • Published: 2026-08-17
  • Collected: 2026-08-18
  • URL: http://arxiv.org/abs/2608.16742v1
  • PDF: https://arxiv.org/pdf/2608.16742v1
  • DOI: UNKNOWN
  • Registry group: academic_apis_and_preprints
  • Evidence role: canonical_academic_index
  • Language: en
  • Country / region: UNKNOWN

Plain-Language Brief

Researchers introduce TDD-Agent, a system that uses the test-driven development (TDD) paradigm for code generation. The system first generates tests to clarify expected behaviors before implementation and then refines both the generated code and tests using execution feedback. TDD-Agent outperforms existing approaches on a benchmark for complex, repository-level tasks.

What the Document Says

  • TDD-Agent operationalizes test-driven development for code generation.
  • It prompts the model to generate executable tests and then performs iterative dual-track refinement over both generated code and tests.
  • The researchers evaluate TDD-Agent on LiveCodeBench and RepoEval benchmarks, showing it outperforms existing approaches.
  • Iterative refinement improves not only code correctness but also the effectiveness of the generated tests.

Key Concepts Mentioned

  • Test-driven development
  • Code generation
  • Large Language Models
  • Execution feedback
  • LiveCodeBench
  • RepoEval

Claims Made by the Document

  • TDD-Agent improves upon reasoning-based prompting baselines on LiveCodeBench.
  • TDD-Agent outperforms retrieval-based and agent-based baselines on RepoEval.

Evidence Used

  • Improvements shown through evaluation on LiveCodeBench and RepoEval benchmarks.

Methods / Approach

  • Prompting the model to generate executable tests, iterative dual-track refinement over both generated code and tests using execution feedback

Limitations Stated by the Authors

The paper does not discuss potential limitations of TDD-Agent in detail.

Limitations Noted by the Agent

Agent interpretation — not from the source.

  • As a research paper, the implementation may have limitations that are not yet identified or addressed.
  • The effectiveness of TDD-Agent might be different in real-world scenarios compared to benchmark environments.

Open Questions

  • What are the potential challenges and solutions for implementing TDD-Agent in a real-world development environment?
  • How does TDD-Agent handle edge cases or unexpected behaviors during code generation?

Notes for Future Q&A

May include interpretation. Labeled where it does.

  • It is important to consider the practicality and scalability of TDD-Agent when implementing it in real-world scenarios.

Raw Abstract / Excerpt

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. 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/.