โ† devalier.com

Loop-Machine

Three-Agent Delegation Pattern for OpenClaw

๐Ÿ“… June 2026 ๐Ÿ”„ v1.0 ๐Ÿท๏ธ OpenClaw Skill

"Most agent systems die not from a weak model but from a weak harness."
โ€” Andrej Karpathy, LOOPS.md

Loop-Machine replaces one-shot agent delegation with a three-role, contract-negotiated, crash-resumable loop. For any non-trivial task, spawn three agents instead of one: a Planner, a Generator, and an Evaluator. The orchestrator monitors progress and only intervenes when the contract itself is wrong.

Why Three Agents?

When a single agent does everything โ€” plan, execute, and evaluate โ€” it becomes sycophantic. It rubber-stamps its own work, converges on slop, and never truly verifies. Separating the roles forces genuine quality at every gate.

The Three Roles

Planner

Design the Spec

  • Reads the objective
  • Researches constraints
  • Writes a sprint spec with ~27 testable criteria
  • Negotiates the contract with the Evaluator
Generator

Execute Only

  • Reads the contract
  • Produces the deliverable
  • Writes progress to disk
  • Does NOT evaluate its own work
Evaluator

Prove It's Broken

  • Assumes output is broken
  • Tests every criterion in the contract
  • Scores subjective axes against calibrated references
  • Does NOT fix anything โ€” only evaluates
Orchestrator

Manage the Loop

  • Spawns the three agents in sequence
  • Reads evaluations and decides next action
  • Restarts the loop on failure (with retry budget)
  • Escalates only when the contract is wrong
  • Does NOT execute or evaluate

Protocol

  1. Spawn Planner. Give it the task. It writes contract.md with ~27 testable assertions, constraints, and a tool plan. It does NOT execute.
  2. Approve contract. Read contract.md. If the criteria are vague or too few, push back. Once approved, the contract is frozen.
  3. Spawn Generator. Give it the contract path. It reads the criteria, produces the deliverable, writes progress.md and log.md. It does NOT evaluate itself.
  4. Spawn Evaluator. Told from the start: "The output is almost certainly broken. Prove it." Reads the contract and the Generator's output. Writes evaluation.md with per-criteria pass/fail, scores, and gap explanations.
  5. Monitor & Decide. Read evaluation.md. Three outcomes:
    • All PASS โ†’ Task complete. Deliver summary.
    • Some FAIL, retries remain โ†’ Delete Generator output. Go to step 3. Let the loop restart.
    • Contract is wrong โ†’ Escalate. The contract needs revision, not the build.

File Structure

delegations/[task-slug]/
  contract.md        # Planner's spec + testable criteria (~27 assertions)
  progress.md        # Generator's current state
  log.md             # Append-only iteration history
  evaluation.md      # Evaluator's pass/fail per criterion
  output/            # Generator's deliverable files
  trace/             # Raw session transcripts (for debugging)

The system must be able to crash, lose its session, and resume by reading only contract.md, progress.md, and log.md.

Contract Template

# Contract: [Task Slug]

## Objective
[One-sentence task description]

## Testable Criteria (aim for ~27)
- [ ] Criterion 1: [exact, falsifiable statement]
- [ ] Criterion 2: [exact, falsifiable statement]
...

## Constraints
- Must not: [forbidden approaches]
- Budget: [max iterations or time]
- Output format: [exact format spec]

## Subjective Rubric (if applicable)
| Axis    | Weight | 3 Good Examples | 3 Bad Examples |

## Exit Conditions
- All criteria PASS โ†’ SUCCESS
- [3] consecutive restarts โ†’ ESCALATE
- [N] total iterations โ†’ REPORT partial

Retry Budget

Default: 3 retries per task. After budget exhausted with persistent failures โ†’ escalate. Counter resets if a retry produces an all-PASS evaluation. Track in log.md.

Origin

This skill is based on Andrej Karpathy's LOOPS.md: Field Notes on Agents That Run for Days, which distills nine principles for building autonomous agent loops. The key insight: "Write the loop, not the prompt" โ€” the unit of leverage is the procedure, not the message.

Interested?

This skill is currently available for inquiry. Commission custom agent skills or license existing ones.

Get in Touch โ†’