Skip to content

Decision ​

A decision picks one of its labelled branches.

Syntax ​

text
id{"Question?"}
id["Question?"]@{ shape: decision }
id{"Question?"}@{ instruction: "…" }

The branches are arrows that leave the decision, each with a label: id -- yes --> next or id -->|yes| next.

Settings ​

SettingRequiredValueExample
instructionnotextinstruction: "Treat crashes and wrong results as bugs."

A branch takes an instruction too. See Arrow.

Where it can go ​

A decision sits inside a flow and holds nothing.

ArrowIn fromOut to (branches)
Arrow (-->)flow, task, decisionflow, task, decision
Dotted link (-.-)——

Rules ​

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?"}@{ instruction: "Treat crashes and wrong results as bugs." }
    fix["File a bug"]@{ instruction: "Open a bug report with steps to reproduce." }
    answer["Answer"]@{ instruction: "Reply to the question using the help center." }
    read --> kind
    kind -- bug --> fix
    kind -- question --> answer
  end
Ctrl + Enter|

Common mistake ​

Two branches with the same label.

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." }
    read --> kind
    kind -- bug --> fix
    kind -- bug --> answer
  end
Ctrl + Enter|

Decision "kind" has more than one branch labelled "bug". Give each branch its own label.

Opens in mermaid.ai