InfCode: Adversarial Iterative Refinement of Tests and Patches for Reliable Software Issue Resolution

KeFan Li, Mengfei Wang, Hengzhi Zhang, Zhichao Li, Yuan Yuan, Mu Li, Xiang Gao, Hailong Sun, Chunming Hu, Weifeng LvarXiv 2025 · OpenReview

Abstract

Large language models have advanced software engineering automation, yet resolving real-world software issues remains difficult because it requires repository-level reasoning, accurate diagnostics, and strong verification signals. Existing agent-based and pipeline-based methods often rely on insufficient tests, which can lead to patches that satisfy verification but fail to fix the underlying defect. We present InfCode, an adversarial multi-agent framework for automated repository-level issue resolution. InfCode iteratively refines both tests and patches through adversarial interaction between a Test Patch Generator and a Code Patch Generator, while a Selector agent identifies the most reliable fix. The framework runs inside a containerized environment that supports realistic repository inspection, modification, and validation. Experiments on SWE-bench Lite and SWE-bench Verified using models such as DeepSeek-V3 and Claude 4.5 Sonnet show that InfCode consistently outperforms strong baselines. It achieves 79.4% performance on SWE-bench Verified, establishing a new state-of-the-art.

Introduction

While Large Language Models (LLMs) have become remarkably good at writing small code snippets, resolving real-world software issues remains a significant challenge. These issues often span multiple files, involve complex dependencies, and require a deep understanding of project-specific invariants.

A critical weakness in current autonomous agents is the reliance on insufficient verification signals. Most existing systems generate a patch and check it against a few basic tests; if the tests pass, the agent assumes the job is done. However, these tests are often too weak to catch subtle regressions or edge cases, leading to "overfitting" where a patch satisfies the test but fails to fix the underlying defect in production.

The InfCode Framework

InfCode introduces a dual-agent adversarial mechanism designed to simulate a rigorous "arms race" between testing and development. The process is split into two main stages:

1. Adversarial Iterative Refinement

In this stage, a Test Patch Generator analyzes the issue report and creates or strengthens test cases to expose the bug. Simultaneously, a Code Patch Generator attempts to modify the repository to pass the current suite of tests. This creates a loop: if the Code Generator produces a passing patch, the Test Generator re-analyzes the issue to find missing edge cases, creating even tougher tests. This continues until a hard cap is reached or the code passes the most stringent tests the agent can devise.

2. Patch Selection

After generating several candidate patches, a Selector Agent evaluates them based on functional correctness, test coverage, and execution success within a containerized environment. It identifies the most reliable and generalizable fix to be the final output.

InfCode framework architecture showing the adversarial iterative process and tool box.

The entire framework operates within a containerized Docker environment equipped with a specialized tool suite—including Bash, Editor, Searcher, Submitter, and Executor—ensuring that all repository modifications and test executions are reproducible and isolated.

Experimental Evaluation

InfCode was evaluated using two primary benchmarks:

  • SWE-bench Lite: A subset of 300 real-world GitHub issues used for lightweight evaluation and comparison against existing baselines.
  • SWE-bench Verified: A more rigorous version of the benchmark where both the solutions and the tests have undergone manual human validation to ensure high quality.

Results and Analysis

InfCode establishes a new state-of-the-art performance. Using Claude 4.5 Sonnet, it achieved a 79.4% solve rate (397/500) on SWE-bench Verified, ranking #1 on the leaderboard at the time of publication.

On the SWE-bench Lite benchmark, InfCode using DeepSeek-V3 solved 40.33% (121/300) of issues, outperforming strong baselines like KGCompass and Moatless Tools. Notably, InfCode achieved these results with significantly lower API costs compared to GPT-4 based agents ($0.26 vs $2.53 per problem for some baselines).

Performance comparison on SWE-bench Lite, showing InfCode's superior resolution rate and cost-efficiency.

Ablation studies revealed that while the adversarial loop is vital, the Selector Agent provided the largest boost in performance. This suggests that LLMs are often capable of generating the correct fix but require a dedicated "critic" stage to distinguish the best solution from several "mostly correct" ones. Furthermore, InfCode demonstrated a unique problem-solving capability, resolving 11 issues that no other baseline could solve.

Conclusion

InfCode demonstrates that code quality is a function of test quality. By forcing agents to compete, the system naturally discovers the "true semantics" of a bug report that a single-pass generation might miss. While challenges remain regarding test faithfulness and tooling robustness, InfCode's adversarial co-evolution approach represents a significant step forward in automated software engineering.

Summary updated

BibTeX
@misc{li2025infcode,
  author = {KeFan Li and Mengfei Wang and Hengzhi Zhang and Zhichao Li and Yuan Yuan and Mu Li and Xiang Gao and Hailong Sun and Chunming Hu and Weifeng Lv},
  title = {{InfCode: Adversarial Iterative Refinement of Tests and Patches for Reliable Software Issue Resolution}},
  year = {2025},
  eprint = {2511.16004},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.16004},
}
Figure