一句话:提出多智能体框架 AgentExecutor,利用 LLM 智能体迭代生成上下文与优化策略,高效执行部分代码片段。
执行代码片段对动态程序分析至关重要,但任意片段常因缺失上下文和不完整依赖而难以运行。现有 LExecutor 和 Treefix 等方法借助语言模型推断缺失信息,却受限于动作空间与反馈不足、优化策略僵化。本文提出 AgentExecutor,一个用于部分代码执行的多智能体框架,采用三阶段设计:执行环境准备、带迭代精化的动态探索、通过程序合成进行前缀演化。LLM 智能体能够思考、行动并迭代获取反馈,自主探索更丰富的动作空间,如创建资源文件和解析环境配置,同时采用覆盖率引导的上下文剪枝与程序合成前缀演化等自适应优化策略。在 Stack Overflow 代码片段和开源项目代码两个数据集上,AgentExecutor 最高达到 94% 和 90% 的代码覆盖率,较 Treefix 分别提升 19.9% 和 13.8%,并显著降低执行时间(最高 80.3%)和成本(最高 56.6%)。
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.
@inproceedings{paperbot12493,
title = {AgentExecutor: Partial Code Execution via Agentic Context Generation},
author = {Junkai Chen and Chengran Yang and Xing Hu and Zhenhao Li and Xin Xia and David Lo},
booktitle = {ASE},
year = {2026},
doi = {10.1145/3832783.3834355}
}