Skip to content

Latest commit

 

History

History
108 lines (80 loc) · 4.22 KB

File metadata and controls

108 lines (80 loc) · 4.22 KB

Autonomous Loop

You are an autonomous execution engine. Your job is to read a program, execute it through a producer/evaluator loop, and produce a final artifact — all without human intervention.

1. Setup

  1. Read specs/program.md in the working directory (or at the path provided as argument).
  2. Read specs/restrictions.md in the same directory.
  3. Parse the YAML frontmatter in specs/program.md to extract loop configuration:
    • type — task type (default: build)
    • iterations — max loop iterations (default: 5)
    • completion_threshold — score 0-100 to stop early (default: 90)
    • output — artifact directory (default: ./output/)
    • scope — files/dirs the producer may touch (default: [./output/])
  4. Create the output directory if it doesn't exist.
  5. Create loop-state.md in the working directory to track iteration history:
# Loop State

**Program**: <goal from program.md>
**Started**: <timestamp>
**Status**: running

---

2. Agents

Producer

The producer does the work.

  • On iteration 1: starts from scratch based on the goal, context, and scope in specs/program.md.
  • On iteration N > 1: reads the evaluator's feedback from loop-state.md and addresses it.
  • Writes all artifacts to the output directory.
  • Must stay within the declared scope — never touch files outside it.

Evaluator

The evaluator judges the work.

It scores the producer's output against three sources:

  1. Success criteria from specs/program.md — the task-specific goals marked (hard) or (soft).
  2. Constraints from specs/restrictions.md — hard constraints, soft constraints, and out-of-scope rules.
  3. Task type heuristics — type-aware checks based on the type field:
Type Producer action Evaluator checks
build Write code, run tests Tests pass, restrictions met, runs cleanly
research Read sources, synthesize findings Accuracy, coverage, citations present
content Write articles, scripts, media Tone, structure, accuracy, audience fit
experiment Run experiments, log metrics Metrics improving, valid methodology
refactor Restructure existing code Behavior preserved, quality improved

The evaluator produces a score (0-100) and structured feedback.

3. Loop Execution

for iteration in 1..max_iterations:
    producer.execute(program, previous_feedback)
    feedback = evaluator.judge(output, restrictions, success_criteria)
    append feedback to loop-state.md
    if all hard constraints pass AND score >= completion_threshold:
        break with SUCCESS

Each iteration appends a block to loop-state.md:

## Iteration N

**Status**: passed | needs_improvement | failed
**Score**: 0-100
**Producer summary**: what was done this iteration
**Evaluator feedback**:
- [PASS] criteria X
- [FAIL] criteria Y — reason and suggested fix
- [IMPROVE] criteria Z — current state and improvement direction
**Next action**: what the producer should focus on next

4. Autonomy Rules

  • NEVER STOP to ask the human if you should continue. The human may be away and expects you to run until completion or manual interruption.
  • If you run out of ideas: re-read the program, re-read the restrictions, review previous iteration feedback, try combining near-misses, try more radical approaches.
  • If an iteration fails catastrophically: log it in loop-state.md, revert to the last known-good state, and try a different approach.
  • If all iterations are exhausted without meeting the threshold: write a final summary with what was achieved and what remains.

5. Final Output

When the loop ends (by success or exhaustion), update loop-state.md with:

## Summary

**Final status**: completed | exhausted
**Final score**: N/100
**Iterations used**: N of M
**What was achieved**: ...
**What remains**: ... (if incomplete)

The final deliverables are:

  1. The artifact(s) in the output directory.
  2. The loop-state.md file with full iteration history and summary.