What is state machines in AI Agents? A Guide for product managers in banking
State machines are a way to model an AI agent as a set of named states, where each state defines what the agent is allowed to do next. In an AI agent, a state machine controls the flow of work by moving the agent from one state to another based on events, conditions, or completed actions.
How It Works
Think of a state machine like a bank teller’s workflow.
A teller does not handle every customer the same way. They start in one state, like Greeting, then move to Identity Verification, then maybe Transaction Processing, then Completion. If something fails, they might move to Escalation or Manual Review. The teller is not “thinking freely” at every step; they are following a controlled sequence with clear exit points.
That is what a state machine does for an AI agent.
Instead of letting the agent improvise across the entire customer journey, you define:
- •States — the current phase of work
- •Events — what happened to trigger movement
- •Transitions — rules for moving from one state to another
- •Actions — what the agent does inside each state
For example:
| State | Trigger | Next State |
|---|---|---|
| Intake | Customer submits claim | Verify Policy |
| Verify Policy | Policy found and active | Assess Claim |
| Verify Policy | Policy missing or expired | Escalate |
| Assess Claim | Amount under threshold | Approve |
| Assess Claim | Amount above threshold | Manual Review |
For product managers, the key idea is this: a state machine makes an AI agent predictable.
That matters because banking workflows are full of rules. You need different handling for KYC failures, fraud signals, missing documents, duplicate applications, and regulatory exceptions. A state machine keeps those paths explicit instead of buried inside one large prompt.
A useful analogy is airport security.
You do not let every passenger wander wherever they want. They move through checkpoints in order: check-in, screening, boarding, then departure. If something looks wrong, they get routed to secondary screening. An AI agent with a state machine works the same way: it moves through controlled checkpoints until it reaches completion or escalation.
Why It Matters
Product managers in banking should care because state machines solve problems that show up quickly in production.
- •
They reduce chaos in complex journeys
Banking flows have many branches: approved, pending, rejected, escalated, retried. A state machine makes those branches visible and manageable.
- •
They improve auditability
If a regulator asks why an application was routed to manual review, you can point to the exact state and transition rule that caused it.
- •
They make AI safer
An unconstrained agent can skip steps or hallucinate actions. A state machine forces the agent to stay within approved process boundaries.
- •
They help teams align on product behavior
Product, compliance, ops, and engineering can all look at the same flow diagram and agree on what happens next.
- •
They support better failure handling
In real banking systems, things fail: OCR errors, API timeouts, identity mismatches. State machines make retries and fallback paths explicit instead of ad hoc.
Real Example
Let’s take a mortgage pre-approval assistant.
The business goal is simple: help customers get pre-approved faster without breaking policy or creating compliance risk.
A basic AI agent without structure might read documents, answer questions, call credit checks, and draft responses all in one loop. That sounds flexible until it starts mixing up incomplete applications with declined ones.
A better design uses a state machine:
- •
Start
- •Customer begins application
- •
Collect Documents
- •Agent asks for payslips, ID, proof of address
- •
Validate Completeness
- •If documents are missing → stay in this state and request them
- •If documents are complete → move forward
- •
Run Eligibility Checks
- •Agent calls income verification and credit policy rules
- •
Decision State
- •If eligible → generate pre-approval summary
- •If borderline → send to manual underwriting
- •If failed → explain rejection reason using approved templates
- •
Completion
- •Customer receives outcome and next steps
Here is how that looks in simplified code:
class MortgageAgentState:
START = "start"
COLLECT_DOCUMENTS = "collect_documents"
VALIDATE_COMPLETENESS = "validate_completeness"
RUN_ELIGIBILITY_CHECKS = "run_eligibility_checks"
DECISION = "decision"
MANUAL_REVIEW = "manual_review"
COMPLETION = "completion"
def transition(state, event):
if state == MortgageAgentState.START and event == "application_started":
return MortgageAgentState.COLLECT_DOCUMENTS
if state == MortgageAgentState.COLLECT_DOCUMENTS and event == "docs_received":
return MortgageAgentState.VALIDATE_COMPLETENESS
if state == MortgageAgentState.VALIDATE_COMPLETENESS:
if event == "docs_missing":
return MortgageAgentState.COLLECT_DOCUMENTS
if event == "docs_complete":
return MortgageAgentState.RUN_ELIGIBILITY_CHECKS
if state == MortgageAgentState.RUN_ELIGIBILITY_CHECKS and event == "checks_passed":
return MortgageAgentState.DECISION
if state == MortgageAgentState.DECISION:
if event == "eligible":
return MortgageAgentState.COMPLETION
if event == "borderline":
return MortgageAgentState.MANUAL_REVIEW
if event == "failed":
return MortgageAgentState.COMPLETION
return state
For a product manager, the value is not the code itself. The value is that every step has a defined outcome.
That means you can ask practical questions:
- •What happens if income verification fails?
- •Can the user upload more documents?
- •When do we stop retrying?
- •Which cases require human review?
- •What message does the customer see at each stage?
Those are product questions first. The state machine gives engineering a clean way to implement them without turning the agent into an unpredictable black box.
Related Concepts
If you are working with AI agents in banking, these topics sit close to state machines:
- •
Workflow orchestration
- •Managing multi-step business processes across systems and services
- •
Finite State Machines
- •The formal computer science model behind states and transitions
- •
Human-in-the-loop review
- •Routing uncertain or high-risk cases to operations staff or underwriters
- •
Guardrails
- •Rules that constrain what an AI agent can say or do in regulated flows
- •
Event-driven architecture
- •Systems where messages or events trigger changes in process state
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit