Manuscript Offprint

arXiv:2608.23341

DPIAgent: Divide, Protocol, Isolate for Agentic Reproduction Test Generation

Hao Liu, Steven Liu, Xin Zhang, Jane Luo, Yu Kang, Jie Wu, Fangkai Yang, Yangyu Huang, Pengfei Gao, Scarlett Li, Yan Lu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Hao Liu 1∗†^{1*†} Steven Liu 1∗†^{1*†} Xin Zhang 1∗‡^{1*‡} Jane Luo 1†^{1†} Yu Kang 1^{1} Jie Wu 1,2†^{1,2†}

Fangkai Yang 1^{1} Yangyu Huang 1^{1} Pengfei Gao 1^{1} Scarlett Li 1^{1} Yan Lu 1^{1}

1^{1}Microsoft 2^{2}Tsinghua University

Reproduction test generation, producing a failing-then-passing test that captures a reported bug, is a critical step in automated software engineering. Existing agentic methods treat this as a monolithic loop, despite the task inherently comprising two subtasks of distinct nature: diagnosing the root cause and writing a fail-to-pass test. Without explicit separation, the agent faces a compound objective with underspecified intermediate goals, leading to goal drift. We propose DPIAgent, a structured agentic framework built on three principles, Divide, Protocol, Isolate (DPI), that mitigates compound-objective ambiguity and goal drift: it Divides the task into single-objective phases of defect exploration and test generation; enforces a handoff Protocol that records the diagnosis and test plan, preventing context loss; and Isolates each phase's action space by tailoring the toolset to its task, preventing irrelevant tools from misleading execution. On SWT-Bench Verified, DPIAgent outperforms seven baselines across three backbone LLMs. With DPI alone it reaches 81.76% success rate on GPT-5, the highest reported among open-source methods, gaining up to 11.88 points over the strongest baseline on GPT-5-Mini; adding test selection further raises it to 86.17%. Our analysis shows that architectural structure and backbone capability are complementary axes rather than substitutes, demonstrating DPI's generalizability across model classes.

Project: https://neverwinhao.github.io/DPIAgent/

Correspondence: haoliu.ai@outlook.com; xinzhang3@microsoft.com

1 Introduction

Large Language Models (LLMs) [1–3] have demonstrated strong capabilities across various domains and are increasingly applied to code generation [4–6] and software engineering automation. A particularly important yet underexplored task is reproduction test generation: given a bug report, the goal is to produce a test that fails on the buggy code and passes after the fix. Despite its central role in the software development lifecycle, reproduction tests are rarely available in the test suite when an issue is first reported [7–9]. And developers widely consider writing tests a tedious and time-consuming task [10].

Existing approaches to reproduction test generation fall into two paradigms. The first follows a workflow design [11–13], where the task is decomposed into fixed pipeline stages such as localization, planning, and generation, with predefined control flow orchestrating LLM calls at each stage. The second adopts an agent paradigm [14–16], where the LLM is equipped with tools and dynamically decides which actions to take and when to terminate, without hardcoded stage transitions. The agent paradigm offers key advantages: it allows the model to pivot based on runtime observations and maintains reasoning continuity throughout the task, achieving strong performance on repository-level benchmarks [8, 17, 18]. Recent leading systems for repository-scale code tasks are predominantly agent-based; we therefore build our method in the agent paradigm.

However, while the agent paradigm offers flexibility, existing approaches treat reproduction test generation as a monolithic task, mixing exploration and test writing in an undifferentiated loop. In reality, this task inherently comprises two subtasks of distinct nature: understanding the root cause through code exploration, and producing a test satisfying

∗^{*}Equal contribution. ‡^{\ddagger}Corresponding author.

†^{\dagger}Work done during internships at Microsoft Research Asia.

Figure

(a) Success Rate S — higher is better

(b) Agent Steps — lower is better

Figure 1: Isolating DPI's contribution. Adding DPI to SWE-Agent yields consistent gains in success rate and reduces agent steps across three backbones. GPT-5-Mini+DPI surpasses GPT-5 SWE-Agent, indicating structural intervention can compensate for model scale.

the fail-to-pass criterion. Without explicit separation, the agent faces a compound objective with underspecified intermediate goals, which has been shown to systematically induce goal drift [19] and is identified as a primary failure mode for software engineering agents [20]. In practice, developers naturally follow a two-stage process of first localizing the root cause and then writing the test [21], suggesting that explicit decomposition aligns with the inherent structure of the task. Moreover, developers locate relevant code through their understanding of code structure and dependencies, whereas existing agents lack such awareness and rely on basic text-matching tools, demanding extensive back-and-forth in large repositories.

Motivated by these observations, we propose DPIAgent, an agent design that imposes structure only at phase boundaries while preserving a full agent loop within each phase. DPIAgent follows three principles—Divide, Protocol, Isolate (DPI). (D)ivide: DPIAgent replaces the monolithic loop with two sequential phases, defect exploration and test generation. Each phase has a single, well-defined objective, eliminating the compound-objective ambiguity of monolithic agents. (P)rotocol: Agents cannot transition silently: it must explicitly write down its diagnosis and test plan before entering the next phase. This forces an explicit handoff so no context is lost between exploration and test writing. (I)solate: Agents often struggle with tool distraction when exposed to an overly broad action space. To maintain focus, we tailor each phase's toolset strictly to its task, preventing irrelevant tools from misleading the agent's execution. In addition, we adopt a test selection step from e-Otter++ [12] that turns variance across diversified candidate runs into improved final output quality.

We evaluate DPIAgent on SWT-Bench Verified across three backbone LLMs (GPT-5-Mini [22], GPT-5 [22], and Claude-Opus-4.5), comparing against seven baselines spanning diverse agent architectures. Results show that DPIAgent consistently outperforms all baselines across all backbones, reaching 81.76% with DPI alone on GPT-5 (the highest among open-source methods on this benchmark) and 86.17% with test selection. Isolating DPI's effect from confounds in baseline architectures, we observe consistent gains across all backbones in both pass rate and step efficiency (Fig. 1). These gains diminish but persist as model capability grows, indicating that structural design and model scale are complementary axes rather than substitutes. Ablation studies verify the effectiveness of DPI's design components. First-edit quality analysis shows that DPI consistently improves pre-feedback test readiness across all backbones, especially benefiting weaker models that rarely recover from incomplete initial test designs.

Our contributions can be summarized as follows:

• We propose DPIAgent, a structured agentic framework that mitigates compound-objective ambiguity and goal drift in composite tasks via the DPI principles. It divides monolithic tasks into single-objective phases, enforces a structured handoff protocol to preserve context, and isolates phase-specific toolsets to prevent action-space distraction.

• On SWT-Bench Verified, DPIAgent outperforms seven baselines across three backbone LLMs. With DPI alone, DPIAgent reaches 81.76% success rate on GPT-5, the highest reported among open-source methods, and gains up to 11.88 points over the strongest baseline on GPT-5-Mini. Adding test selection further raises the result to 86.17% on GPT-5.

https://www.anthropic.com/news/claude-opus-4-5

Figure

Figure 2: Overview of DPIAgent. Following DPI, the pipeline has three stages: Divide splits exploration from test generation; Protocol passes diagnostic findings through a structured summary; and Isolate switches tools across the boundary while preserving context. A final Test Selection stage scores candidates against surrogate patches.

• Our analysis reveals that architectural structure and backbone capability are complementary axes rather than substitutes. DPIAgent yields the largest absolute gain on the weakest model, 11.88 points on GPT-5-Mini, demonstrating DPI’s generalizability across model classes. It further reaches peak pass rates in 3×3\times fewer steps, uniquely resolves 18+ issues, and improves function-level localization by 25+ Acc@5 points.

References (43)