Originally published on Towards AI.
State machines for multi-step tasks
The loop in Part 1 handles a class of question that fits in one breath: read this file, list that directory, answer the user. Two turns, three turns, done. As long as the model can plan and execute inside one conversation, the loop is enough.

Beyond the initial loop, the article argues that real multi-step agent work needs a state-machine structure to handle composition of phases, human approval gates, and durability across failures or restarts. It explains how Eugene v0.4 introduces a typed graph system in Rust—nodes that represent phases and return transitions (goto, halt, interrupt), a graph runner that drives execution with checkpointing via a SQLite checkpointer, and an interrupt mechanism for human-in-the-loop pauses. The post also covers plan-mode lineage (permission modes like read-only vs approve-before-destructive), generalized gating via hooks (before/after node hooks for permissions, logging, budgets, and other cross-cutting concerns), and how retries should be placed at the correct scope (HTTP call vs whole node). Finally, it demonstrates a practical three-node “draft → review → revise” graph and concludes with what this design enables next (multi-agent parallelism) plus where to find the full code and related background.
Read the full blog for free on Medium.
Published via Towards AI
Towards AI Academy
We Build Enterprise-Grade AI. We'll Teach You to Master It Too.
15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.
Start free — no commitment:
→ 6-Day Agentic AI Engineering Email Guide — one practical lesson per day
→ Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages
Our courses:
→ AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.
→ Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.
→ AI for Work — Understand, evaluate, and apply AI for complex work tasks.
Note: Article content contains the views of the contributing authors and not Towards AI.




















