🤖 AI Summary
This work addresses the challenge of generating executable code from partial snippets with missing context and dependencies, a task where existing methods are hindered by limited action spaces, inadequate feedback mechanisms, and suboptimal optimization strategies. To overcome these limitations, we propose a large language model–based multi-agent framework that operationalizes partial code through a three-stage pipeline: dynamic execution environment construction, coverage-guided context pruning with iterative refinement, and program-synthesis-driven prefix evolution. This approach substantially expands the action space and enables adaptive optimization. Experimental results demonstrate that our method achieves 94% and 90% code coverage on Stack Overflow and open-source project datasets, respectively—outperforming Treefix by 19.9% and 13.8%—while reducing execution time by 80.3% and computational cost by 56.6%.
📝 Abstract
Executing code snippets is essential for dynamic program analysis, but it remains challenging to execute an arbitrary code snippet due to issues like missing context and incomplete dependencies. Existing approaches to partial code execution, such as LExecutor and Treefix, leverage the power of language models to infer missing information and enable execution. However, they suffer from (i) limited action spaces and feedback, and (ii) rigid optimization strategies, which restrict their effectiveness and efficiency. In this paper, we propose AgentExecutor, a novel multi-agent framework for partial code execution. Our approach introduces a three-phase design: execution environment preparation, dynamic exploration with iterative refinement, and prefix evolution via program synthesis. Supported by the power of LLM agents who can think, act, and get feedback iteratively, AgentExecutor is able to autonomously explore a richer action space, enabling diverse operations such as creating resource files and resolving environment configuration. Furthermore, it adopts adaptive optimization strategies, including coverage-guided context pruning and prefix evolution via program synthesis, to systematically improve the execution quality of partial code. We evaluate AgentExecutor on two widely used datasets comprising Stack Overflow snippets and open-source project code. The results show that AgentExecutor achieves up to 94% and 90% code coverage, outperforming the state-of-the-art approach Treefix by 19.9% and 13.8%, respectively. In addition, AgentExecutor significantly reduces execution time (by up to 80.3%) and cost (by up to 56.6%). These findings demonstrate that AgentExecutor provides an effective and efficient solution for partial code execution.