Loop Prevention

v1.0.1

操作循环防止规范。防止 Agent 对同一操作反复执行造成资源浪费。适用于 exec 命令、工具调用、文件读写等所有可重复操作。核心规则:同一操作最多 5 次、结果不理想换策略、检测到循环立即停止。

0· 72·2 current·2 all-time
bywei dong@weidongkl

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for weidongkl/loop-prevention.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Loop Prevention" (weidongkl/loop-prevention) from ClawHub.
Skill page: https://clawhub.ai/weidongkl/loop-prevention
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install loop-prevention

ClawHub CLI

Package manager switcher

npx clawhub@latest install loop-prevention
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description match the SKILL.md: guidance to detect and stop repeated execs, tool calls, file reads/writes and API requests. No unrelated credentials, binaries, or installs are requested.
Instruction Scope
Instructions are procedural guidelines and examples (redirecting output to /tmp/out.txt, using head/tail/wc, changing params/tools). They do not ask the agent to read unrelated system files, call external endpoints, or exfiltrate data.
Install Mechanism
No install spec and no code files — instruction-only skill; nothing is written to disk by the skill itself beyond example usage of /tmp in the docs.
Credentials
No environment variables, credentials, or config paths are required. The examples reference common temporary files but do not require secrets or service tokens.
Persistence & Privilege
always is false and the skill is user-invocable; it does not request permanent presence or modify other skills or system-wide settings.
Assessment
This is a coherent, low-risk guideline for preventing repeated operations. It's just policy text — it doesn't enforce behavior by itself. Before relying on it, ensure your agent's runtime actually implements counting and stopping logic (the SKILL.md describes the policy but enforcement is up to the agent). Note the examples write to /tmp; that is normal but means temporary files may be created. Also be aware these heuristics can produce false positives (legitimate repeated retries might be stopped); test with your agent in safe environments.

Like a lobster shell, security has layers — review code before you run it.

latestvk97499ynmyc8jehtad7258a1sx85g04h
72downloads
0stars
2versions
Updated 3d ago
v1.0.1
MIT-0

Loop Prevention

防止对同一操作反复执行。适用于 exec 命令、工具调用、文件读写、API 请求等所有可重复操作。

核心规则

  1. 同一操作最多 5 次 — 超限必须停止
  2. 结果不理想时换策略 — 换参数、换工具、换思路,不要重复相同操作
  3. 检测到循环倾向立即停止 — thinking 中出现"再试一次"、连续 2 次相同操作 → 停止并向用户说明

触发信号

信号说明
连续 2 次相同或极相似的操作循环开始
输出被截断后再次执行相同命令截断≠失败,用重定向
thinking 中出现"再试一次"意图自我循环预警
结果越来越差但还在继续必须停止

正确做法

输出被截断

# ❌ 反复执行
git diff

# ✅ 重定向或限制
git diff > /tmp/out.txt && head -200 /tmp/out.txt
git diff --stat

工具调用失败

# ❌ 相同参数反复调用
tool_call(same_params)

# ✅ 换参数或换工具
tool_call(different_params)
other_tool(same_params)

需要完整内容

command > /tmp/out.txt
head -50 /tmp/out.txt    # 前段
tail -50 /tmp/out.txt    # 后段
wc -l /tmp/out.txt       # 总量

检查清单

问题行动
这个操作执行过吗?是 → 计数,超限则停止
上次结果不理想?是 → 换策略
在想"再试一次"?是 → 停止,换方法
连续 2 次操作相同?是 → 循环信号,立即停止

Comments

Loading comments...