Ralph Loop Failure Modes (Context Rot, Runaway Cost) and How to Avoid Them
A Ralph loop fails in a handful of predictable ways. Here is each failure mode, why it happens, and the specific guardrail that stops it.
A Ralph loop fails in a handful of predictable ways. Here is each failure mode, why it happens, and the specific guardrail that stops it.
A Ralph loop stops on an explicit signal, not a guess. How promise tags and exit codes tell the loop and your scripts when the agent is COMPLETE, BLOCKED, or needs a decision.
PROMPT.md is the instruction sent to the agent on every iteration. Here is how to structure it so a fresh-context agent reorients from disk and ships one verified task at a time.
One-shot prompting solves small changes in a single response and stalls on hard ones. A Ralph loop iterates with fresh context and tests until the work is actually done.
Geoffrey Huntley popularized the Ralph technique by running a coding agent in a plain Bash loop until a working programming language fell out the other end. Here is where the idea came from and why it stuck.
The Ralph technique runs a coding agent in a loop until it signals completion. Fresh context each iteration, state on disk, and a promise tag that tells the loop when to stop.