---
title: 'State machine'
description: 'A model of a system as explicit states and permitted transitions triggered by events or conditions.'
canonical_url: 'https://darkfactory.dev/glossary/state-machine'
markdown_url: 'https://darkfactory.dev/glossary/state-machine.md'
collection: glossary
date_published: '2026-08-04T00:00:00-04:00'
date_modified: '2026-08-26T00:00:00-04:00'
---

# State machine


## Definition

A state machine models a system as explicit states and permitted transitions triggered by events or conditions. A state records where the process is. A transition defines when and how it may move somewhere else.

An agent workflow can be treated as a state machine when its carried state and transition rules are explicit. Examples include `awaiting_approval`, `running`, `blocked`, `completed`, and `failed`. Persisting those states outside the model lets a retry or restart determine what has already happened.

Finite-state machines have a defined set of states. Practical agent systems may also carry rich data, create tasks dynamically, and wait for external events, but the state-machine discipline still clarifies which transitions are valid.

## Distinguish it from nearby terms

A state machine emphasizes valid states and transitions. A workflow emphasizes activities and outcomes. A control graph emphasizes possible paths. An execution trace records the transitions that actually occurred.

## Check your understanding

An approval request exists only in chat history. After compaction, the agent deploys because it no longer knows approval was pending. An explicit `awaiting_approval` state would make that transition invalid.

## Also called

finite-state machine, FSM

## Related terms

- [Control graph](https://darkfactory.dev/glossary/control-graph)
- [Workflow](https://darkfactory.dev/glossary/workflow)
- [Model checkpoint](https://darkfactory.dev/glossary/checkpoint)
- [Graph engineering](https://darkfactory.dev/glossary/graph-engineering)

## Related factory areas

- [Orchestration, state, concurrency & recovery](https://darkfactory.dev/factory/orchestration-state)

## Evidence and further reading

- [LangChain: 3 Years of Graph Engineering with LangGraph](https://www.langchain.com/blog/3-years-of-graph-engineering-with-langgraph)
- [A Methodology for Selecting and Composing Runtime Architecture Patterns for Production LLM Agents](https://arxiv.org/abs/2605.20173)
