LOOP ENGINEERING
Internal · dsk26 · 261017
Enter PIN to unlock
LOOP ENGINEERING
dsk26 · capability · 17 Oct 2026

LOOP ENGINEERING

M~ hands over one task line. The loop asks its questions, compiles a refined prompt spec, then runs the work step by step, verified, until it's done — the Karpathy autoresearch pattern, pointed at the estate.

FACTS in normal text. SPECULATION in italics. Loop mechanics quoted from Karpathy's autoresearch repo + posts (March 2026, extracted 17 Oct 2026). The design section is the build plan for M~'s setup, not yet running code.
Zeus · 17 Oct 2026 · Internal
Section 01

Where the pattern comes from

Karpathy's autoresearch, posted to X in March 2026: a nanochat LLM training core stripped to a single GPU, ~630 lines, one file. The division of labor is the whole idea:

"the human iterates on the prompt (.md) — the AI agent iterates on the training code (.py). The goal is to engineer your agents to make the fastest research progress indefinitely and without any of your own involvement." — @karpathy, 7 Mar 2026

The agent works an autonomous loop on a git branch: edit the code, run a fixed 5-minute training, check one number (val_bpb, lower is better), keep the commit if it improved, revert if it didn't, log every attempt, repeat — ~12 experiments per hour, roughly 100 overnight. Two days of it produced ~700 experiments and ~20 kept improvements worth an 11% training speedup on the big model.

The part M~ asked for lives in the setup phase, before the loop starts: agree the run tag, cut the branch, read the in-scope files, confirm — "Once you get confirmation, kick off the experimentation." Karpathy's human-side craft object is the prompt file itself (program.md), and the repo's own bound is stated plainly: if you can't evaluate it, you can't auto-research it. That is why this loop begins with questions — the questions are how the prompt gets iterated before any work runs.

Repo stars
97.7k
github.com/karpathy/autoresearch, 17 Oct 2026
Experiments
~700 / 2 days
agent-run on Karpathy's GPU
Kept wins
~20
→ 11% training speedup
Human touch
prompt.md only
agent never touches the eval harness
autoresearch (Karpathy)This loop (M~ estate)
Human iterates on program.mdAgent asks 3–5 questions, compiles a refined task spec for M~ to confirm
Agent edits train.pyAgent runs work step-by-step in scratch, nothing touches live estate mid-loop
Fixed 5-min training run + val_bpbVERIFY check per step (command / number / checklist)
Commit kept if better, else git resetWinners advance; losers revert, logged keep/discard/crash
~100 experiments run while asleepFull deliverable + audit trail by morning on overnight tasks
NEVER STOP until human interruptsSame: loop runs to done / budget / gate-pending / interrupt
Section 02

The loop, end to end

TASK → QUESTIONS → REFINED PROMPT → STEPS → VERIFY → DELIVER, with the two human veto gates marked on the irreversible exits. This is M~'s loop, built from Karpathy's mechanics:

TASK IN one raw line from M~ QUESTIONS agent asks 3–5, numbered REFINED PROMPT spec: goal·scope·constraints verify·budget VETO GATE 0 M~ confirms spec (edit · ship) edit loop back to questions STEPS (loop body) plan → do → verify → keep / discard spec approved → run VERIFY (per step) command / number / checklist pass fail → discard, revert (logged) VETO GATE 1 irreversible step staged, M~ fires it DELIVER artifact + audit trail AUDIT TRAIL — every step logged (Karpathy's results.tsv)
Figure 1 — the loop cycle with human veto gates on the irreversible exits

Gate 0 is the spec confirm — M~ edits or ships the refined prompt before any work runs. Gate 1 is the irreversible step: the loop stages it (file, message, payment-ready state) and waits for fire / amend / kill. Everything reversible runs free.

Section 03

Stage 1–2 · Spin up + ask

M~ gives one raw line — from a Cockpit registry row, typed in chat, or a standing cron task. Intake captures it as-is: no cleanup, no invented parameters. The agent reads scope, ambiguity, and stakes out of the raw line, then asks its question round before any work begins.

Karpathy parallelThe human owns the prompt, not the code

In autoresearch, the human's one craft object is program.md — "a super lightweight skill". He never touches the Python. Here: M~ never has to write the brief himself. The question round is the prompt iteration — the agent turns one vague line into an executable spec, which M~ confirms or edits at Gate 0.

Source: program.md — "This is an experiment to have the LLM do its own research"

Question classWhat it nails downSample for a real row
GoalWhat "done" looks like, single metric if possible"Insurance pack: terminate 3 legacy plans?"
ScopeFiles/rows/accounts in, which out"Only the 3 legacy plans, or new ones too?"
ConstraintsDeadline, budget cap, blocked paths"Must close before the next premium date"
VerificationThe objective check that settles "correct"" insurer confirmations PDF-ed + logged?"
BudgetStep/token/time cap + expiry date"Run before 28 Oct expiry on one plan"
Decision-inbox tie-in: the 261015 one-pager found 20 of 41 registry rows waiting on M~. A question round converts each vague "decide X" row into an executable spec — the same mechanism Karpathy uses to hand the agent a prompt worth looping on.
Section 04

Stage 3 · The refined prompt spec

The answers compile into a 5-field task spec — the loop's contract, M~'s program.md analog:

GOAL
the one number
outcome + single unambiguous metric — Karpathy's val_bpb analog
SCOPE
in / out lists
what the agent may touch — program.md's CAN / CANNOT
CONSTRAINTS
deadlines + bans
budget limits, blocked paths, style rules
VERIFY
the objective check
if you can't evaluate it, you can't auto-research it
BUDGET
cap + expiry
steps / tokens / time — then the loop stops and reports

"if you can't evaluate it, you can't auto-research it" — the bound Karpathy states in program.md. VERIFY is the field the whole loop stands on: every discipline in Stage 4 keys off it.

Section 05

Stage 4–5 · Run + verify, keep or discard

Karpathy's loop, translated: work in small verified steps on a scratch copy, log every attempt, never stop — until done, budget, gate, or interrupt:

plan next step small, 100% doable verify it objective check runs KEEP — advance winners accumulate DISCARD — revert logged, reason recorded CRASH — fix or skip dumb mistake: re-run · else: skip + log VETO GATE 1 keep wins only UNTIL the irreversible exit gate hit → stage + halt log every attempt — keep / discard / crash — like Karpathy's results.tsv append-only · the trail is the yield: "wake up to a log of experiments" next step → loop
Figure 2 — the loop body: verify, then keep / discard / crash — logged every time
Loop discipline (straight from program.md): every attempt logged; killed runs count as failures with reasons; between checkpoints, never ask "should I continue?" — the human may be asleep; fresh angles when stuck (re-read sources, re-read the spec, combine near-misses) instead of thrashing. Crash handling scales down too: a dumb fix re-runs, an unsound idea is skipped and logged.
Section 06

What this loop does well

Verified strengths, straight from where the pattern has already been proven:

What it does wellWhy it holdsEvidence
Runs unattended for hoursThe loop is closed and bounded: fixed budget, single metric, and nobody needs to be in it after Gate 0.✅ ~100 experiments ran overnight in Karpathy's run; 700 in 2 days
Keeps quality high while you sleepWinners keep, losers revert. Every step is checked — there is no "hope it works" state.✅ 15 of 83 kept in Karpathy's sample session (≈18% pass rate)
Verifies cheaply every cycleWork is checked by running a command/number/checklist — not by asking anyone. The cost of finding a win is high; the cost of checking one is near zero.✅ val_bpb mechanics, per program.md
Refines the prompt instead of the workOne round of questions up front, then confirmation, gets more out of the loop than any mid-run tweak.✅ Karpathy's own design: human iterates on prompt.md, not the code
Leaves a full audit trailEvery attempt — keep / discard / crash — is logged with reason. The trail is the reviewable memory of the run.✅ results.tsv: commit / metric / status / description
Composes into swarmsChief-scientist-in-plan-mode + workers, or N loops on N branches — the pattern scales by spawning, not rewriting.✅ Karpathy's HN note on plan-mode + tmux workers; swarm analogy: commits as blocks.
The honest bound: everything above assumes the objective metric exists. The 5-field spec is how this loop makes one before it runs. Outside that — pure taste calls, novel-strategy calls, open-ended judgement — the loop degrades to ordinary agent work.
Stays outside the loop (always M~)Why
Money movementPayments, transfers, premium terminations, subscription cancels — any financial-irreversible action
SendsAnything that leaves the machine with M~'s name on it: email, Telegram, insurer/agent mail, posts
DeletesDestruction of files, records, accounts, or anything unrecoverable
Legal / contractual effectSignatures, commitments, terms acceptance — anything with legal consequence
Gate mechanics: each gate exit is staged: the loop ends its work there, packages the action ready-to-fire, and asks one decision question. Fire → the loop resumes instantly; amend → spec is tweaked and the loop re-runs that step; kill → logged and closed. Gates sit on the STEP — a run can hit many gates and still be one loop.
Section 07

Deliverable + audit trail + stops

What M~ gets when a run ends — the same shape as waking to a finished autoresearch run:

Deliverable
the artifact
file / report / deploy-ready piece, staged
Audit trail
every step
outcome, evidence, keep/discard/crash + reason
Decision log
gate calls
M~'s gate answers + the assumption log
Spec carried forward
the memo
next run starts from the refined spec — the prompt that got better this cycle
Stop conditionWhat happens
Deliverable acceptedLoop closes clean: artifact delivered, trail sealed, spec updated
Budget or expiry hitLoop stops, reports where it stopped + what's next — never thrashes past its budget
Gate pendingLoop halts at the gate, everything staged, resumes the instant M~ answers
M~ interruptsKarpathy: "The loop runs until the human interrupts you — period." That interrupt is always live.
Section 08

How to run it

The pattern is live in this estate already in pieces: cron jobs spin up work, decision inbox collects answers, deploy scripts execute. Loop engineering binds them with the four primitives the 261015 one-pager found missing:

PrimitiveWhere it livesStatus
Task intake (raw line → scope/ambiguity/stakes read)Intake on new tasks, Cockpit rows, cron task textSpec'd — not yet live
Question round (3–5 numbered, options offered)Runs at start of any new loop; on every "decide" rowSpec'd — not yet live
5-field spec (goal/scope/constraints/verify/budget)Task header; rides the audit trailSpec'd — not yet live
Gate protocol (stage → ask → resume)Any irreversible exit inside a runSpec'd — not yet live
Pilot pick (carried from the 261015 analysis): decision-inbox lane first. Vague "decide" rows get question rounds; answers compile to specs; reversible work runs through full loops while heavier rows still gate. First two weekly digests decide adoption — if ignored, drop the pattern rather than nag.
Section 09

Sources

Loop mechanics extracted 17 Oct 2026: