Skip to content

1. Your first agent ​

The smallest workflow is one flow with one task in it.

Code:
mermaid
agentflow TB
  flow greeter["Greeter"]
    hello["Say hello"]@{ instruction: "Greet the user warmly and ask how you can help." }
  end
Ctrl + Enter|

Line by line:

  • agentflow TB starts the diagram. TB draws it top to bottom; LR draws it left to right.
  • flow greeter["Greeter"] opens a flow with the id greeter and the title "Greeter". end closes it.
  • hello["Say hello"] is a task with the id hello and the label "Say hello".
  • @{ instruction: "…" } holds the task's settings. The instruction says what the step should do.

Every task lives inside a flow, and every task needs an instruction. A label alone names the step but doesn't say what to do.

Code:
mermaid
agentflow TB
  flow greeter["Greeter"]
    hello["Say hello"]
  end
Ctrl + Enter|

Task "hello" has no instruction, so the workflow can't run it. Add an instruction that says what the step should do.

A flow can also take settings. model picks the model, and the flow's own instruction gives guidance for its steps.

Code:
mermaid
agentflow TB
  flow greeter["Greeter"]@{ model: "claude-sonnet-4-5", instruction: "You are a friendly front-desk assistant." }
    hello["Say hello"]@{ instruction: "Greet the user warmly and ask how you can help." }
  end
Ctrl + Enter|

Next: 2. Steps in a flow.

Opens in mermaid.ai