Every developer using Claude Code or Cursor has encountered the read-loop death spiral. It happens when an AI agent, tasked with a complex bug fix, enters a hypnotic cycle of reading the same file five times without ever attempting a write operation. The agent possesses the tool to edit the code, but it lacks the cognitive stability to execute it. The Statewright team describes this as hitting the floor, the precise point where a local model, typically under 13GB, can generate a tool call but cannot retain enough file content to produce an accurate edit. The frustration is not a lack of raw intelligence, but a collapse under the weight of too many options.

Statewright and the Architecture of Constraint

Statewright addresses this collapse by treating tool usage not as a free-for-all, but as a deterministic state machine. Instead of allowing an agent to access every available tool at once, Statewright restricts the toolset based on the current phase of the workflow. This logic is handled by a core engine written in Rust, located in `crates/engine`, which evaluates state transitions, guards, and tool restrictions without involving the LLM in the decision-making process. By removing the LLM from the management of its own constraints, the system eliminates the possibility of the agent hallucinating its way out of a restriction.

For those using the Claude Code free tier, the system can be initialized with a simple command:

bash

Claude Code에서 실행

/statewright start bugfix

Once the API key is provided and the user confirms the intent, the agent is locked into a three-phase workflow. In the Planning phase, the agent is restricted to read-only tools, forcing it to map the problem before touching the code. The Implementation phase opens up limited shell access and modification tools, specifically utilizing write-via-redirect while blocking destructive commands. Finally, the Testing phase restricts the agent to a set of designated test commands. If the agent attempts to call a tool that does not belong to the current phase, Statewright rejects the request and provides a message explaining which tools are available and how to transition to the next state.

To ensure this logic is not siloed, Statewright leverages the Model Context Protocol (MCP). This allows the state machine to act as a plugin layer that integrates seamlessly with Claude Code, Codex, Cursor, opencode, and Pi. Workflows are defined via JSON schemas, which can be automatically generated by the agent using the `statewright_create_workflow` tool or adjusted manually through a visual editor. The system offers two distinct enforcement modes: Hard mode, which blocks the tool call at the protocol level before the model even sees it, and Advisory mode, which injects rules into the context without strict enforcement.

The Shift from Model Scale to Problem Space

The most striking evidence of this approach is found in the performance of small, local models. In a subset of the SWE-bench (Software Engineering Benchmark) consisting of five tasks, the development team tested two local models sized 13.8GB and 19.9GB. Without Statewright's constraints, these models scored a dismal 2/10. However, when the state machine was applied to the same hardware and the same tasks, the score jumped to 10/10. This represents a five-fold increase in performance without changing a single parameter of the model itself.

This result exposes a critical flaw in the current AI trajectory. While frontier models like GPT-4 or Claude 3.5 use massive system prompts to prevent destructive actions or credential leaks, they still operate in a bloated tool space. When an agent has 30 or 40 tools available, the cognitive load of selecting the right tool often competes with the cognitive load of solving the actual engineering problem. Statewright proves that by shrinking the tool space from 30 options to five, the model can stop worrying about the interface and start focusing on the reasoning.

This structural advantage turns local models into viable alternatives for professional engineering tasks. The performance gap between a 13GB local model and a frontier model is not always about the number of neurons, but about the noise in the environment. By enforcing a state machine, Statewright effectively clears the noise, allowing smaller models to achieve parity with much larger systems on specific, structured tasks.

Regarding accessibility, the tool is free for individual developers. For those requiring managed infrastructure, statewright.ai provides a cloud platform for workflow storage, execution logs, and an MCP gateway. The licensing is designed to encourage both open-source contribution and commercial flexibility. The core engine in `crates/engine` is released under the Apache 2.0 license, making it embeddable without runtime dependencies. Full-stack self-hosting for a single developer or team is permitted under the Functional Source License (FSL). Furthermore, the team has included a patent pledge, ensuring that solo developers, researchers, and open-source projects are protected even if they implement similar logic independently without using the Statewright software.

The industry is currently obsessed with scaling context windows and parameter counts, but Statewright suggests a different path. The future of reliable AI agents may not lie in making the models larger, but in making the problems smaller.