Skip to content
Mernyx
Open menu

Mermaid Agent Flow Diagram Cheat Sheet

An agent’s steps, and what kind of step each one is.

Every picture on this page was drawn byMernyx, the native Mermaid editor for macOS. Not by a browser running Mermaid.js — the same renderer the app uses for its canvas.

A flow block

A flow is a block that owns the steps inside it. The end keyword closes it.

agentflow-beta TB
  flow worker["Worker"]
    job["Do the job"]@{ shape: task }
  end
An agent flow diagram with one group called Worker containing a single step, Do the job.Expand diagram

What kind of step is it

The word after shape: says what the step is. input, task, tool, decision, action and refdoc are the six.

agentflow-beta LR
  brief["Brief"]@{ shape: input }
  draft["Draft copy"]@{ shape: task }
  check["spell_check"]@{ shape: tool }
  guide["Style guide"]@{ shape: refdoc }
  ship["Publish"]@{ shape: action }
  ok["Ready?"]@{ shape: decision }
  brief --> draft --> check --> ship
  ok --> ship
A left-to-right agent flow of six steps: a brief, a draft, a spell check tool, a style guide, a publish action and a ready decision.Expand diagram

Arrow forms

A labelled arrow says why. A cross is a retry, and a dotted line points at something to read.

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 decision asking whether the tests pass, branching to Ship it on yes and to Fix the build on no, with a dotted line from the fix to a box of build logs.Expand diagram

Nesting flows

A flow can hold other flows. The inner ones are the sub-agents.

agentflow-beta TB
  flow team["Content Team"]
    flow researcher["Researcher"]
      gather["Gather sources"]@{ shape: task }
    end
    flow writer["Writer"]
      compose["Compose draft"]@{ shape: task }
    end
    researcher --> writer
  end
A flow called Content Team containing two flows, Researcher and Writer, joined by an arrow, each holding one step.Expand diagram

Draw it in Mernyx.

Open a .mmd file, move a node on the canvas, and the source comes with it. Native on macOS, no browser involved.

Diagram preview