AI 中文总结
本文提出多智能体框架AgentExecutor,通过三阶段设计和自适应优化策略提升部分代码执行效果,在两个数据集上的覆盖度、执行时间和成本均优于现有最优方法Treefix。
AI 中文摘要
执行代码片段对于动态程序分析至关重要,但由于缺少上下文和不完整的依赖项等问题,执行任意代码片段仍然具有挑战性。现有的部分代码执行方法(如LExecutor和Treefix)利用语言模型的能力推断缺失信息以实现执行,但它们存在两个问题:(1)动作空间和反馈有限;(2)优化策略僵化,这限制了其有效性和效率。本文提出了一种用于部分代码执行的新型多智能体框架AgentExecutor,该方法采用三阶段设计:执行环境准备、带迭代优化的动态探索,以及通过程序合成实现的前缀演化。借助能够迭代思考、行动并获取反馈的大语言模型(LLM)智能体的支持,AgentExecutor能够自主探索更丰富的动作空间,支持创建资源文件、解析环境配置等多样化操作;此外,它采用自适应优化策略,包括覆盖度引导的上下文剪枝和通过程序合成实现的前缀演化,以系统性提升部分代码的执行质量。我们在两个广泛使用的数据集上对AgentExecutor进行评估,这两个数据集分别包含Stack Overflow代码片段和开源项目代码。结果显示,AgentExecutor的代码覆盖度分别达到94%和90%,分别比当前最优方法Treefix高出19.9%和13.8%;此外,AgentExecutor还显著降低了执行时间(最高降低80.3%)和成本(最高降低56.6%)。这些结果表明,AgentExecutor为部分代码执行提供了一种有效且高效的解决方案。
英文摘要
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.
CommentsASE 2026