Skip to content
RALPH LOOP

Running the Ralph Loop with custom options

Terminal window
# 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 --help

NB: you might need to run chmod +x ralph.sh to make the script executable.

--memory and --cpus only take effect when the sandbox is created. To resize an existing one, sbx rm <name> it first (./ralph.sh --print-name prints the name).

  • 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=N changes the limit, 0 turns it off).
  • Cleanup hook. If .agent/hooks/after-iteration.sh exists, 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 seeds after-iteration.sh.example; rename it to enable.
  • Decisions. The agent records judgment calls in .agent/DECISIONS.md instead of stopping to ask, and uses DECIDE only for course-changing choices. Ralph stops when unticked high entries reach --max-open-decisions.

The default “mode” is “implementation”. Depending on your use case, you might want to change .agent/PROMPT.md to 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:

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.