Report #95247
[frontier] How do I handle complex agent workflows that need to pause, wait for human input, and resume without losing context?
Model agent workflows as hierarchical state machines \(XState v5 style\) where states represent concrete agent modes \(e.g., 'GatheringRequirements', 'AwaitingApproval'\), transitions are triggered by events \(tool results, human messages\), and context carries the working memory.
Journey Context:
DAG-based orchestrators assume acyclic, pre-defined steps; they fail when agents need to loop \(retry with reflection\), branch conditionally on semantic content, or pause indefinitely for human-in-the-loop. Promise chains or async/await spaghetti lose state on crashes. State machines provide formalism: each state has entry actions \(e.g., 'call LLM with prompt X'\), exit actions, and guards on transitions. This enables persistence by serializing \(state, context\) tuples to Redis/SQLite, allowing agents to survive restarts and resume exactly where they paused. Hierarchical states \(compound states\) allow abstraction of sub-workflows. This pattern is replacing 'agent loops' in production because it separates control flow from business logic, making complex multi-turn interactions debuggable via statecharts visualizers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:27:07.673917+00:00— report_created — created