MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration

Miseon Yu, Jaehoon Choi, Younghan Lee, Yunheung Paek
8/26/2026
cs.CRcs.AIcs.MA

No confident code implementation found for this paper. 5 possible matches can be shown below.

Abstract

Despite their strong ability to generate code, large language models often fail to produce secure code, as their outputs frequently contain security vulnerabilities. Secure code generation is inherently challenging because it requires solving a multi-objective problem: functional correctness and security. Existing approaches address this challenge by injecting external security knowledge or by using agentic feedback and iterative refinement. However, guideline retrieval often leaves the generator to translate generic advice into task-specific secure implementations, while shared-dialogue multi-agent feedback can blur role boundaries and suffer from context bloat. We present MACGen, a multi-agent framework that integrates planning, security analysis, code synthesis and refinement to jointly optimize security and functionality. A planner constructs a step-by-step plan to satisfy functional requirements. A security advisor identifies likely CWEs and synthesizes task-specific guidelines, a coder then generates code grounded in these artifacts, and a reviewer issues perspective-separated feedback. Rather than sharing full dialogue histories, each agent receives only structured artifacts from upstream stages, enforcing role specialization and reducing uncontrolled context growth. On CWEval and BaxBench, MACGen improves F&S@1 over direct prompting by 19.61 and 10.57 percentage points (pp) on average, respectively.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 5 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yu2026macgen,
  title  = {MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration},
  author = {Miseon Yu and Jaehoon Choi and Younghan Lee and Yunheung Paek},
  year   = {2026},
  eprint = {2608.25457},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.25457v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2608.25457.svg)](https://codeofpaper.com/paper/2608.25457)

Discussion