Stats
Actions
Tags
How this skill is triggered — by the user, by Claude, or both
Slash command
/myagent:loopThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
设计 Agent 的核心控制循环:何时继续、何时停止、何时恢复、何时放弃。
设计 Agent 的核心控制循环:何时继续、何时停止、何时恢复、何时放弃。
snippets/loop/loop-state-machine.ts — 核心 while(true) 循环 + 状态定义 + 终止/继续类型snippets/loop/retry-with-backoff.ts — 指数退避 + 抖动 + 错误分类 + 持久模式snippets/loop/abort-propagation.ts — AbortController 树形传播 + 工具中断行为snippets/loop/output-recovery.ts — 输出 token 多轮恢复(升级→恢复→放弃)snippets/loop/model-fallback.ts — 连续过载检测 → 模型切换 + 流式回退snippets/loop/token-budget.ts — Token 预算控制 + 收益递减检测while(true) + 明确的 return 终止点stop_reason == 'tool_use' → 执行工具后继续
stop_reason == 'end_turn' →
├─ Stop Hook 有阻塞错误? → 注入错误后继续
├─ Token Budget 未用完? → 注入提醒后继续
└─ 否 → 完成
error == 'prompt_too_long' →
├─ Context Collapse 可用? → 排空后重试
├─ 未尝试 Reactive Compact? → 全量摘要后重试
└─ 已尝试 → 失败
error == 'max_output_tokens' →
├─ 首次? → 升级 8k→64k
├─ 恢复次数 < 3? → 注入 "继续" 消息
└─ ≥ 3 → 表面错误
abort signal → 停止
| 错误 | 后果 | 正确做法 |
|---|---|---|
| 无 maxTurns | 无限循环烧钱 | 始终设置上限 |
| 首次 529 就切模型 | 浪费配额 | 连续 3 次再切 |
| 压缩后不重置计数器 | 误累积 | 成功轮次重置 |
| 中断不清理子进程 | 资源泄露 | AbortController 全链路传播 |
| 恢复无防螺旋 | 无限循环 | hasAttemptedReactiveCompact 守卫 |
| 固定重试间隔 | 雷暴效应 | 指数退避 + 随机抖动 |
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub dongliutony/myagent-skill --plugin myagent