A Graph Workflow with Human Approval¶
What you build¶
exercise/minigraph.py: a small graph engine: nodes, fixed edges, routers, reducers, a step limit, and interrupt-and-resume with checkpoints.exercise/workflow.py: plan, branch, build, test, review, approve, open PR, with an attempt counter routing to escalation after three failed cycles, and a human approval interrupt.solution/langgraph_version.py: the same workflow on LangGraph (tested with 1.2), to compare.
Steps¶
- Implement
_merge,_nextand_run_from; then the three routers inworkflow.py. python -m pytest -q. The LangGraph test runs iflanggraphis installed.cd solution && python langgraph_version.pyto watch a run pause for approval and resume.
Done when¶
All tests pass, and you can point to where your engine and LangGraph each store the state needed to resume.
Stretch goals¶
- Add fan-out and fan-in: build two parts in parallel and join.
- Replace the stub
buildwith aharnesslab.AgentLoopon the habit tracker.