Skills & Workflow

State Machine Agent

A state machine agent is one whose behavior is modeled as a fixed set of named states — like idle, working, waiting for input — with explicit rules for when it transitions from one to another.

IdleWorkingWaiting for input
The agent cycles between named states.

The default mental model for an agent is a continuous loop: perceive, plan, act, observe, repeat (see agent-loop). A state machine agent is a more structured variant of that idea — instead of one undifferentiated loop, its behavior is broken into a fixed, named set of states, and the logic for what the agent does next depends explicitly on which state it's currently in.

An agent like this might sit in an Idle state until a task arrives, move to Working while it executes, and move to Waiting for input if it needs a human or another system to respond before it can continue — and, unlike a one-way sequence, it can transition back: from Waiting for input back to Working once the answer arrives, or back to Idle once a task finishes.

Modeling an agent this way makes its possible behaviors easier to reason about and test, since there's a finite, enumerable set of states rather than an open-ended loop — at the cost of needing to define states and transitions up front, which can be restrictive for genuinely open-ended tasks.

How it works

Each state defines what the agent is allowed to do while in it, and a set of transition rules define which events move it to which other state. The agent's current state is tracked explicitly (often as a simple label or enum), and every action the agent takes is interpreted in light of that state — the same event can lead to different behavior depending on what state the agent was already in.

How it differs

State machine agent vs. DAG workflow: a DAG models a single run's task graph — it starts, executes, and finishes once, with no cycles; a state machine models an agent's ongoing behavior over time, and can legitimately transition back to a state it's been in before, which a DAG by definition cannot.

Common misconceptions

Often assumed: A state machine agent can't loop back to an earlier state.
Actually: That's the opposite of the point — unlike a DAG, a state machine is explicitly allowed to transition back to a state it's already visited, which is exactly what lets it wait, retry, or resume.

FAQ

What is a state machine agent?
An agent whose behavior is modeled as a fixed set of named states, like idle, working, and waiting for input, with explicit rules for when it moves between them.
How is a state machine agent different from a DAG workflow?
A DAG runs once through a fixed graph with no loops; a state machine tracks an agent's ongoing behavior and can transition back to a state it's already been in.

Last checked: 2026-08-28

Related terms