arXiv:2610.33129cs.SEOct 2026

Manuscript Offprint

arXiv:2610.33129

Speculative Forking: Turning Idle Wait into Parallel Exploration for Repository Environment Setup

Yuling Shi, Mingchu Zhong, Zhensu Sun, Weihan Peng, Zhi Chen, Shilin He, Chengcheng Wan, Kai Cai, Hongyu Zhang, David Lo, Xiaodong Gu

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

Yuling Shi 1^{1}, Mingchu Zhong 1^{1}, Zhensu Sun 2^{2}, Weihan Peng 1^{1}, Zhi Chen 2^{2}, Shilin He 3^{3}, Chengcheng Wan 45^{45}, Kai Cai 6^{6}, Hongyu Zhang 7^{7}, David Lo 2^{2}, Xiaodong Gu 1^{1}

1^{1}Shanghai Jiao Tong University 2^{2}Singapore Management University

3^{3}The Chinese University of Hong Kong

4^{4}East China Normal University 5^{5}Shanghai Innovation Institute

6^{6}Independent Researcher 7^{7}Chongqing University

{yuling.shi,peng-weihan,xiaodong.gu}@sjtu.edu.cn

{zssun,zhi.chen.2023,davidlo}@smu.edu.sg

{selin.hsl,hopcookie,hongyujohn}@gmail.com, ccwan@sei.ecnu.edu.cn

Abstract—Before developers can use a software project, they must first get it to run. This often requires installing the right language runtime, system packages, build tools, and test commands. Recent LLM-based agents automate environment setup by inspecting a repository, writing setup scripts, running them, and repairing the resulting errors. However, these agents still follow a sequential trial-and-error loop: they try one setup route, wait for slow commands to finish, observe the failure, and only then decide what to try next. Because environment commands often take long to run, this sequential workflow makes setup slow and limits exploration to one route at a time.

We present SPECBUILD, an LLM-based environment setup system designed to be both faster and more successful through speculative forking. SPECBUILD explores candidate setup branches in parallel, returns the first committed environment, and discards the rest. It applies this design at two granularities: strategy-level forking explores alternative setup routes, such as different base images and dependency policies, while command-level forking predicts failures of running commands and prepares repair branches before those failures are observed.

We evaluate SPECBUILD on Multi-Docker-Eval, covering 334 tasks from 40 repositories and 9 programming languages. Across three backbone models, SPECBUILD improves the success rate by 6.4 to 12.0 percentage points over the strongest baseline, while reducing average setup time by 22.4% to 41.6%. These results show that LLM-based environment setup need not trade speed for reliability: parallel speculative exploration can make agents both faster and more successful.

I. INTRODUCTION

Before developers can modify, test, debug, or reuse a software project, they must first get it to run. Running a project's tests is central to validating code changes in both development and software-engineering research [1]. This requires matching language runtimes, system packages, build tools, environment variables, and test commands to the project at hand. Containerization makes this setup explicit through artifacts such as Dockerfiles, which have been widely studied as software-engineering and DevOps artifacts [2]–[4]. Yet writing these artifacts remains difficult: developers report Docker and DockerCompose specifications as time-consuming, and prior work observes that they require system-administration knowledge and project-specific adaptation [2], [5], [6]. Environment setup is therefore a practical bottleneck for developers before they can run tests, reproduce bugs, or validate fixes.

This bottleneck is amplified by recent efforts to make software-engineering tasks verifiable at scale. Benchmarks and training pipelines for coding agents require executable environments in which tests can be run against real repositories [7]–[12]. Recent systems now scale this construction to tens of thousands or even millions of environments [13], [14]. In this setting, setup time is no longer a one-time inconvenience: each failed or slow construction attempt becomes a recurring wall-clock cost for evaluation, data generation, and developer workflows.

Recent work has started to automate environment setup with LLM-based agents. These agents inspect repository files, generate setup scripts, run them in containers, read execution errors, and revise the scripts until the tests pass or a budget is exhausted [1], [15], [16]. Newer systems broaden this automation across languages, repositories, and training-data pipelines [16]–[18]. This feedback-driven loop also appears in broader software-engineering agents, which execute tools, observe feedback, and use that feedback to plan later actions [19]–[21]. In environment setup, however, the loop is typically sequential: the agent tries one setup route, waits for slow commands such as package installation, dependency resolution, and compilation to finish, observes the result, and only then decides what to try next [1], [15], [16].

This sequential structure exposes two uncertainties in environment setup. First, the agent faces route uncertainty: it does not know which setup route, including choices such as the base image, runtime, package manager, and dependency policy, will build the repository. A sequential loop can validate only one route at a time, so failed routes consume time and iteration budget before other plausible routes are tried. Second, the agent faces command-outcome uncertainty: slow setup commands may fail, but a sequential loop waits for the failure before preparing a repair. Together, these uncertainties couple wall-clock time and success: slow feedback makes each trial expensive, and one-route-at-a-time search limits how broadly the agent can explore.

Figure

Fig. 1. Timeline comparison on polarsignals/frostdb. The sequential agent waits for go mod download to fail before diagnosing and retrying, whereas speculation predicts the missing Go toolchain during the idle waiting interval and prepares an apk-based repair branch in advance.

Our insight is to address both uncertainties with speculative forking. Rather than waiting for one setup future to fail before considering another, SPECBUILD explores candidate setup branches in parallel, returns the first committed environment, and discards the rest. We apply this primitive at two granularities. Strategy-level forking explores alternative setup routes, such as different base images, runtimes, and dependency policies, addressing route uncertainty. Command-level forking predicts the failure of a currently running command and prepares a repaired branch before the failure is observed, addressing command-outcome uncertainty. In both cases, speculation is predict-then-verify: branches only matter if real execution validates them.

We implement SPECBUILD for LLM-based environment setup and evaluate it on Multi-Docker-Eval [22], a benchmark of 334 environment-construction tasks drawn from 40 real-world repositories and 9 programming languages. Across three backbone models, SPECBUILD improves the success rate by 6.4 to 12.0 percentage points over the strongest baseline, while reducing average setup time by 22.4% to 41.6%. The results support the central claim of this paper: LLM-based environment setup need not trade speed for reliability, because parallel speculative exploration can make agents both faster and more successful.

In this paper, we make the following contributions:

• A dual objective for environment setup. We formulate LLM-based environment setup as a dual-objective problem: improve the success rate while reducing wall-clock setup time. This framing captures the practical cost that developers and large-scale evaluation pipelines pay when sequential setup attempts fail slowly.

• Speculative forking and its two granularities. We introduce speculative forking, a fork, explore, commit, and discard primitive over isolated setup branches, at two granularities: strategy-level forking races alternative setup routes, while command-level forking prepares repairs for likely command failures in advance.

• Implementation and multi-language evaluation. We implement SPECBUILD and evaluate it on Multi-Docker-Eval across three backbone models and 9 programming languages, measuring end-to-end success and time, isolating each granularity’s contribution, analyzing the branch-budget trade-off, and illustrating the mechanism through a case study. We release our implementation at https://anonymous.4open.science/r/Speculative-Forking-C907.

References (51)