Back to Hooks

Ralph Loop

Implements an autonomous feedback loop for task refinement. It monitors the agent's output for a specific "completion promise" tag (<promise>...). If ...

Ralph Loop

Description

Implements an autonomous feedback loop for task refinement. It monitors the agent's output for a specific "completion promise" tag (<promise>...). If the tag is missing or the work is incomplete, it automatically re-prompts the agent to continue, up to a maximum number of iterations.

Features

  • Automated Iteration: Continues the session automatically if the task is not marked complete.
  • Completion Detection: Scans transcript files and message history for the <promise> tag.
  • State Persistence: Persists loop state (iteration count, prompt) to disk to survive session restarts.
  • User Feedback: Displays TUI toasts for loop progress and completion.

Trigger Events

  • session.idle: Checks if the current task has completed its promise. If not, injects a continuation prompt.
  • session.error / session.deleted: Cleans up loop state on errors or deletion.

Usage

Triggered programmatically or via specific agent commands that initiate a "Ralph Loop".