arXiv:2510.08665cs.SEcs.AI2025-10被引 3

用多智能体协作让代码生成更安全可控,支持动态调用外部工具。

RA-Gen: A Controllable Code Generation Framework Using ReAct for Multi-Agent Task Execution

  • 四智能体协同:规划、搜索、生成、提取,分工明确。
  • 在SVEN数据集上安全率94.8%,优于现有方法。
  • 推理过程透明,用户可干预,适合高安全性场景。

基于大语言模型的代码生成模型已广泛应用,但在复杂任务中仍面临安全、准确性和可控性挑战。现有方法常缺乏对外部工具的动态集成、透明推理以及用户对安全性的控制。为此,我们提出一种基于ReAct范式的多智能体任务执行可控代码生成框架。该框架采用四智能体协作架构:Planner负责任务分解,Searcher利用ReAct框架实现推理与工具融合,CodeGen负责精准代码生成,Extractor用于结构化数据提取。ReAct-based Searcher交替生成推理轨迹与执行动作,实现内部知识与外部工具(如搜索引擎)的无缝整合,提升准确性与用户控制力。实验表明,该框架在多种语言下表现优异,在SVEN数据集上使用CodeQL检测的安全率达到94.8%,显著优于现有方法。其透明推理过程增强了用户信任,提升了可控性。

原文摘要 · Abstract (English)

Code generation models based on large language models (LLMs) have gained wide adoption, but challenges remain in ensuring safety, accuracy, and controllability, especially for complex tasks. Existing methods often lack dynamic integration of external tools, transparent reasoning, and user control over safety. To address these issues, we propose a controllable code generation framework utilizing the ReAct paradigm for multi-agent task execution. This framework is a multi-agent system designed to enable efficient, precise, and interpretable code generation through dynamic interactions between LLMs and external resources. The framework adopts a collaborative architecture comprising four specialized agents: a Planner for task decomposition, a Searcher that leverages the ReAct framework for reasoning and tool integration, a CodeGen agent for accurate code generation, and an Extractor for structured data retrieval. The ReAct-based Searcher alternates between generating reasoning traces and executing actions, facilitating seamless integration of internal knowledge with external tools (such as search engines) to enhance accuracy and user control. Experimental results show the framework's effectiveness across multiple languages, achieving a 94.8% security rate on the SVEN dataset with CodeQL, outperforming existing approaches. Its transparent reasoning process fosters user trust and improves controllability.

代码生成多智能体ReAct可控性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。