Execution Loop for Openclaw

A sophisticated control framework for AI agents that enforces persistent execution, prevents task drift, and verifies completion through multi-layered stop hooks.

lanyasheng
v2.4.0
Apr 8, 2026
0
956
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install execution-loop

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install execution-loop using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Execution Loop?

The Execution Loop skill is a critical governance layer for AI coding agents, designed to solve the common problem of agents stopping before a task is truly finished. It provides a structured set of patterns to manage agent autonomy, ensuring that the agent remains active and focused until defined goals are met. By leveraging the power of Openclaw Skills, developers can implement strict verification gates that monitor agent behavior in real-time.

At its core, the skill manages the lifecycle of an agent session by intercepting stop events and applying logic-based blocks. Whether it is preventing an agent from being too hesitant through the Doubt gate or ensuring a long migration task stays on track via the Ralph persistent loop, this skill provides the guardrails necessary for high-stakes autonomous operations.

Execution Loop Use Cases

  • Force persistent execution for complex, multi-file refactoring tasks that an agent might otherwise stop mid-way.
  • Block agents from providing vague or uncertain answers by detecting hedging language and demanding concrete evidence.
  • Maintain focus on the original task description during long sessions to prevent the agent from drifting into unrelated code optimizations.
  • Automate headless agent pipelines where session control and budget awareness are required without human intervention.
  • Synchronize task progress against a predefined checklist to ensure no sub-task is overlooked.

How Execution Loop Works

  1. The skill performs an initial triage of the task complexity based on file counts and keywords to determine the appropriate hook level.
  2. Developers initialize a tracking session using Ralph scripts, setting maximum iteration limits and task identifiers.
  3. Every time the agent attempts to end its turn, a chain of Stop hooks is triggered to evaluate the session status.
  4. High-priority safety valves check for critical conditions like 95% context usage or authentication errors to ensure the system remains stable.
  5. If safety checks pass, secondary gates like the Doubt gate and Task Completion Verifier scan the output for semantic correctness and checklist completion.
  6. If the task is deemed incomplete, the skill blocks the stop event and injects a context-aware continuation prompt to guide the agent forward.

Execution Loop Setup

To integrate these Openclaw Skills into your environment, configure the Stop hooks in your .claude/settings.json file:

{
  "hooks": {
    "Stop": [
      { "hooks": [{ "type": "command", "command": "bash ralph-stop-hook.sh" }] },
      { "hooks": [{ "type": "command", "command": "bash doubt-gate.sh" }] },
      { "hooks": [{ "type": "command", "command": "bash task-completion-gate.sh" }] }
    ]
  }
}

To start a controlled execution loop, use the initialization script:

# Initialize a loop with a 50-turn maximum for a specific task
bash ralph-init.sh my-migration-task 50

Execution Loop Data Schema & Taxonomy

The skill manages state through structured JSON files to maintain consistency across session turns:

File Type Path Purpose
Ralph Status sessions/<id>/ralph.json Stores iteration counts, max limits, and active status.
Task Checklist .harness-tasks.json An array of objects defining task names and their completion boolean.
Guard File $TMPDIR/doubt-gate-<id> Temporary file used to prevent the Doubt gate from triggering multiple times in a single turn.

These schemas ensure that even if a session is interrupted, the Openclaw Skills framework can resume execution with accurate state data.

Execution Loop Advanced Features

  • Adaptive Complexity Triage: Automatically scales from light verification for trivial tasks to full semantic gating for critical architectural changes.
  • Iteration-Aware Messaging: Dynamically rotates continuation prompts to prevent agents from entering repetitive compliance modes.
  • Drift Re-anchoring: Periodically re-injects the original task requirements into the context to ensure long-running agents don't lose sight of the objective.
  • Graceful Handoff: Triggers documentation generation and state saving when context limits or turn limits are approached.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*