Show HN: Statewright – Visual state machines that make AI agents reliable
TL;DR Highlight
Per-phase tool limits took two local models from 2/10 to 10/10 on a small SWE-bench subset.
Who Should Read
A backend developer whose Claude Code or Codex agent edits during review or deploys before checks finish.
Core Mechanics
- Agents hold every tool the whole time
- With the same tools throughout, an agent can edit during review or deploy before checks finish.
- Statewright defines the tools, checks, and transitions for each phase.
- Out-of-phase tools get rejected before running
- On intercepted tool paths, calls outside the current phase are rejected, and the agent is told which tools and transitions are available.
- When edits are disallowed, Bash checks also block workarounds like echo > file, rm -rf, sed -i, and python or node.
- Local-model success went from 2/10 to 10/10
- On the same tasks and hardware, two local models finished 2 of 10 attempts without constraints and 10 of 10 with them.
- This covers a 5-task SWE-bench subset, not the full 2294 instances.
- Small models failed the 5 tasks in the table
- Only gpt-oss:20b (13.8GB) and gemma4:31b (19.9GB) completed all five.
- gemma3 (3.3GB) and gemma4:e2b (7.2GB) failed, and the README says this does not establish a minimum model size.
- Model and reasoning level can change per state
- The example uses Haiku for diagnose, Opus for propose_fix, and Sonnet as default.
- It is not a measurement of token use or savings.
- The engine is a Rust state machine with no LLM
- It evaluates states, transitions, guards, and tool limits deterministically with no runtime dependencies.
- requires_approval gates pause the run for human review.
- Too-strict workflows leave the agent stuck
- The README lists this as a tradeoff.
- The escape hatch is statewright_deactivate.
Community Reactions
- Opinion that the patent blurs the open-source scope
- A commenter was unsure what the open-source "core engine" covers given the provisional patent.
- They liked the idea but the patent made them want to back away.
- The author replied that the engine and agent crates are Apache 2.0, while only the gateway and plugins are FSL.
- Reproduction code could not be found
- A commenter tried to reproduce the research results locally and could not find the code.
- Opinion that changing tool lists busts the cache
- A commenter said frequent tool-list changes invalidate the cache, raising costs in long sessions, and that this belongs in the tradeoffs.
- Doubts about rigidity and necessity
- Commenters asked how much flexibility is lost on exploratory tasks.
- One said a smart model writing a phased plan, a cheaper model implementing, and another reviewing already works, and asked what a state engine adds.
- Author's experience of a blocked workaround
- The author said Claude tried to write an intricate bash script around a guardrail and Statewright blocked it.
How to Apply
- Split one agent task into three phases
- Pick a task you hand to agents often, split it into plan, implement, and test, and list allowed tools per phase.
- Paste the prompt below into Claude to get a JSON draft.
- Install the plugin and run the starter workflow
- Run /plugin marketplace add statewright/statewright and /plugin install statewright@statewright in Claude Code.
- Try it on one small bug with "Use the engineering workflow to fix the failing tests".
- Add allowed_commands and max_edit_lines to phases
- Allow only pytest or npm test in testing and set max_edit_lines to around 20 in implementing.
- Add a transition that sends failures back to implementing.
- Put requires_approval before deploys
- Set requires_approval: true on deploy or migration transitions so the run pauses for human review.
- If it gets too restrictive, release it with statewright_deactivate.
Try It
# Paste into Claude or ChatGPT (simplified Statewright-style version: workflow design prompt)
Task I want to give the agent: {{task description}}
Available tools: {{e.g. Read, Grep, Edit, Write, Bash}}
Design this task as a phased state machine in JSON.
Rules:
- States: planning, implementing, testing, completed (final)
- Give each state least-privilege allowed_tools (planning read-only, testing Read and Bash only)
- In implementing, add max_edit_lines and max_files_per_state
- In testing, add allowed_commands (e.g. {{test command}}), with failure going back to implementing and success going to completed
- Add requires_approval: true to hard-to-undo transitions such as deploys
- Add one line per state explaining why only those tools are allowedTerminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques