Ralph Wiggum Loop
The Ralph Wiggum Loop is the core execution model of Smithers. Named after Ralph Wiggum’s famous “I’m in danger” catchphrase, it controls iterative loops that could potentially run away.The Execution Model
Smithers uses a reactive render loop powered by Solid.js signals:- Render: Your JSX components render using Solid’s fine-grained reactivity
- Execute:
<Claude>nodes execute via the Claude Code CLI - Update:
onFinishedcallbacks update Solid signals - Re-render: Signal changes trigger reactive updates
- Loop: Process repeats until no pending agents remain
Why “Ralph Wiggum”?
The name captures two key ideas:- Iteration Control: Like Ralph’s oblivious danger-awareness, loops can run away if not controlled
- Safety Rails: The
<Ralph>component providesmaxIterationsto prevent infinite loops
How It Differs from Other Frameworks
| Traditional Agent Loops | Smithers Ralph Loop |
|---|---|
| Imperative while loops | Declarative reactive rendering |
| Manual state tracking | Automatic signal propagation |
| Hard to visualize flow | Components describe the flow |
| State scattered in closures | Centralized in Solid signals |
The Ralph Component
The<Ralph> component wraps iterative workflows:
Reactive Updates
The power of the Ralph Loop comes from Solid.js reactivity:setPhase("implement") is called:
- The signal updates
- Solid detects the change
- Only the affected branch re-renders
- The new
<Claude>component mounts and executes
Fire-and-Forget Pattern
Components use an async IIFE pattern inonMount:
- Components execute when they mount
- Results trigger callbacks that update signals
- Signal updates cause re-renders
- New components mount and execute
Orchestration Context
The<Ralph> component provides context for task coordination:
- Active tasks
- Completed tasks
- Iteration count
- Orchestration state
Best Practices
Always set maxIterations
Always set maxIterations
Without a limit, a bug in your state logic could cause infinite loops:
Use signals for phase transitions
Use signals for phase transitions
Let reactivity drive the flow instead of imperative logic:
Handle the maxIterations callback
Handle the maxIterations callback
Know when you’ve hit the limit: