Skip to content

Agentflow Diagram

Last updated:

Mermaid Studio recognizes and renders agentflow diagrams inside IntelliJ IDEA and other JetBrains IDEs. An agentflow diagram maps an AI agent workflow: each agent is a flow container of tasks, tool calls, and decisions, joined by sequence, reference, and failure edges.

Mermaid Studio opens an agentflow diagram in a split editor with the highlighted source on the left and the rendered workflow on the right. The example below drafts release notes with one agent and checks them with a second, looping back when a claim doesn’t hold, with classes highlighting the agents’ tasks, rendered under three IDE themes:

An agentflow diagram with classDef and style lines carrying color swatches in the gutter, and a drafting agent and a review agent with restyled tasks in the live preview under the Armada Dark theme

Agentflow diagrams are a basic syntax highlighting type with a few editing aids on top.

IDE feature supportSelect a feature for its description.
Editing
Code Intelligence
Validation
Refactoring
Appearance

At the start of a line, completion offers the statement keywords such as flow, global, and connector, plus each direction value. Press Enter Enter after a flow or global header and the editor inserts the closing end, and every container folds like any other block. When the diagram shows in a preview, Mermaid.js parser errors are marked in the editor on the token they point to, so a mistake in the body shows up where you typed it (see Diagram Validation).

Frontmatter completion covers the config.agentflow block, and the sample picker includes basic and styled agentflow samples to start from.

Style nodes and containers with classDef, class, and style statements, attach a class inline with the ::: suffix, and restyle edges with linkStyle. The editor completes CSS properties and values inside these statements, completes class names wherever a class is referenced, and shows a color swatch in the gutter next to each color. Renaming a classDef updates every use of that class, and an inspection flags a class that is defined but never used or used but never defined.

In the styled sample below, the gutter shows the colors of the classDef and style lines, and the preview shows the restyled nodes and failure edge:

The styled agentflow sample in the split editor, with color swatches in the gutter beside the classDef and style lines and the critical action and failure edge drawn in red in the live preview

Mermaid Studio bundles live templates for the building blocks of an agentflow diagram, so you can scaffold an agent container or a connector without recalling the metadata keys. Type the abbreviation, accept it from the completion popup, and tab through the variables. See Live Templates for the cross-cutting mechanics (triggering, contextual visibility, configuration).

AbbreviationExpansion
flowFlow container block (flow id["Label"] … end)
globalGlobal block for shared nodes (global … end)
connectorConnector with protocol and endpoint (connector id["Label"] plus its @{ protocol, endpoint } block)
nodeNode with a shape (id["Label"]@{ shape: … })
edgeLabeled sequence edge (source -- label --> target)
metaMetadata block on an element (id@{ key: "value" })

A node is an identifier, an optional label in brackets, and an optional @{ shape: … } block; a node without a shape is drawn as a task. Agentflow defines six shapes:

ShapeUse it for
taskA unit of work an agent performs
toolA callable capability such as a function or an API
inputData entering the workflow
decisionA branch point
refdocReference material an agent consults
actionA side-effecting step such as sending or publishing

Each of the three edge operators has its own meaning: --> passes control or data, -.- marks a reference that an agent consults, and --x is a failure path. Sequence and failure edges take a label in the middle:

agentflow-beta TB
check["Tests pass?"]@{ shape: decision }
ship["Ship it"]@{ shape: action }
fix["Fix the build"]@{ shape: task }
logs["Build logs"]@{ shape: refdoc }
check -- yes --> ship
check -- no --> fix
fix --x check
fix -.- logs

A flow block groups nodes into a container, usually one agent, and closes with end. Flows nest, and a flow is itself an edge endpoint. Declare a node that several flows share inside global … end:

agentflow-beta TB
global
guide["Style guide"]@{ shape: refdoc }
end
flow writer["Writer"]
draft["Draft copy"]@{ shape: task }
draft -.- guide
end
flow reviewer["Reviewer"]
check["Check claims"]@{ shape: task }
end
writer --> reviewer

For complete syntax details, see the Mermaid.js agentflow documentation.