WhoBuilt

Building Multi agent Systems with Finite State Machines

Feb 22, 2025· 17 min· 5.9K views·Watch on YouTube

Speaker

Adam Charlson presents for AI Engineer on using finite state machines to structure and govern AI agent systems; no role or company affiliation is stated.

State machines add structure and oversight

Charlson argues that autonomous AI systems need predictability, observability, and control alongside model capability. He describes state machines as systems of states and event-triggered transitions, with guards, actions, and context, and explains that statecharts extend the model with hierarchical and parallel states. Paired with the actor model, they provide a way to organize concurrent, message-passing applications.

Operational benefits and tradeoffs

Charlson says state machines are predictable, traceable, auditable, reliable, and recoverable; replaying an event log can reconstruct state, and model-based testing can cover valid transitions. He also names tradeoffs: state explosion, unmodeled events, concurrency, versioning, and a learning curve. For distributed transactions, he describes using the Saga pattern with compensating actions when a step fails.

Combining LLMs with explicit workflows

Charlson contrasts LLMs’ dynamic intelligence with the structure and predictable behavior of state machines, proposing systems that use both. In tool use, an LLM selects a tool and specifies its arguments, while the surrounding system executes it and returns the result. A recipe example uses an inventory lookup so the model works with available ingredients.

Human review, feedback, and collaboration

Charlson shows how a state machine can pause for authenticated human approval before a tool request proceeds. In a feedback pattern, a critic agent reviews a recipe and suggests changes such as using less sugar. For collaboration, specialized agents handle recipe writing, ingredient procurement, meal preparation, and reporting in a governed workflow.

Letting agents plan or create workflows

In agentic orchestration, a planning agent chooses the next state, while transition guards check that the requested transitions are valid. Charlson also proposes agentic chartering, where an LLM generates a statechart for a task; he describes using OpenAI’s o1 model to turn instructions for removing personal data from Whitepages into a process. He closes by suggesting that composable systems of specialized units may support more emergent behavior, and credits XState for the presentation’s statecharts and visualizations.

Takeaways

  • Use explicit states, events, and transition guards to make agent workflows easier to inspect and govern.
  • Keep tool execution in the surrounding application: let the LLM request a tool and let the system validate and run it.
  • Add an authenticated human approval step before consequential tool actions.
  • Use specialized agents with defined roles and feedback loops for broader tasks.
  • Plan for event replay, concurrency, and workflow version changes when building stateful systems.

Mentioned in this talk

Search inside this talk

What was claimed 8

  • previously at
    Adam Terlson previously at Best Buy
    Led mobile self-checkout across 900 stores; cloud-native development and DevOps on AWS
    “today working as a senior principal security architect”
    YouTube
    Verified2 sources· Talk, Web· archived
  • feature
    state machine: Predictable, traceable, auditable, reliable, and recoverable behavior
    “they are predictable, traceable, and auditable”
    YouTube
    Unverified1 source· Talk
  • feature
    model-based testing: Can check that tests exercise every valid transition in a state machine
    “tests are exercising every valid transition in your machine”
    YouTube
    Unverified1 source· Talk
  • feature
    saga pattern: Uses compensating transactions to undo previous steps when a distributed transaction step fails
    “you can apply compensating transactions to undo the previous steps”
    YouTube
    Unverified1 source· Talk
  • feature
    Agentic orchestration: A centralized planning node directs the next state
    “a centralized planning node can direct the next state”
    YouTube
    Unverified1 source· Talk
  • feature
    agentic chartering: An LLM can generate a statechart to separate planning from execution
    “separate your planning phase from your execution phase”
    YouTube
    Unverified1 source· Talk
  • feature
    XState: Supports statecharts and visualizations
    “used for all the state charts and visualizations”
    YouTube
    Unverified1 source· Talk
  • uses
    “the library I used for all the state charts and visualizations”
    YouTube
    Unverified1 source· Talk

Related talks