Towards AIblog

Building AI Agents in Rust — part 4

Monday, June 22, 2026Enzo LombardiView original
Author(s): Enzo Lombardi 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. Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor. Published via Towards AI