MESHFLOW_MOCK=1 python3 hands_on/08_workflow_dag.pyThis lesson introduces MeshFlow as an artifact-driven orchestration style for AI workflows. You do not need to know the real library yet. First learn the mental model:
define a workflow
-> validate the graph
-> run nodes in dependency order
-> pass named artifacts forward
-> stop at gates when needed
-> inspect the trace
MeshFlow is useful because real AI systems need more than prompts. They need structure.
A prompt chain is a sequence of model calls:
prompt 1 -> prompt 2 -> prompt 3
This works for simple demos, but it becomes fragile when:
MeshFlow-style orchestration moves important control out of the prompt and into an explicit workflow.
In MeshFlow, the workflow is the source of truth.
node A produces artifact X
node B consumes artifact X and produces artifact Y
gate C checks Y
node D runs only if the gate passes
The model still matters, but the workflow controls the process.
| Term | Beginner Meaning |
|---|---|
| Workflow | The whole process |
| Node | One unit of work |
| Dependency | A rule saying what must run first |
| Artifact | A named output from a node |
| Tool | A function or external capability |
| Agent | A goal-directed worker inside a node |
| Gate | A hard stop for approval or quality |
| Trace | The execution record |
| Compile | Validate the workflow before running |
| Run | Execute the workflow |
The mini runner in this tutorial uses simple node types:
| Node Type | Purpose |
|---|---|
prompt | Simulate a basic LLM response |
agent | Simulate an agent planning step |
tool | Call a built-in tool |
memory_write | Store a value |
memory_read | Retrieve a stored value |
gate | Stop unless approval is present |
Real MeshFlow systems can be richer, but these types are enough to learn the architecture.
Without artifacts:
"Do research, write an answer, check it, and publish it."
Everything is hidden in one instruction.
With artifacts:
research_questions
source_notes
draft_answer
quality_check
approval_record
final_answer
Now each important output can be inspected, tested, and reused.
A gate is a controlled pause. It says:
Do not continue until this condition is satisfied.
Examples:
Gates are how a workflow expresses judgment, risk, and accountability.
A trace answers:
Beginner rule: if you cannot trace it, you cannot reliably debug it.
Compilation means checking the workflow before doing expensive or risky work.
Good compile checks include:
This course's mini runner has a small compile command:
python3 -m src.mini_meshflow compile examples/02_tools_and_memory.json
Diagrams help you catch design mistakes.
Run:
python3 -m src.mini_meshflow diagram examples/02_tools_and_memory.json
Read the graph from left to right:
what starts first -> what depends on it -> what produces final output
If you cannot explain the graph in plain English, simplify it.
Use this pattern for almost every AI workflow:
Compile a workflow:
python3 -m src.mini_meshflow compile examples/02_tools_and_memory.json
Draw the workflow:
python3 -m src.mini_meshflow diagram examples/02_tools_and_memory.json
Run an agent workflow:
python3 -m src.mini_meshflow run examples/03_agent_with_gate.json
When it stops at the gate, do not treat that as a failure. The pause is the workflow doing its job.
Mistake 1: Starting with code before naming artifacts.
Correction: First decide what each step must produce.
Mistake 2: Letting prompts control everything.
Correction: Put process control in the graph.
Mistake 3: Treating gates as optional decoration.
Correction: Gates are required anywhere risk, cost, or human judgment matters.
Mistake 4: Ignoring trace output.
Correction: Read traces after every run until you can predict them.
MeshFlow-style orchestration is about making AI work explicit. Nodes do work, dependencies define order, artifacts carry state, gates control risk, and traces explain what happened. This makes agentic systems easier to learn, debug, and trust.
python3 -m src.mini_meshflow compile examples/02_tools_and_memory.json
Record the node count and artifact list.
python3 -m src.mini_meshflow diagram examples/02_tools_and_memory.json
Explain which node runs first and why.
Open ../../examples/02_tools_and_memory.json and find every depends_on field.