MermaidFlow: Redefining Agentic Workflow Generation via Safety-Constrained Evolutionary Programming
Chengqi Zheng, Jianda Chen, Yueming Lyu, Wen Zheng Terence Ng, Haopeng Zhang, Yew-Soon Ong, Ivor Tsang, Haiyan Yin
TL;DR
MermaidFlow tackles brittleness in agentic reasoning by introducing a declarative graph representation based on Mermaid and a safety-conscious evolutionary search over that graph space.By separating planning from execution and enforcing static type and connectivity constraints, the approach yields verifiable, executable workflows with improved search efficiency.Empirical results across GSM8K, MATH, HumanEval, and MBPP show MermaidFlow achieving top performance and higher validity than code-based or prompt-only baselines, with a notable average improvement of 1.40 percentage points over the best prior baseline.The work highlights the significance of structure-aware, compiler-verified workflow design for scalable, interpretable, and robust multi-agent reasoning systems.
Abstract
Despite the promise of autonomous agentic reasoning, existing workflow generation methods frequently produce fragile, unexecutable plans due to unconstrained LLM-driven construction. We introduce MermaidFlow, a framework that redefines the agentic search space through safety-constrained graph evolution. At its core, MermaidFlow represent workflows as a verifiable intermediate representation using Mermaid, a structured and human-interpretable graph language. We formulate domain-aware evolutionary operators, i.e., crossover, mutation, insertion, and deletion, to preserve semantic correctness while promoting structural diversity, enabling efficient exploration of a high-quality, statically verifiable workflow space. Without modifying task settings or evaluation protocols, MermaidFlow achieves consistent improvements in success rates and faster convergence to executable plans on the agent reasoning benchmark. The experimental results demonstrate that safety-constrained graph evolution offers a scalable, modular foundation for robust and interpretable agentic reasoning systems.
