Skip to the content.

The Ralph Invariants

Source: Geoffrey Huntley, “Ralph Wiggum as a software engineer” and “everything is a ralph loop”.

Ralph in its purest form:

while :; do cat PROMPT.md | agent ; done

Kelix treats the following four properties as invariants. Every feature must preserve them; any feature that cannot be built without breaking one does not ship.

1. Static prompt

The prompt fed to the agent is the same every iteration. It is not assembled from conversation history and it is not mutated by the agent mid-run. Tuning the prompt is an operator act between runs (“erecting signs”), not an agent act during one.

Kelix nuance: Kelix injects memory digests and skills into the prompt as data blocks with fixed slots. The prompt template is static; only the file-derived data inside clearly delimited slots varies. The agent is told the blocks are reference data, not instructions.

2. Fresh context per iteration

Every iteration is a brand-new agent process with an empty context window. Nothing survives in the model’s head between iterations. This is what makes the loop deterministic-ish and cheap: no context rot, no compounding confusion, and a wrong turn only costs one iteration.

Huntley: use as little of the context window as possible; the primary context acts as a scheduler and expensive work goes to subagents. Kelix honors this by budgeting every injected byte (plan slice, memory digest, skills) with hard caps.

3. Deterministic stop sentinel

The loop stops for mechanical, checkable reasons only:

The loop never stops because the agent “feels done.” Conversely, the agent cannot keep the loop alive by refusing to exit — each iteration process exits unconditionally; continuation is the runner’s decision.

4. Externalized state

All state lives in files and git history: the plan/backlog, the memory, the logs, the coordination data. The repo is the database. Anyone (human or the next iteration) can reconstruct exactly where the run is by reading files. Corollaries:

Supporting observations from the source posts (not invariants, but encoded in Kelix)