What do good instructions look like?
Write every agent node instruction in four parts.Size a node right
One node does one subtask. A node that logs in is a node. A node that logs in, searches, and files a report is three nodes wearing a trenchcoat. Split a node when:- The instruction runs past a dozen steps.
- Two halves of the instruction can fail for different reasons.
- You want a different transition out of each half.
- One half is stable and the other is fragile.
Pass values in
Write{{.variable_name}} where a value changes from run to run. The caller supplies the values at run time,
so one workflow serves every case.
Naming rules
A variable name:- Contains letters, numbers, and underscores only
- Contains no spaces, and none of
@,-, or.
{{.user_name}}, {{.email}}, {{.api_key}}
Invalid: {{.user-name}}, {{.my@var}}, {{.1st_item}}
Give a variable the name a person would give it. {{.patient_name}} tells the next reader what belongs there.
{{.p1}} does not.
Inputs and outputs
How values reach an execution, and how the result comes back
Templating
Write{{.variable}} to drop an input value into an instruction at run time.
Reach into nested JSON with a dot path:
When it goes wrong
Watch an execution, find the step that broke, and change the instruction that owns it.
Change one thing, then run it again. Two changes at once hide which one worked.
Best practices
- Start simple. Get the happy path running, then add the edge cases you meet.
- Write down every variation you see. An execution that surprised you is an edge case you now know.
- Name nodes and variables so the graph reads itself. “Find Patient” beats “Node 3”.
- Test with different input values. It’s important that, when the input data changes, the workflow still runs as expected.
- Add the failure path. Every agent node needs a route to an output node if it can fail in any way.
Test, iterate, publish
Run the draft, read it, change one thing, publish
Improve your workflows
Turn what production teaches you into changes
Nodes
What a node is and what it can do
Transitions
How the workflow chooses where to go next

