InthebeginningtherewasRalph...andRalphhadaloop.

Akawhyyoushouldn'ttrusttheClankerstomarktheirgoalsascomplete.

I’m not gonna rehash the entire history of the Ralph loop. You know what it is.

Code snippets by ChatGPT, cuz I’m lazy. Apologies if they’re not precise enough.

while : ; do
  cat PROMPT.md | npx --yes @sourcegraph/amp
done

That’s it. No skills, no extra tools, no fancy /commands. It keeps running until the same prompt.md over and over again, always in a new session with fresh context until you feel like you’ve burnt enough tokens or when you sense a disturbance in the force and predict the Clanker should’ve been done by now.

And then the shit started going down and people started bastardising it, by giving the agent options.

#!/usr/bin/env bash
PROMPT_FILE="PROMPT.md"
LOG_FILE="ralph.log"
DONE_MARKER="[done]"

while : ; do
  echo "===== RALPH RUN: $(date) =====" | tee -a "$LOG_FILE"
  OUTPUT="$(cat "$PROMPT_FILE" | npx --yes @sourcegraph/amp 2>&1)"
  echo "$OUTPUT" | tee -a "$LOG_FILE"

  if echo "$OUTPUT" | grep -qiF "$DONE_MARKER"; then
    echo "Detected $DONE_MARKER. Ralph is going to sleep." | tee -a "$LOG_FILE"
    break
  fi

  echo "No $DONE_MARKER found. Running again in 3 seconds..." | tee -a "$LOG_FILE"
  sleep 3
done

This one runs until agent outputs a “done marker”. Now a question for y’all…

What do Clankers love doing most? What have they been trained on? Any guesses?

Achieving their goals (foreshadowing intended) as quickly and as efficiently as possible. At all cost.

This means they will rush, cut corners and try to satisfy your request, no matter how crappy the means to achieve it would be.

#clanker_goals

This brings us to the hyped up /goal - the Codex version of the Ralph loop, which unfortunately borrows from the more “agentic” version.

Somewhat required reading if you wanna really understand what is going on.

https://github.com/openai/codex/blob/main/codex-rs/core/templates/goals/continuation.md

https://github.com/openai/codex/tree/main/codex-rs/core/src/tools/handlers/goal

Or a Pi version which is more “at a glance”.

https://github.com/fitchmultz/pi-codex-goal/blob/main/src/prompts.ts

The idea is stupid simple and I love it… and hate it at the same time. You set a goal, the agent has access to it, can update it, track its progress (simplifying here).

You YOLO it and hope for the best. “Make no mistakes”, “cut no corners” and all that voodoo magic. For anyone who works with coding agents enough, it’s clear that they do make mistakes and they do cut corners.

They complete goals based on vibes. They report success all the time in a standard chat, and yet half the shit you asked it to do doesn’t work. You start swearing at your terminal, issuing shorter and shorter prompts.

So why do you trust a Clanker to correctly mark a long running task as done with no supervision or corrections?

Not all is hopeless hype.

Okay, you random dude, then why are people constantly tweeting about these amazing /goal runs?

Okay random reader. Keep in mind most of them are screenshots of how long a goal has been running, not necessarily the outcome of the goal. A lot of them for whatever reason don’t share any of it. Because it would probably show a half-baked result and honesty doesn’t really get you likes and follows (FML).

There are a few people I would trust with it. I’m sure you can name a few that probably had more success with /goal than your average Joe/Jane. Why? Few options:

  1. They’ve spent SHITLOADS of time with the Clankers and they know precisely what they can expect from them, and what is a pipedream (for now).
  2. They discovered a hack where the agent writes a better goal for itself than you ever would. This is what you call a… plan mode. Or just chatting through your idea with the agent, and then asking it to create a doc, and making it “do the do”.
  3. They write an extremely detailed spec for the goal, they have a brownfield codebase, they asked for a refactor - basically, they’ve given the agent something very clear to work with.

So, in my humble opinion, it comes down to: managing expectations, somewhat carefully prep before you set a goal or giving the agent context to work with - even if it’s a half-baked, semi-functional codebase.

I’m going to clanker hell.

Right, so there is only so much whinging one can do before giving their take. My take on this was different. I tortured the Clanker using a Clanker.

While I cant find the actual files for this anymore, here’s what I did:

  1. Set up a main orchestrator agent - defined its identity to be a ruthless judge.
  2. Set up a /command for it explaining that its task is to orchestrate a single subagent to deliver the prompt. The command would go into specifics about how… The task must be progressively disclosed so the worker subagent doesn’t instantly know the entire scope.
  3. Fire it up and watch how when the subagent thinks it’s done, the taskmaster issues it more work (say it in WC3 peon’s voice) that it wasn’t previously aware of.

I am generally against subagents, since with delegation, you lose the original intent. But when a main agent’s only objective is to progressively disclose that intent… This is where the fun begins.

The non-conclusive conclusion.

So did I use it a lot? Nah. It’s all BS experiments. Nearly all of it resulted in more fixing than it was worth it.

Maybe I needed prompts like the OpenAI Symphony spec, which looks like a /goal in itself. ( https://github.com/openai/symphony/blob/main/SPEC.md )

Or maybe I haven’t clocked enough hours on the Clanker clock at the time to actually think about things that I wouldn’t be disappointed with to put in a loop.

Although I’ve recently, ca 1500hrs later, tried a /goal and pointed the agent towards a repo I wanted him to take inspo from to do a bit of a rejig. Even with references, it failed miserably.

So anyway, to wrap this rambling up, do not believe the hype blindly. You will be mostly burning tokens, unless your goals are very specific. Do it “for fun” and have no expectations.

Did you have any actual success with loops that the agent can close itself?

Or are you faking it for them views? :P

Originally published on: https://x.com/Howaboua/status/2053983892747497883?s=20