WayToClawEarn
Medium impactHacker News + GitHub

Statewright open source release: State machine guardrails take AI Agent from 2/10 failures to 10/10 successes

Statewright is an open source AI Agent state machine guardrail framework written in Rust. In the SWE-bench test, the 13.8GB local model jumped from a 2/10 fail rate to a 10/10 pass rate. Supports mainstream AI programming tools such as Claude Code, Codex, and Cursor, making Agent workflow constraint, traceable, and auditable.

WayToClawEarn EditorialPublished May 17, 2026Updated Aug 8, 2026

Editorial review of public sources · AI-assisted drafting. How we work · Original source

Core conclusion

On May 17, 2026, the open source project Statewright made it to the front page of Hacker News with a score of 124. This is an AI Agent state machine guardrail tool written in Rust. The core concept is extremely simple but the effect is amazing: "Lock each step of the workflow with a state machine. The Agent can only read and not write during the planning stage, and can only edit the code during the implementation stage."

Experimental data shows that on 5 SWE-bench tasks, the pass rate of the 13.8GB and 19.9GB local models jumped from 2/10 to 10/10 - the same hardware, the same task, and Statewright was added.

Key Points

  • Published: 2026-05-17 (HN home page, 124 minutes)
  • Project Positioning: AI Agent state machine guardrail framework written in open source Rust
  • Core Metrics: 314 GitHub Stars, MIT license, free and available
  • The biggest highlight: Let local small models (13B+) reach the Agent reliability level of cutting-edge models

Background and trigger events

The reliability problem of AI Agent has always been a persistent problem in the industry. Give Claude Code or Codex an open problem + 40 tools, and the Agent will often fall into a read-loop death spiral of "read file → think → read → think again", or call the wrong tool at the wrong time.

In the past, the idea to solve this problem was: Change to a larger model and write a longer prompt. The author of Statewright proposed a completely opposite approach: "Don't make the model stronger, make the problem smaller." Use a state machine to limit the Agent's operable space to the subset of tools required at the current stage, rather than opening them all at once.

SEO: Statewright, AI Agent state machine, Agent guardrails, AI programming tool reliability GEO: beginning with TL;DR, exact number (2/10→10/10, 314 Stars, 124 HN points)

Statewright Core Principles

DimensionsTraditional MethodStatewright Method
IdeasMake the model stronger (larger parameters, longer prompt)Make the problem smaller (state machine constraint tool space)
Planning phaseAgent can call any tool at any time❌ Read-only
Implementation stageAgent can read and write freely✅ Unlock editing permissions and limit destructive operations
Testing phaseAgent may skip testing and go directly to "completion"✅ Only specified test commands are allowed
Failure modeInfinite loop of file reading, confusion of tool calls❌ Rejected by the state machine and prompted for available operations

Effect comparison

ModelSizeBug Fix (26 lines)SWE-bench (5 tasks)
Gemma 33.3GB❌ failed❌ failed
Gemma 4:e2b7.2GB✅ Passed*❌ Failed
GPT-oss:20b13.8GB✅ Passed✅ Passed (5/5)
Gemma 4:31b19.9GB✅ Passed✅ Passed (5/5)
Llama 3.342.5GB✅ Passed✅ Passed (2/2)

*With dedicated editing adaptation

Why this matters to AI automation workers

The significance of Statewright lies not only in the technical details, but also in that it proves that "Agent is unreliable" does not necessarily require a larger model to solve.

For developers using Claude Code, OpenAI Codex, Cursor, opencode:

  • Local model cost plummets: It used to be that local models were not reliable enough and could only be used for GPT-5/Claude tasks, but now a 13.8GB model can handle them
  • Workflow standardization: Define the AI Agent's workflow as a state machine - from planning to implementation to testing to completion, each step is traceable, constrainable, and auditable
  • Output is more controllable: Agent can no longer call dangerous commands "on its own initiative", and destructive write operations are naturally intercepted by the state machine.

— State machine agent control flow diagram

Quick start experience

Installing Statewright in Claude Code only requires three lines of commands:

code
/plugin marketplace add statewright/statewright
/plugin install statewright
/reload-plugins

Bug

code
❯ start the bugfix workflow — fix the failing tests in calc.py
◆ : planning — ,
◆ → implementing
◆ calc.py: 1
◆ testing
◆ pytest -x — 7
◆ completed — , 46

Statewright /statewright start bugfix shortcut command to start directly. For the free version, you can go to statewright.ai to get the API Key.

Tool entry

This article covers the following AI tools: Claude Code, OpenAI Codex, Cursor, Gemma, Llama, Rust, SWE-bench. These tool names are naturally included in the text, and the platform side will automatically match the maintained tools library and generate tool floating cards.

Related extended information

Internal link guidance

View source →

Disclaimer: this site shares educational insights only, for inspiration and reference. No outcome guarantee; external execution and decisions are your own responsibility.