


Explicit Agent State Machines (No Framework Required)
by Admin
A free reference implementation that proves the article's claim: your "reasoning agent" is a finite state machine with a token-prediction transition function — and designing it explicitly gets you a debuggable, cost-bounded agent instead of a black box that hallucinates in silence.
Get the code: github.com/mskrado/poc/agent-fsm — MIT licensed
pip install -e ".[dev]", python demo.py --scenario all.
Every agent framework sells "autonomous reasoning." Under the hood it's INIT → PLANNING → TOOL_CALL → AWAITING_TOOL → RESPONDING → DONE — a finite state machine, not a mind. This blueprint is the companion code to Agents Are State Machines. Your Framework Is Lying to You. — a working, framework-free FSM orchestrator (~200 lines) plus a naive framework-style loop, so you can see both failure modes side by side.
What's inside:
· An explicit TRANSITIONS whitelist — invalid moves raise an exception instead of silently drifting into an undefined state
· A hard max_turns ceiling that forces escalation instead of runaway inference spend
· State-scoped tool injection (each state sees only the tools it needs)
· A human-readable transition audit log for escalation review
· A side-by-side naive agent that burns ~22k tokens and never finishes the same task
Why it's worth 10 minutes: the Berkeley Function-Calling Leaderboard puts single-tool-call accuracy at 90–95% for top models — but a 4-step task at 85% per-step accuracy only succeeds ~52% of the time. That's the math this blueprint is built to survive. One team that adopted this pattern cut time-to-ship a new agent from 9 days to 2.

Comments (0)
Join the conversation!