Skip to content
Preprint

TDD-Agent: Test-Driven Reasoning for Code Generation

Aug 2026 · 0 citations · 27 references
Computer Science

TL;DR

TDD-Agent is introduced, which operationalizes the test-driven development paradigm for code generation and 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.

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

Similar papers

Review Jul 2026

Multi-Agent LLM Collaboration for Unit Test Generation via Human-Testing-Inspired Workflows

TestAgent is proposed, an LLM-based test generation approach that addresses the above limitations by emulating human testing practices via a multi-agent collaboration mechanism and equips TestAgent with a set of tool APIs that can be invoked dynamically in an on-demand and adaptive manner.

Quanjun Zhang, Ye Shang, Siqi Gu et al. · 0 citations
Book Open access Jul 2026

TestAgent: A Multi-Agent LLM Framework for Repository-Level Unit Test Generation

TestAgent, a multi-agent tool implemented as a VS Code extension that automates the generation of high-quality unit tests for Java projects using repository-level Code Knowledge Graphs, demonstrates its practical utility for regression testing and bug discovery.

Ye Shang, Quanjun Zhang, Zheng Zhan et al. · 0 citations
Preprint Aug 2026

Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generation

It is shown that test suites generated by the spec-driven agent are superior to the baseline and human-authored tests in 77.8% and 56.7% of the cases, respectively, and demonstrated improvements on following best practices, readability, and edge-case coverage.

Michele Tufano, James McClure, José Cambronero et al. · 0 citations
Book Open access Aug 2026

BiVCoder: A Multi-Agent Framework for Code Generation via Bidirectional Code-Test Diagnosis

Large Language Models (LLMs) have demonstrated remarkable potential in automated code generation. However, existing test-driven code generation and refinement frameworks are often hindered by the tests' quality: they typically treat self-generated tests as ground truth, leading to ineffective debugging loops where code is modified to satisfy erroneous tests. To address this, we propose BiVCoder, a diagnosis-driven multi-agent framework featuring a novel bidirectional code-test diagnosis mechanism. BiVCoder coordinates three specialized agents—Coding Agent, Test Agent, and Review Agent. Central to this architecture is the Review Agent, which serves as a diagnosis and decision-making hub. By integrating an MCP-based code-test execution tool, the Review Agent rigorously executes programs to diagnose failure root causes, distinguishing between implementation bugs and test case deficiencies, and subsequently triggers targeted repairs (Coding Agent or Test Agent). Furthermore, we introduce BiVCoder-SFT, a role-specific instruction fine-tuning scheme. We construct high-quality datasets to fine-tune the Qwen3-4B base model into specialized agents for coding, testing, and reviewing. Extensive experiments on HumanEval, MBPP, and their rigorous ''ET'' variants demonstrate the superiority of our approach. With GPT-3.5, BiVCoder achieves a Pass@1 of 77.3%. Notably, the specialized BiVCoder-SFT achieves an average score of 79.5% across the four datasets, not only outperforming its base model (69.7%) but also surpassing larger general-purpose models such as Qwen3-8B (77.8%). Additionally, BiVCoder boosts the performance of more powerful models, improving DeepSeek-V3.2 from 87.2% to 92.1% on HumanEval.

Xiaoyang Li, Jinhao Dong, Wenhang Shi et al. · 0 citations
Preprint Aug 2026

A Unified Issue Resolution Benchmark for Requirement Clarification, Planning, and Code Generation for Coding Agents

SWE-RPG is introduced, a repository-level benchmark that combines executable patch evaluation with validated ground-truth references (GTs) for Requirement Clarification and Implementation Planning, and suggests implicit-requirement recovery as a key candidate direction for improving coding agents.

Xin Zhou, C. Chong, Kisub Kim et al. · 0 citations
#computer vision Review Aug 2026

REFINE: A Multi-Agent LLM Approach for Evidence-Guided Code Refactoring

Large Language Models (LLMs) offer new opportunities for automated code refactoring. However, generated changes must reduce targeted quality problems without introducing new issues or altering behaviour-relevant code structures. We introduce REFINE (Refactoring with Evidence-aware Flow for Integrated ageNtic Execution), a tool-agnostic, evidence-aware multi-agent approach for generating Java file-level refactoring candidates. REFINE combines static-analysis-guided smell identification, smell-informed planning, LLM-based transformation, automated re-analysis, preservation checks, and structured reporting. We evaluate REFINE on 450 Java files from 15 open-source systems, producing 1,350 model-pass outputs using OpenAI GPT-5.5, Google Gemini 3.1 Pro Preview, and Anthropic Claude Opus 4.8. REFINE reduces detected code smells by 68.26%, 72.79%, and 68.49% across the three configurations, respectively, with the strongest reductions observed for major smells. A matched 150-file direct-prompt baseline shows that REFINE achieves a higher median code-smell reduction with smaller edits and fewer public-method removals. However, broader quality improvements are inconsistent, and preservation checks reveal residual risks, including assert/fail-call changes and public-method removal. Therefore, REFINE outputs should be treated as refactoring candidates requiring compilation, testing, dependency analysis, and human review before adoption in repository- or system-level settings.

Muhammad Waseem, Aakash Ahmad, Pekka Abrahamsson · 0 citations