Statewright: State Machine Guardrails for AI Agents

Statewright is a Rust-based engine that enforces state machine guardrails on AI agents to control tool usage across different task phases. By restricting the available tools and commands at each step, it prevents agents from making catastrophic errors or getting stuck in repetitive loops. This structured approach significantly improves the success rates of both frontier and local models on complex software engineering tasks.
Key Points
- Statewright uses deterministic state machines to restrict AI agent tool access based on the current phase of a workflow.
- The framework prevents common agent failures by enforcing guardrails like Bash command filtering, edit line limits, and approval gates.
- Empirical research shows that state machine constraints significantly boost the performance of local LLMs, enabling smaller models to solve complex coding tasks.
- It integrates with major AI coding tools through MCP and provides a visual editor and JSON schema for defining custom workflows.
- The core engine is open-source (Apache 2.0/FSL) and written in Rust for high performance and embeddability.
Sentiment
The community is broadly supportive of Statewright's core technical thesis — that deterministic state machines constraining agent tool access by phase can dramatically improve reliability, especially for smaller models. The creator's active and constructive engagement, including shipping fixes to licensing and UI feedback in real time during the discussion, earned goodwill. However, the patent filing generated meaningful friction, with some developers stating they would wait for the full Apache 2.0 release before engaging. Overall, the sentiment leans positive with cautious optimism.
In Agreement
- State machines are the key to getting low-powered LLM models to produce good quality code — constraining the solution space is more effective than scaling up model size
- The insight that smaller tool spaces lead to better reasoning is validated by multiple independent projects converging on structural guardrails over unconstrained agents
- Enforcement must be structural (hooks blocking tool calls) rather than advisory (prompt instructions the model can rationalize away)
- The approach addresses real pain points with current coding agents like death spirals, overzealous edits, and models overriding user intent with their own judgment
- The visual workflow editor and audit trail of agent reasoning at phase boundaries add practical value for understanding and debugging agent behavior
Opposed
- A simpler multi-model pipeline with a smart planner, cheaper implementer, and reviewer model may achieve similar results without the complexity of a Rust state engine
- Rigid state machine workflows may sacrifice flexibility needed for tasks requiring creative exploration
- The provisional patent on state machine guardrail enforcement for LLM tool access makes the project a no-go for some developers regardless of licensing terms
- State machines can prevent agents from doing wrong things but cannot force agents to do required actions — they solve only part of the reliability problem
- The requirement for an external API and managed service when the core concept could run entirely locally raises questions about the project's business model