Beyond ReAct: Dynamic Plan Revision in Autonomous Coding Agents

The canonical ReAct (Reason + Act) pattern revolutionized tool-using LLMs by interleaving internal thought tokens with tool invocations. However, when applied to long-horizon software engineering tasks—such as refactoring an entire microservice or migrating database schemas—standard ReAct suffers from catastrophic failure modes:

✦

The Dynamic Plan Revision Architecture

Modern agent harnesses replace linear ReAct loops with hierarchical plan execution graphs featuring explicit rollback and branch verification.

MERMAID
stateDiagram-v2
    [*] --> PlanSynthesis: User Specification
    PlanSynthesis --> ExecutionStep: Approved Plan DAG
    ExecutionStep --> ToolExecution: Execute Action
    ToolExecution --> VerificationCheck: Collect AST & Test Output
    VerificationCheck --> ExecutionStep: Pass (Next Step)
    VerificationCheck --> PlanRevision: Fail / Constraint Violation
    PlanRevision --> ExecutionStep: Updated DAG / Rollback
    ExecutionStep --> Completion: All Steps Verified
    Completion --> [*]
✦

1. Structured Step Contracts

Rather than free-form natural language thoughts, the agent generates and commits to structured JSON step definitions:

JSON
{
  "stepId": "migrate-auth-tokens",
  "dependencies": ["schema-migration-applied"],
  "intendedModification": {
    "files": ["src/auth.ts", "test/auth.test.ts"],
    "invariants": [
      "Zero breaking changes to verifyCredential signature",
      "All unit tests in auth.test.ts must exit code 0"
    ]
  },
  "rollbackPlan": {
    "gitCheckout": "HEAD~1",
    "discardPaths": ["src/auth.ts"]
  }
}
✦

2. Compacting the Observation Stream

Verbose compiler and test outputs should never be injected verbatim into the root planner prompt. High-efficiency agent runtimes pass raw stdout through a Summarization Filter:

✦

3. Empirical Results

In comparative benchmarks evaluating autonomous bug-fix pipelines on 150 complex repository pull requests:

Planning Paradigm Success Rate Avg Inference Steps Context Tokens Consumed
Linear ReAct 41.2% 28.4 steps 184,000 tokens
Plan-and-Solve 56.8% 19.1 steps 112,000 tokens
Dynamic Plan Revision (Ours) 82.4% 12.3 steps 64,000 tokens

By enforcing programmatic verification at each transition point, autonomous agents transition from unpredictable toy demos into resilient engineering assistants.