面向可靠基础设施即代码的多智能体代码编排生成
Multi-Agent Code-Orchestrated Generation for Reliable Infrastructure-as-Code
AI总结:
本文提出多智能体架构 MACOG,通过专门角色、共享黑板编排、Terraform Plan 与 OPA 验证治理,可靠生成合规且语义连贯的 IaC,并在 IaC-Eval 上显著提升多模型表现。
摘要:
云原生基础设施日益复杂,使基础设施即代码(IaC)成为可复现、可扩展部署的关键。尽管大型语言模型(LLM)已展现出根据自然语言提示生成 IaC 代码片段的潜力,但其单体式、单次生成方法往往导致语法错误、策略违规和不可扩展的设计。本文提出 MACOG(Multi-Agent Code-Orchestrated Generation,多智能体代码编排生成),这是一种新颖的基于多智能体 LLM 的 IaC 生成架构,将任务分解为模块化子任务,并由专门智能体处理:Architect、Provider Harmonizer、Engineer、Reviewer、Security Prover、Cost and Capacity Planner、DevOps 和 Memory Curator。这些智能体通过共享黑板和有限状态编排层交互,共同生成不仅语法有效,而且符合策略、语义连贯的 Terraform 配置。为确保基础设施正确性和治理,我们引入 Terraform Plan 进行执行验证,并使用 Open Policy Agent(OPA)实施可定制策略。我们在 IaC-Eval 基准上评估 MACOG;MACOG 在各模型中均为最佳增强方案,例如 GPT-5 从 54.90(RAG)提升至 74.02,Gemini-2.5 Pro 从 43.56 提升至 60.13,同时在 BLEU、CodeBERTScore 和 LLM-judge 指标上取得提升。消融实验表明,约束解码和部署反馈至关重要:移除二者分别使 IaC-Eval 降至 64.89 和 56.93。
英文摘要:
The increasing complexity of cloud-native infrastructure has made Infrastructure-as-Code (IaC) essential for reproducible and scalable deployments. While large language models (LLMs) have shown promise in generating IaC snippets from natural language prompts, their monolithic, single-pass generation approach often results in syntactic errors, policy violations, and unscalable designs. In this paper, we propose MACOG (Multi-Agent Code-Orchestrated Generation), a novel multi-agent LLM-based architecture for IaC generation that decomposes the task into modular subtasks handled by specialized agents: Architect, Provider Harmonizer, Engineer, Reviewer, Security Prover, Cost and Capacity Planner, DevOps, and Memory Curator. The agents interact via a shared-blackboard, finite-state orchestrator layer, and collectively produce Terraform configurations that are not only syntactically valid but also policy-compliant and semantically coherent. To ensure infrastructure correctness and governance, we incorporate Terraform Plan for execution validation and Open Policy Agent (OPA) for customizable policy enforcement. We evaluate MACOG using the IaC-Eval benchmark, where MACOG is the top enhancement across models, e.g., GPT-5 improves from 54.90 (RAG) to 74.02 and Gemini-2.5 Pro from 43.56 to 60.13, with concurrent gains on BLEU, CodeBERTScore, and an LLM-judge metric. Ablations show constrained decoding and deploy feedback are critical: removing them drops IaC-Eval to 64.89 and 56.93, respectively.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。