DEV Community

Cover image for The Ralph Loop Is Not Enough
Lizzie Siegle
Lizzie Siegle

Posted on

The Ralph Loop Is Not Enough


"I don't prompt Claude anymore. My job is to write loops."

— Boris Cherny, Claude Code creator

Though I see where he's coming from, I'd put it differently.

A developer's job isn't to write loops. It's to design state machines.


Every major agent framework — Claude Code, Codex, Cursor, LangGraph — does the same thing under the hood. A while loop calls an LLM, checks if it wants to use a tool, runs the tool, repeats until done. The loop isn't just a solved problem. It's a boring problem.

The hard part is everything around it.

A loop has no idea what state the work is in. It just keeps going until something breaks or you run out of tokens. That's the Ralph Loop — named after the Simpsons kid who put a crayon in his nose. Agent, infinite loop, go. The Ralph Loop works, is famous, and has zero memory of where it is in the job. Like Ralph, it keeps going without knowing why.


The Fix: A Finite State Machine

Think about the NBA Finals. The Spurs and the Knicks aren't improvising — every possession has a state. Fast break. Inbound play. Half court set. Each one has specific reads and triggers for what happens next. Point guard De'Aaron Fox isn't making it up as he goes. The system tells him what situation he's in, and the situation tells him what to do.

Your agent works the same way. You define the stages — planning, implementing, reviewing, error handling — and you define what triggers each transition. The agent doesn't orchestrate. It executes. One focused job per state.


Why This Matters in Production

When agents break, it's almost always one of three things:

  • Infinite loops — one system repeated the same answer 58 times before anyone noticed.
  • Context overflow — the history gets so long the model starts quietly forgetting things.
  • Goal drift — 70 turns in, "don't touch auth" has completely evaporated.

State machines fix all three. The loop runs until the list is empty, not until you run out of tokens. The goal lives in the transition logic, not in the context getting squeezed. And failures don't spiral — they transition to an error state with explicit rules for what's next.


Observability

State machines also give you observability. You can see the exact sequence of states the agent passed through before it broke.

That's what Entire is built for — full transcript history across your agent sessions, so you can see not just what your agents did, but what state they were in when they did it.


A system you can't inspect isn't a system. It's a loop with better vibes.

Top comments (1)

Collapse
 
xulingfeng profile image
xulingfeng

The Ralph Loop naming is spot on. The infinite loop problem isn't just about token waste — it's that the agent can look productive while slowly forgetting what it was supposed to do. State machines as the fix make sense, but the real win is what you mentioned at the end: observability. A loop you can't inspect is just a bet.