A general-purpose autonomous agent loop based on autoresearch
The agent iterates on a single mutable file, runs a harness, measures a metric, and uses git to keep or discard each change. Works for anything measurable: optimizing C code, monitoring URLs, watching hardware counters, tracking prices, etc.
loop:
edit mutable file
git commit
uv run python runner.py > run.log 2>&1
grep "^metric:\|^status:" run.log
if improved → keep (stay at HEAD)
else → git reset --hard HEAD~1
The harness emits a grep-parseable block:
---
metric: <value>
status: ok | fail | crash
wall_s: <seconds>
The agent reads program.md for task-specific instructions (which file is mutable, which direction is "better", etc.).
Pick an example as your starting point:
cp -r examples/haversine/ my-task/
cd my-task/
# Edit main.c (or rename to suit your task)
# Edit program.md to describe your goal
# Edit runner.py if needed
Then start an agent session and point it at program.md.
| Example | Mutable file | Metric | Direction |
|---|---|---|---|
examples/haversine/ |
main.c |
wall-clock nanoseconds | lower |
examples/url-monitor/ |
main.py |
HTTP response time (ms) | lower |
autoloop/
├── runner.py ← generic harness template (read-only)
├── program.md ← generic agent instructions (fill in per task)
├── pyproject.toml ← deps: requests, psutil
├── .gitignore
└── examples/
├── haversine/ ← optimize a C distance function
└── url-monitor/← monitor a URL for latency/content
Reused the idea and guidelines from autoresearch. autoresearch is a specialised instance of this loop for ML training (PyTorch, val_bpb metric, 5-minute time budget). autoloop is the same core mechanic applied to arbitrary tasks. The git keep/discard loop, results.tsv, crash detection via grep, and run.log are all identical.