← Back to Skills Marketplace
weidongkl

Loop Prevention

by wei dong · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
81
Downloads
0
Stars
2
Active Installs
2
Versions
Install in OpenClaw
/install loop-prevention
Description
操作循环防止规范。防止 Agent 对同一操作反复执行造成资源浪费。适用于 exec 命令、工具调用、文件读写等所有可重复操作。核心规则:同一操作最多 5 次、结果不理想换策略、检测到循环立即停止。
README (SKILL.md)

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 次操作相同? 是 → 循环信号,立即停止
Usage Guidance
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.
Capability Analysis
Type: OpenClaw Skill Name: loop-prevention Version: 1.0.1 The skill bundle 'loop-prevention' consists solely of instructional markdown (SKILL.md) designed to improve agent efficiency by preventing infinite loops and repetitive command execution. It contains no executable code, network requests, or malicious prompt injection; rather, it provides safety guidelines for the agent to limit retries and change strategies when operations fail.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install loop-prevention
  3. After installation, invoke the skill by name or use /loop-prevention
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
精简优化:去除冗余描述,保留核心规则+触发信号+正确做法+检查清单
v1.0.0
初始版本:操作循环防止规范,适用于所有可重复操作
Metadata
Slug loop-prevention
Version 1.0.1
License MIT-0
All-time Installs 2
Active Installs 2
Total Versions 2
Frequently Asked Questions

What is Loop Prevention?

操作循环防止规范。防止 Agent 对同一操作反复执行造成资源浪费。适用于 exec 命令、工具调用、文件读写等所有可重复操作。核心规则:同一操作最多 5 次、结果不理想换策略、检测到循环立即停止。 It is an AI Agent Skill for Claude Code / OpenClaw, with 81 downloads so far.

How do I install Loop Prevention?

Run "/install loop-prevention" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Loop Prevention free?

Yes, Loop Prevention is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Loop Prevention support?

Loop Prevention is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Loop Prevention?

It is built and maintained by wei dong (@weidongkl); the current version is v1.0.1.

💬 Comments