MESHFLOW_MOCK=1 python3 hands_on/10_hitl_gate.pyThis lesson walks through a complete agent workflow step by step. The goal is to make the execution feel concrete. You should be able to predict what each node does before you run it.
We will use:
examples/03_agent_with_gate.json
The workflow looks like this:
capture_goal
-> draft_plan
-> check_plan
-> human_approval
-> final_answer
Plain English version:
The draft_plan step is an agent node. It receives the goal and creates a plan. In a real system, that agent might:
In this tutorial runner, agent behavior is simulated so you can focus on the workflow shape.
The agent does not publish directly. It produces an artifact:
course_plan
Then another node checks it. Then a gate blocks finalization until approval.
This matters because agents are flexible but not always predictable. A workflow adds boundaries.
Step 1:
capture_goal
type: prompt
produces: goal
This creates the first artifact. Everything downstream depends on a clear goal.
Step 2:
draft_plan
type: agent
consumes: goal
produces: course_plan
The agent uses the goal and drafts a plan.
Step 3:
check_plan
type: tool
tool: word_count
consumes: course_plan
produces: plan_word_count
The tool checks something measurable about the plan. Real checks could include policy review, citation review, rubric scoring, or schema validation.
Step 4:
human_approval
type: gate
approved: false
The workflow stops here until approval is present.
Step 5:
final_answer
type: prompt
consumes: course_plan
produces: final_tutorial
This step runs only after the gate passes.
Run:
python3 -m src.mini_meshflow run examples/03_agent_with_gate.json
Expected behavior:
That is correct. The workflow is protecting the final step.
Open:
examples/03_agent_with_gate.json
Find the gate node and change:
"approved": false
to:
"approved": true
Run again:
python3 -m src.mini_meshflow run examples/03_agent_with_gate.json
Now the final node should run.
Look for three sections:
Ask:
Beginner extension:
capture_goal
-> draft_plan
-> check_plan
-> revise_plan
-> human_approval
-> final_answer
Intermediate extension:
capture_goal
-> draft_plan
-> check_plan
-> estimate_cost
-> human_approval
-> final_answer
Advanced extension:
capture_goal
-> researcher_agent
-> writer_agent
-> reviewer_agent
-> quality_gate
-> human_approval
-> final_answer
Each extension should add a clear artifact, not just another hidden prompt.
A production agent workflow might add:
The tutorial runner is intentionally small. It teaches the skeleton before the industrial machinery.
Mistake 1: Skipping the check step.
Correction: Add at least one measurable review before approval.
Mistake 2: Letting the agent approve itself.
Correction: Use a separate gate or reviewer.
Mistake 3: Publishing from the agent node.
Correction: Make the agent produce a draft artifact, then publish later.
Mistake 4: Forgetting to inspect the trace.
Correction: Read the trace after every run until the workflow feels predictable.
This workflow shows the core pattern of governed agent design:
goal -> agent draft -> check -> gate -> final output
The agent provides flexible reasoning. The workflow provides structure, inspection, and control.
For each node in ../../examples/03_agent_with_gate.json, write:
| Node id | Node type | Dependencies | Produced artifact |
|---|
Open the JSON file directly and fill the table from the node definitions. Do not run the workflow yet — read the structure first.
Expected result: a table with five rows. Compare against the answers in answers.md only after you have filled it in yourself.
Open ../../examples/03_agent_with_gate.json and add a specific instruction to the review_plan node. For example:
"Check that the plan mentions at least three distinct sources and does not
recommend any action that requires budget approval."
Run the workflow:
python3 -m src.mini_meshflow run examples/03_agent_with_gate.json
Answer:
Open the workflow file and change "approved": false to "approved": true. Run the workflow again.
Answer:
difference?
Now change "approved": true back to "approved": false.
Run the workflow with the gate blocked:
python3 -m src.mini_meshflow run examples/03_agent_with_gate.json
Walk through the trace output and answer for each node:
| Node id | Started? | Completed? | Blocked? | Why? |
|---|
The goal is to read the trace as a story: what ran, what was blocked, and what never had a chance to run because an upstream node did not complete.
Design (do not code) a second gate that fires earlier in the workflow — before the agent node runs. Describe:
blocked?
A good answer names a realistic condition (for example, "topic is within allowed subject areas" or "input length is under 500 tokens") and explains the benefit of catching it early rather than after the agent has already spent compute.