Arrow
An arrow (-->) sets the order of steps: a --> b runs b after a.
Syntax
text
a --> b
a --> b --> c
a --> b & c
b & c --> d
decision -- label --> b
decision -->|label| b
decision e1@-- label --> b& puts several nodes on one side. An arrow leaving a decision is a branch and carries a label. e1@ gives an arrow an id, so you can give it settings on their own line: e1@{ instruction: "…" }.
Settings
| Setting | Required | Value | Example |
|---|---|---|---|
| label | yes on a branch, not allowed elsewhere | text | kind -- bug --> fix |
instruction | no; only on a branch | text | e1@{ instruction: "Include the app version." } |
An arrow uses no other setting. Any other setting is ignored: a branch warns about it, and a regular arrow doesn't.
Connects
| From | To |
|---|---|
| flow | flow, task, decision |
| task | flow, task, decision |
| decision | flow, task, decision |
| input | flow |
An arrow never touches a connector. Use a dotted link for that.
Rules
- An arrow only connects the pairs in the table above. →
EDGE_KIND_INVALID(error) - Both ends are nodes that exist. →
REF_UNRESOLVED(error) - An arrow doesn't point at a node inside a flow from outside that flow. An input's arrow is the exception: it can start any flow. →
REF_OUT_OF_SCOPE(error) - Only a branch has a label. →
EDGE_LABEL_UNSUPPORTED(error) - Only a branch has an instruction. →
EDGE_INSTRUCTION_UNSUPPORTED(error) - The same arrow isn't drawn twice. →
EDGE_REDUNDANT(warning) - An arrow doesn't skip a step its source already reaches. →
EDGE_SHORTCUT(error) - Every loop can end: a decision in it has a branch that leaves the loop, and every loop inside it, however small, takes at least one decision branch. →
CYCLE_NO_EXIT(error) - A task in a loop doesn't have an arrow that leaves the loop. →
CYCLE_TASK_EXIT(warning) - A branch takes only the
instructionsetting. →METADATA_UNKNOWN_KEY(warning) - The instruction has no unfilled placeholder such as
<REPO>. →INSTRUCTION_PLACEHOLDER(error)
Example
Code:
mermaid
agentflow TB
flow support["Support"]
read["Read ticket"]@{ instruction: "Read the ticket and decide whether it is a bug or a question." }
kind{"Bug or question?"}
fix["File a bug"]@{ instruction: "Open a bug report with steps to reproduce." }
answer["Answer"]@{ instruction: "Reply to the question using the help center." }
close["Close ticket"]@{ instruction: "Close the ticket with a one-line note." }
read --> kind
kind e1@-- bug --> fix
kind -->|question| answer
fix & answer --> close
e1@{ instruction: "Include the customer's app version." }
end
Common mistake
A label on an arrow that doesn't leave a decision.
Code:
mermaid
agentflow TB
flow support["Support"]
read["Read ticket"]@{ instruction: "Summarise the ticket in two lines." }
reply["Reply"]@{ instruction: "Write a polite reply that answers the ticket." }
read -- then --> reply
end
The arrow from "read" to "reply" has a label, but only branches leaving a decision can have one. Remove the label, or add a decision.