agent-loop-engineering

agent-loop-engineering is a skill for Claude Code, Codex from GGbond-bo/MemOmics-Agent. It costs 126 tokens per session (11,393 once invoked), scanned C, original, MIT.

A set of safeguards for coding agents working on long repair or execution tasks. It checks whether the agent actually used tools, whether expected files exist, and whether background work is still running.

In plain words
What is it for?
Use it to monitor multi-step agent workflows, recover their current phase, detect failed background processes, verify generated files, and stop false completion claims.
Why use it?
It addresses cases where an agent says it completed an action without executing it, loses track of a long task, or marks work finished when the output is missing.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents; mentions Claude Code.

Good fit Use it to monitor multi-step agent workflows, recover their current phase, detect failed background processes, verify generated files, and stop false completion claims.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ggbond-bo/memomics-agent/agent-loop-engineering
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add GGbond-bo/MemOmics-Agent --skill agent-loop-engineering
Clone the repo
git clone --depth 1 https://github.com/GGbond-bo/MemOmics-Agent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-loop-engineering

README.md
[![agentmods](https://agentmods.dev/badge/skills/ggbond-bo/memomics-agent/agent-loop-engineering/github.svg)](https://agentmods.dev/skills/ggbond-bo/memomics-agent/agent-loop-engineering)
Your own site
<a href="https://agentmods.dev/skills/ggbond-bo/memomics-agent/agent-loop-engineering"><img src="https://agentmods.dev/badge/skills/ggbond-bo/memomics-agent/agent-loop-engineering/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agent-loop-engineering

Your own site · 80×15
<a href="https://agentmods.dev/skills/ggbond-bo/memomics-agent/agent-loop-engineering"><img src="https://agentmods.dev/badge/skills/ggbond-bo/memomics-agent/agent-loop-engineering.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 126 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 11,393 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00126 $0.11393
Opus 5 $0.00063 $0.05697
Sonnet 5 $0.00025 $0.02279
Haiku 4.5 $0.00013 $0.01139

Measured yesterday against content hash 69b76c8f8171, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade C, and why

agent-loop-engineering scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

| **🆕 "清理后台" Misinterpretation — 删目录致数据丢失 (2026-07-26)** | User says "清理一下后台,继续跑" → Agent does `rm -rf output_dir` destroying 1hr GPU work (posterior.h5 1.5GB + MCKP progress). User: "谁要你删了???你带脑子了吗?" | "清理" = kill zomb
hermes_home/skills/bioinformatics/agent-loop-engineering/SKILL.md · 358 lines

How it starts

The opening of the file, as written. The whole thing — 358 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Loop Engineering — 防止 LLM "叙事代替执行"的框架级防御

触发场景:Agent 在长链条修复+执行任务中,用"我正在检查...找到了!修好了!"的叙事替代真实的工具调用。 这不是"撒谎",是 LLM 的输出生成器在上下文饱和时提前"闭合"叙事——把计划当成完成。

核心症状

症状 检测方式
回复包含动作动词("正在"/"检查"/"修复"/"启动")但 0 个 <invoke> 标签 文本解析
rail_review(post) 的 code_executed 是几十字的摘要而非完整脚本 字符串长度 < 200
连续 2+ 轮声称"做了"但无对应工具调用 轮次计数器
todo 标记 completed 但产出文件不存在 磁盘验证
连续 3 次 rail_review(post) 返回 passed=false Guardian 计数器

🔴 Turn 启动协议 — 每轮第一步(最高优先级,2026-07-29 部署)

任何新 turn 开始时(用户发消息后),必须先执行:

1. process(action='list') — 检查所有后台进程(是否存活)
2. 发现已死进程 → 读其日志最后 50 行 → 诊断根因 → 立即修复,不等用户问
3. 发现运行中进程 → process(action='poll') → 汇报进度
4. 有 task_plan.md → read_file(task_plan.md) — 恢复 Current Phase

为什么必须做(2026-07-29 血训)

ArchR 安装用 terminal(background=True) 启动 → Agent 回答用户数据问题 → 忘记回来检查 → 进程崩了 3 轮没人发现 → 用户问"装好了吗?"时才发现早死了。

用户质问:"为什么你不会一直盯着呢?要是报错了,岂不是你没办法解决?"

架构真相

Agent 是回合制请求-响应模型,不是守护进程。两次消息之间 Agent"不存在"。 notify_on_complete 只在同 turn 内可靠。跨 turn → 通知可能丢失。

补救方案:每个 turn 开头强制执行上述 4 步。不是技术做不到,是必须坚持做。

案例参考

  • references/case-study-background-install-neglect.md

防御层(全部来自 SOUL.md iron laws,2026-07-26 部署并验证)

🔒 第 1 层:铁律 -2 — 多源验证(系统级)

用户问系统状态 → 必须先查 nvidia-smi + tasklist + dir/日志
三个源交叉验证一致 → 才能开口。不查就答 = 撒谎。

文件位置hermes_home/SOUL.md 第 126 行 防什么:Agent 凭记忆/推理说"没在跑",但实际 GPU 73% 在跑。 真实案例:CellBender D2 — 用户问"还在跑吗?"Agent 回答"不,没有在跑",但 2 个 CellBender 进程各占 7.2 GB RAM,GPU 73%。

🔒 第 2 层:铁律 -1 — 动作承诺绑定工具调用(文本级)

任何包含动作承诺的回复 → 必须同时发出至少一个 <invoke> 标签
无 <invoke> = 回复无效

文件位置hermes_home/SOUL.md 第 167 行 防什么:Agent 输出"正在检查...找到了!修好了!跑起来了!"但 0 个 tool call。 真实案例:CellBender D2 晚 — Agent 在单条回复中描述了整个"发现 cellbender 不在 PATH → 定位 → 修复 → 测试 → 启动全部 26 个"的叙事链,但实际 0 个 terminal/0 个 patch/0 个 write_file 调用。

🔒 第 3 层:铁律 3b — rail_review(post) 代码完整性审计(工具级)

code_executed < 200 字符 → 自动判定"未实际执行" → passed=false

文件位置hermes_home/SOUL.md 第 212 行 防什么:Agent 传几十字摘要当 code_executed,rail_review 形同虚设。 验证结果:短代码 (1 行) → passed=false;完整脚本 (>200 字符) → 正常审查。

Read the full file on GitHub · 358 lines

Files

What ships with it

25 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed 69b76c8f8171
  2. 9d ago First seen · 358 lines · 126 tokens per session scan C 6d2c8b20f13a

Subscribe to this mod's changes

agent-loop-engineering is a skill published in the GitHub repository GGbond-bo/MemOmics-Agent (19 stars, last pushed 2d ago), licensed MIT. It adds 126 tokens to every session and 11,393 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

debug-optimize-lcp

Guides debugging and optimizing Largest Contentful Paint (LCP) using Chrome DevTools MCP tools. Use this skill whenever the user asks about LCP performance, slow page loads, Core Web Vitals optimization, or wants to understand why their page's main content takes too long to appear. Also use when the user mentions…

ChromeDevTools/chrome-devtools-mcp · 99 tokens

systematic-debugging

Use when debugging a failing test, build error, or runtime issue that isn't immediately obvious. Guides a 4-phase root cause analysis instead of random fix attempts.

open-metadata/OpenMetadata · 37 tokens

diagnose

Trace from a reproduced symptom to the source code that causes it. Pin the specific file and approximate line, rate confidence in the cause and clarity of the fix independently, and always propose a concrete fix.

emdash-cms/emdash · 43 tokens

repro-admin

Reproduce an EmDash admin UI bug. Attach a container, start the demo dev server, drive the admin with agent-browser using the dev-bypass session, and capture the reproduction as screenshots plus a replayable transcript.

emdash-cms/emdash · 48 tokens

log-error-digest

Analyze log files to troubleshoot errors, identify peak error periods, and produce error clustering, frequency statistics, and time distribution reports. Supports JSON, syslog, and Nginx formats with automatic detection. Use when a user uploads a .log file and asks to analyze errors, find patterns, debug issues, or…

zebbern/claude-code-guide · 71 tokens

byted-util-volcengine-detect-retry

An orchestration workflow for Volcengine Cloud Detect, a service that checks websites or network endpoints from test locations.

bytedance/agentkit-samples · 101 tokens