A crucial framework-agnostic skill designed to prevent infinite loop recursion, runaway token bills, and stuck behaviors in LLM-driven agent workflows.
The fastest way to install a skill directly from the registry.
npx clawhub@latest install agentsop-bounded-loop
Copy the skill folder to one of these locations
~/.openclaw/skills/ <project>/skills/ Priority: Workspace > Local > Bundled
Copy this prompt to OpenClaw to install it automatically.
Help me install agentsop-bounded-loop using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).
Get the raw skill files in a ZIP archive.
This skill establishes a universal control mechanism for any LLM-driven loop—such as agent retries, plan-act-observe steps, multi-agent handoffs, and self-correcting test-fix cycles. It addresses the fundamental truth that language models are not reliable terminators on their own. By decoupling the termination logic from the AI's internal state and placing it in a framework-agnostic control structure, developers can reliably prevent runaway loops and catastrophic API billing spikes.
With Openclaw Skills, you can design deterministic safeguards including explicit iteration counters, progress witnesses, stagnation detectors, and graceful escalation paths. Implementing this design pattern ensures that when an agent gets stuck or repeats its attempts, the system halts and escalates properly instead of throwing generic framework recursion errors or exhausting your API token budgets.
To apply this skill, configure your agent's state schema and verification logic inside your code setup. Below is an example setup initializing state tracking components:
# Create a schema definition for your bounded agent loop
touch state_schema.py
Next, register a monotonic counter and stagnation check in your agent's control loop:
from typing import TypedDict, Literal, Annotated
import operator
class BoundedState(TypedDict):
messages: list
retries: Annotated[int, operator.add]
last_error: str | None
witness_hash: str | None
def check_termination(state: BoundedState) -> Literal["continue", "escalate"]:
# Cap iteration budget
if state.get("retries", 0) >= 3:
return "escalate"
# Stagnation check
if state.get("last_error") == state.get("previous_error"):
return "escalate"
return "continue"
The skill establishes a strict, auditable state taxonomy to ensure control loops run deterministically. Use the following structured fields in your agent's persistent state container:
| State Key | Type | Description | Invariant Rules |
|---|---|---|---|
retries |
int |
Monotonic loop counter tracked via system state. | Must strictly increment by 1 each iteration. |
last_error |
str |
Text representing the error returned in the last iteration. | Empty if the previous iteration succeeded. |
witness_hash |
str |
MD5 or SHA256 signature of tool arguments, plan revisions, or output values. | Used to detect duplicate calls; triggers stagnation if repeated. |
escalation_reason |
str |
Human-readable explanation of why the loop halted (e.g., budget_exhausted or stagnation_detected). |
Populated solely when routing to the escalation branch. |
Loading
A utility skill designed to guide developers and homelab enthusiasts in setting up Sun-Panel-Helper, Docker apps, and complex database environments like MIMIC III Postgres and Oracle 23ai.

An interactive AI agent skill that guides chemical engineers through the design of energy-efficient heat exchanger networks and pinch temperature analysis using Aspen Energy Analyzer.

An auto-crystallized AI skill that automates descriptive statistics, anomaly detection, and trend analysis for tabular datasets.

A practical utility skill that optimizes data querying and text manipulation by demonstrating why the Search function outperforms the Find function.

A master Standard Operating Procedure (SOP) for driving terminal-based, git-native AI pair programming workflows using Aider.

An AI-powered screening methodology designed to identify potential data fabrication, image manipulation, and statistical anomalies in biomedical and life-science publications.








































