Plan Mode Is a State Machine, Not a Prompt
Prompt-based guardrails are unreliable; a model with write access can still modify files. A Harness-enforced Plan Mode creates a real permission boundary, preventing premature code changes and making AI agents safe for unsupervised project exploration.
Giving an AI agent write access from the start lets it modify code before understanding the full picture—deleting compatibility layers, missing real entry points, and skipping tests. The solution is not a polite prompt asking it to think first, but a Harness-level state machine that physically removes write tools during the planning phase. The agent can only read files, list directories, and search code until it submits a structured plan. The Agent Loop then pauses entirely, waiting for a human to approve, request changes, or cancel. Only after approval are write tools restored, and the agent begins executing against a generated TODO checklist. This three-phase cycle—planning, approval, execution—turns an eager code modifier into a disciplined engineering collaborator.
Separating mode (which tools are available) from status (what phase the loop is in) is critical; a single boolean cannot distinguish between actively planning and waiting for approval.
Structuring the plan into title, content, and steps lets the Harness automate task directory creation and TODO generation without parsing free-form Markdown.
Using a dedicated submit_plan tool turns an ambiguous model output into an explicit workflow event the Harness can act on.
Even read-only tools must enforce path sandboxing; read-only does not mean the agent can read arbitrary files on the user's system.
Task directory names must be sanitized from model-generated titles to prevent path traversal and collisions.