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 · 2025

Read MermaidFlow: Redefining Agentic Workflow Generation via Safety-Constrained Evolutionary Programming by Chengqi Zheng Jianda Chen Yueming Lyu Wen Zheng Terence Ng, Haopeng Zhang Yew-Soon Ong Ivor Tsang Haiyan Yin (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2505-22967.txt.

Introduction

Plans made by language models often break when a computer tries to run them, since free text sets few hard rules. Chengqi Zheng and co-authors tackle that flaw with a graph-based frame in work from twenty twenty-five. Workflows are drawn in a chart language that people can read and machines can check.

Change steps drawn from breed-style search swap, tweak, add, and drop graph parts while guarding sense and structure. The search stays inside a space of plans that can be checked before they run. Tests on an agent test set showed higher success rates and faster arrival at plans that run. The team frames the method as a base for agent systems that stay clear and safe to inspect.

Catalog record

CREATORChengqi Zheng Jianda Chen Yueming Lyu Wen Zheng Terence Ng, Haopeng Zhang Yew-Soon Ong Ivor Tsang Haiyan Yin
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE114 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2505-22967

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

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 Abstract Despite the promise of autonomous agentic reasoning, existing workflow generation methods frequently produce fragile, unexecutable plans due to unconstrained LLM-driven construction. We propose 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. The codes are available at https://github.com/chengqiArchy/MermaidFlow 1 Introduction Large language models (LLMs) are increasingly instantiated as modular agents that collaborate to solve complex tasks through structured workflows [ 9 , 15 , 16 ] . These agentic workflows decompose problems into subtasks, assign them to specialized agents, and integrate intermediate outputs toward a shared goal. Moving beyond single-agent prompting, this multi-agent setting requires coherent planning and execution across agents with distinct roles and responsibilities. Designing such workflows involves reasoning over compositional graph structures that represent inter-agent dependencies, data flow, and semantic constraints, forming the foundation for scalable and adaptive multi-agent systems [ 32 ] . The lifecycle of agentic workflow is naturally structured into three layers: (1) workflow planning , which defines the structure of subtasks, agent roles, and information flow; (2) code realization , where the plan is translated into executable programs; and (3) runtime execution , where agents are instantiated and carry out their assigned behaviors. In many systems, these layers are collapsed (e.g., [ 12 , 30 ] ): workflows are directly generated as Python code or serialized JSON trees , where planning decisions are entangled with implementation (i.e., through prompting -based generation of code or execution traces). As a result, workflows are often encoded in low-level formats where structure is implicit, semantics are entangled with imperative logic, and validity can only be assessed at runtime. This implicit representation hinders verifiability, reuse, and search, limiting the robustness and scalability of multi-agent systems. Figure 1: An illustration of the workflow lifecycle in MermaidFlow . The workflow is modeled as a declarative graph using Mermaid code, where nodes \mathcal{V}_{[\tau,\alpha]} and edges \mathcal{E}_{[\rho]} are explicitly defined with annotated prompts and roles (lines 3-8), styled and typed (lines 11–21), and connected via directed edges (lines 24–30). This results in a statically verifiable, semantically typed, and structurally interpretable representation that serves as a unified interface for visualization, validation, and code generation. Indeed, recent studies reveal that multi-agent LLM systems frequently fail due to brittle workflow logic and coordination breakdowns ( 2 , 26 , 31 ) . These failures typically arise not from deficiencies in language models themselves but emerge from workflows that cannot be reasoned about, verified, or adapted. Without a structured representation of agent roles, task flow, and dependencies, systems struggle to detect errors before execution or to generalize behaviors across tasks. This points to a core limitation: existing workflows lack the abstraction needed for reliable planning. To address the limitations of implicit, code-bound workflows, we introduce MermaidFlow , a declarative representation for agentic planning inspired by the Mermaid graph markup language 1 1 1 https://mermaid.js.org . MermaidFlow defines workflows as declarative graphs , where nodes represent prompting agents and edges specify information flow (see Figure 1 for an illustrative example of the declarative graph encoded in Mermaid language, which is declarative, structurally explicit, and highly human-interpretable). This high-level representation enables structural and semantics properties with static verification, e.g., role consistency , and type-safe connections , can be enforced at the graph level. For instance, a simple workflow can be written as input → reasoner → summarizer , offering a clear plan that is both human-readable and programmatically analyzable. By exposing explicit semantics and structure, MermaidFlow yields substantial downstream benefits in both code generation and workflow evaluation, when LLMs are extensively employed to realize and evaluate workflows. These properties ultimately yield a more robust, verifiable, and high-reward search space for agentic workflow planning. MermaidFlow enforces a clear separation between symbolic planning and executable code, ensuring that workflow structures remain statically verifiable by design. Building on this foundation, we further propose a novel evolutionary programming (EP) framework tailored specifically to explore MermaidFlow’s structured graph space. Our EP approach employs safety-constrained operations, including node replacement, subgraph rewiring, and role-consistent insertions, to maintain workflow correctness throughout the search process. Furthermore, historical workflows generated during search accumulate as structured experience, enabling efficient reuse and adaptation across tasks. Together, MermaidFlow’s declarative representation and EP search framework constitute a programmable and task-agnostic programming layer for agentic workflow generation, enabling efficient search with improved correctness, generalization, and adaptability. To our knowledge, this is the first agentic workflow framework to guarantee static graph-level correctness across the entire generation process. In summary, our contributions are threefold: (1) We introduce MermaidFlow, a declarative, verifiable graph representation for agentic workflow planning that cleanly separates planning from execution; (2) We develop a novel EP-based search framework leveraging structured mutation operators and workflow experience accumulation; and (3) We empirically demonstrate that MermaidFlow significantly outperforms existing code-based methods on standard agentic reasoning benchmarks, improving success rates, search efficiency, and interpretability. 2 Related Works Agentic Workflows with LLMs Recent advances in multi-agent LLM systems have enabled structured collaboration among specialized agents to tackle complex, multi-step tasks. AFLOW ( 30 ) , MaAS ( 28 ) , and MASS ( 32 ) formalize agent workflows using execution graphs and message-passing protocols to model multi-step reasoning. MetaGPT ( 11 ) and MAS-GPT ( 25 ) implement role-based orchestration by assigning domain-specific functions (e.g., product manager, engineer) and encoding Standard Operating Procedures (SOPs) to reduce cascading errors. Debate-based frameworks such as Multi-Agent Debate ( 17 , 6 ) and DebFlow ( 21 ) introduce structured critique among agents to promote output reliability. While these systems improve modularity and scalability, their workflows are typically encoded in imperative code or loosely structured prompts , i.e., formats that lack semantic abstraction and resist verification. Recent studies ( 2 , 26 , 31 ) identify fragile workflows, rather than model errors, as the primary source of failure in multi-agent systems. Our proposed MermaidFlow addresses this bottleneck by introducing a typed, declarative workflow space that supports safe construction, static validation, and structured exploration, advancing agentic reasoning beyond brittle prompt chaining. Workflow Representation The representation of agentic workflows governs not only how agents are composed, but also whether they can be verified, reused, or optimized. Natural language-based prompting methods, such as Chain-of-Thought ( 14 ) , ReAct ( 24 ) , and Self-Refine ( 19 ) , are expressive but underspecified, lacking formal structure for validation. In contrast, code-centric approaches like AFLOW ( 30 ) , ADAS ( 12 ) , and ScoreFlow ( 23 ) generate executable Python or JSON trees

Read the complete text