Architecture
8 min readUpdated: October 2026

Phase State Machine vs Freeform ReAct Loop: Why Structured Agents Don't Hallucinate

The traditional ReAct (Reason + Act) prompting pattern is notorious for getting stuck in infinite loops, jumping prematurely into code edits, and failing to verify results. Smoke Monkey Harness replaces freeform loops with a deterministic 6-phase engineering state machine.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

Phase State Machine vs Freeform ReAct Loop: Why Structured Agents Don't Hallucinate: The traditional ReAct (Reason + Act) prompting pattern is notorious for getting stuck in infinite loops, jumping prematurely into code edits, and failing to verify results. Smoke Monkey Harness replaces freeform loops with a deterministic 6-phase engineering state machine. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways

Phase Breakdown and Invariants

  1. Explore: Tools restricted to view_file, list_dir, grep_search.
  2. Plan: Task decomposition and rollback strategies.
  3. Edit: write_to_file and replace_file_content.
  4. Verify: Test and linter execution via run_command.
  5. Recover: Activated on test failure; synthesizes adjustments.
  6. Complete: Generates git diffs and session persistence.
Google Search Questions & Answers

Frequently Asked Questions

Q:Can the agent transition backward from verify to edit?

Yes! If `verify` fails, the state machine transitions to `recover`, which diagnoses the error before returning to `edit`.

Related Alternatives & Comparisons

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness