The Pulse
MAGS Verifies Agent-Written Code, Then Exposes Its Limits
The MAGS framework translates agent-generated programs into Dafny and verifies them against frozen specifications, while its authors warn that incomplete auto-formalized semantics may fail to capture target behavior.

AI.info Team ·
A new system aims to give agent-generated programs formal safety guarantees by translating them into Dafny, checking them against frozen specifications, repairing violations and compiling verified programs back into executable code.
MAGS, described in a paper submitted to arXiv on September 16, evaluates the approach across 220 examples: 100 CUDA kernels, 100 terminal scripts and 20 robotic-arm tasks. The abstract says the system achieved a 100% success rate in producing programs with non-trivial safety guarantees against frozen specifications.
“Across all 220 examples, it achieves a 100% success rate in producing programs with non-trivial safety guarantees against frozen specifications.”
The paper presents Dafny as a verification-aware intermediate representation. Safety properties are encoded there so they can be checked mechanically before the resulting programs are compiled back into their executable form.
The benchmark covers three different categories of generated software. CUDA kernels represent parallel GPU programs. Terminal scripts test a separate class of executable programs, while the robotics benchmark involves robotic-arm tasks. The paper’s abstract describes the framework as a unified multi-agent system designed to generate executable programs with formal safety guarantees.
Guarantees Depend on the Specification
MAGS does not claim that a certificate establishes safety in every real-world sense. Its guarantees apply to the properties represented in the frozen specifications used by the verification pipeline.
That distinction is central to the paper’s evaluation. Alongside the formal verification results, the authors report independent safety and functional evaluations across all three domains. Those evaluations reveal failures when the auto-formalized semantics do not fully capture the behavior of the target programs.
The result sets a clear boundary around what the system proves. A program can satisfy the formal model while still failing an external evaluation if the model omits a relevant behavior or security property. Formal verification therefore depends not only on whether a proof succeeds, but also on whether the specification accurately represents the risks and requirements of the program being checked.
A Pipeline Rather Than a Complete Safety Claim
MAGS addresses a practical problem in agent-written software: coding agents can generate complex programs faster than people can review every possible edge case. Existing approaches such as fuzz testing, static analysis and language-model-based verification can identify many failures, but the paper says they may not cover all possible cases.
Its approach is to place generated code inside a machine-checkable workflow. Human-audited APIs and safety requirements are formalized and frozen, generated code is translated into Dafny, and verifier feedback is used to repair violations. The system then compiles programs that satisfy the specified requirements back into executable code.
The 220-example result shows that one pipeline can produce programs with formal safety guarantees across different execution models. It does not show that the generated programs are safe regardless of how their behavior is modeled. The paper’s independent evaluations instead emphasize the risk created when auto-formalized semantics leave out behavior that matters in the target environment.
MAGS therefore offers a narrower claim than a general guarantee of safe agent-written code. It demonstrates a method for checking generated programs against explicit, frozen specifications. Its reliability remains tied to the completeness and accuracy of those specifications.