MEnvAgent: Scalable Polyglot Environment Construction for Verifiable Software Engineering

Chuanzhe Guo, Jingjing Wu, Sijun He, Yang Chen, Zhaoqi Kuang, Shilong Fan, Bingjin Chen, Siqi Bao, Jing Liu, Hua Wu, Qingfu Zhu, Wanxiang Che, Haifeng Wang

Introduction

The evolution of Large Language Model (LLM) agents for software engineering (SWE) is heavily constrained by a critical bottleneck: the scarcity of verifiable datasets. To truly evaluate whether an AI agent has fixed a bug, one cannot simply inspect the code; the code must be executed. This requires a verifiable environment—a sandbox configured with the precise compilers, libraries, and dependencies necessary to run tests.

Unfortunately, constructing these environments across diverse repositories is notoriously difficult due to "dependency hell." Conflicting versions, non-standard build tools, and brittle setup scripts make environment creation a nightmare. Consequently, most high-quality datasets are manually curated and restricted to Python. To overcome this lack of scalable, multi-language (polyglot) environments, researchers have introduced MEnvAgent, a novel multi-agent framework that automates the creation of executable, verifiable Docker environments across 10 different programming languages.

Methodology: A Dynamic Multi-Agent Approach

MEnvAgent departs from traditional static scripting by treating environment construction as a dynamic, iterative problem-solving task managed by specialized agents. The framework relies on two core innovations:

1. The Planning-Execution-Verification Loop

  • Planning: A Repository Analysis Agent scans the target codebase to identify its language and build system. Subsequently, an Environment Setup Agent drafts an installation script, while a Test Configuration Agent generates the test runner.
  • Execution: An Environment Execution Agent attempts to build the container while monitoring terminal output in real-time. If a command fails (e.g., due to a missing package), the agent attempts a dynamic, on-the-fly fix.
  • Verification: Finally, a Verification Agent executes the tests. If failures occur, it performs "error attribution" to determine whether the fault lies in a misconfigured environment or a flawed test, feeding this diagnostic signal back to the planning stage for a retry.

2. Environment Reuse Mechanism

Building every environment from a clean slate is computationally expensive and slow. MEnvAgent mitigates this by maintaining a pool of successful historical environments. When tasked with a new repository, it identifies the most similar existing environment and deploys an EnvPatchAgent to synthesize an incremental patch. This "warm start" approach bypasses the heavy lifting of reinstalling base OS packages, drastically reducing computational overhead.

New Datasets: MEnvBench and MEnvData-SWE

To benchmark and train future models, the paper introduces two major open-source contributions:

  • MEnvBench: A rigorous benchmark for evaluating environment construction tools, comprising 1,000 tasks across 10 mainstream languages (including Python, Java, Go, and C++) sourced from 200 real-world GitHub repositories.
  • MEnvData-SWE: Currently the largest open-source polyglot dataset of its kind. It features 3,005 task instances complete with verifiable Docker environments and expert "solution trajectories" designed to train superior SWE agents.

Key Insights and Results

MEnvAgent demonstrates that treating build failures as diagnostic feedback is highly effective; LLMs excel at interpreting compiler errors to iteratively correct missing dependencies. Furthermore, the framework highlights that polyglot complexity varies significantly: modern languages with unified package managers (like Go and Python) are much easier for AI to handle than system-level ecosystems (like C++ and Java).

Empirical evaluations showcase substantial improvements:

  • Efficiency: The Environment Reuse Mechanism slashed the average time required to build an environment by 43%, dropping from ~6,266 seconds (baseline) to 3,574 seconds.
  • Effectiveness: MEnvAgent achieved an average Fail-to-Pass (F2P) rate of 38.4%, outperforming the state-of-the-art SWE-Factory baseline by 8.6%.
  • Downstream Impact: Fine-tuning open-source models on the MEnvData-SWE dataset yielded striking results. Notably, the Qwen2.5-Coder-32B model matched the performance of GPT-4.1 on the SWE-bench Verified benchmark, proving that high-quality, verifiable environment data acts as a massive force multiplier for model capabilities.

Limitations and Future Work

Despite these advancements, system-level languages like C and C++ remain the "final bosses" of automated environment construction. MEnvAgent struggled with C++ tasks primarily due to memory exhaustion (OOM)—complex template expansions crashed 22% of the containerized sandboxes—and non-standard build systems like Bazel or Nix, which require highly specific contextual knowledge.

Future work will need to focus on "resource-aware" sandboxes capable of dynamically allocating RAM for heavy compilations, alongside specialized toolsets tailored for the unique challenges of legacy and system-level languages.

Summary updated

BibTeX
@inproceedings{guo2026menvagent,
  author = {Chuanzhe Guo and Jingjing Wu and Sijun He and Yang Chen and Zhaoqi Kuang and Shilong Fan and Bingjin Chen and Siqi Bao and Jing Liu and Hua Wu and Qingfu Zhu and Wanxiang Che and Haifeng Wang},
  title = {{MEnvAgent: Scalable Polyglot Environment Construction for Verifiable Software Engineering}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=Mkal0hTCnh},
}
Figure