Running the Ralph Loop with custom options
# Run the agent loop (default: 10 iterations)./ralph.sh
# Run with custom iteration limit./ralph.sh 5./ralph.sh -n 5./ralph.sh --max-iterations 5
# Run exactly one iteration./ralph.sh --once
# Run with a different supported agent./ralph.sh --agent codex./ralph.sh -a cursor -n 5
# Log in to an agent inside Ralph's deterministic sandbox./ralph.sh --login./ralph.sh --login --agent cursor
# Publish the configured dev port to the selected agent sandbox./ralph.sh --ports./ralph.sh --ports --agent codex
# Print the deterministic sandbox name./ralph.sh --print-name./ralph.sh --print-name --agent codex
# Give the sandbox more memory or CPUs (applies when Ralph creates it)./ralph.sh --memory 12g --cpus 10
# Stop once N high-impact decisions await review in .agent/DECISIONS.md (default 3, 0 = off)./ralph.sh --max-open-decisions 5
# Pass extra options to the selected agent./ralph.sh --agent codex -- --model gpt-5.5./ralph.sh -a gemini -- --model pro
# Show help./ralph.sh --helpNB: you might need to run
chmod +x ralph.shto make the script executable.
--memoryand--cpusonly take effect when the sandbox is created. To resize an existing one,sbx rm <name>it first (./ralph.sh --print-nameprints the name).
Between iterations
Section titled “Between iterations”- Failed iterations. If the agent exits non-zero before finishing its final message (for example killed by a signal), Ralph marks the iteration
✗, shows the last lines of output and any commits it made, and moves on. After 3 failed iterations in a row that landed no commits it stops (RALPH_MAX_FAILED_ITERATIONS=Nchanges the limit,0turns it off). - Cleanup hook. If
.agent/hooks/after-iteration.shexists, Ralph runs it inside the sandbox after every iteration (60 s limit). Use it to stop leftover dev servers and browsers; keep databases running. The installer seedsafter-iteration.sh.example; rename it to enable. - Decisions. The agent records judgment calls in
.agent/DECISIONS.mdinstead of stopping to ask, and usesDECIDEonly for course-changing choices. Ralph stops when untickedhighentries reach--max-open-decisions.
The default “mode” is “implementation”. Depending on your use case, you might want to change
.agent/PROMPT.mdto a different mode, e.g. “refactor”, “review”, “test” etc.
⚠️ If you want to use a different language or testing framework, see below.
(Optional) Adjusting to your language/framework
Section titled “(Optional) Adjusting to your language/framework”This script assumes the following are installed:
- Playwright for e2e testing
- Vitest for unit testing
- TypeScript for type checking
- ESLint for linting
- Prettier for formatting
If you’d like to use a different language, testing framework etc. please adjust .agent/PROMPT.md to reflect your setup, server ports and startup commands etc.
👉 The loop is controlled by this prompt, which will be sent to the agent each iteration.