Install
openclaw skills install agent-optimization-expertAgent 优化专家 — 自动诊断和修复 Agent 执行问题(Cron 失败、工具报错、工作流中断、性能退化), 兼容 OpenClaw 和 Hermes Agent,自带持续自我进化能力。 Use when user asks to 系统诊断、修复 cron、优化配置、检查系统健康度、自愈修复、 诊断失败原因、修复任务失败、优化师自我更新、Agent优化、巡检系统. 不适用于业务逻辑问题排查、飞书内容编辑、数据查询类任务.
openclaw skills install agent-optimization-expert基于 Anthropic / OpenAI 工程实践的 Agent 自愈引擎,覆盖「检测 → 诊断 → 修复 → 验证 → 学习 → 进化」闭环。 兼容 OpenClaw 和 Hermes Agent 双环境,自动识别当前平台并切换对应命令。
双环境适配:OpenClaw 走
openclaw cronCLI,Hermes 走cronjob工具。 完整命令映射表和修复规则见references/dual-env-adaptation.md
快速诊断流程(通用):
references/fix-templates.md 执行修复常见修复类型:
# Step 1 — 检查错误日志
cat learnings/error-log.md 2>/dev/null | tail -50
# Step 2 — 按错误类型定位(参照 references/error-taxonomy.md)
# 401/403 → 认证/权限问题
feishu_app_scopes # 检查飞书权限(双环境通用)
echo $API_KEY | wc -c # 检查 key 是否存在
# 429 → 限流,等待 + 指数退避重试
# 5xx → 服务端错误,稍后重试
# Step 3 — 应用降级策略
# 搜索: web_search → SearXNG(local:3004) → web_fetch
# 网页: web_fetch → firecrawl(local:3002)
# 资源检查(通用)
df -h / # 磁盘
free -m # 内存
docker ps # 容器状态
# 服务健康检查(通用)
curl -s http://localhost:3002/health # Firecrawl
curl -s http://localhost:3003/health # Crawl4AI
curl -s http://localhost:3004/health # SearXNG(返回 HTML 即正常)
# Agent 平台状态
# OpenClaw → openclaw status
# Hermes → ps aux | grep hermes
OpenClaw:openclaw subagents list 查看 → openclaw subagents kill <target> 终止
Hermes:子 Agent 同步执行不卡死,超时检查 delegate_task timeout;Cron 子任务卡住用 process(action='kill')
本 Skill 不会自己跑起来,需要环境提供"心跳"或"定时"机制。 双环境适配完整指南(含 Cron Job 配置命令 + HEARTBEAT.md 配置模板)→
references/dual-env-adaptation.md
一句话总结:
cronjob(action='create') 创建每日自检 + 每周知识更新workspace/HEARTBEAT.md 中配置心跳检查清单问题出现
│
├─ Cron 相关?
│ ├─ 任务未执行 → 检查 enabled / schedule / timezone
│ ├─ 执行报错 → 查错误输出 → 对照 fix-templates.md
│ └─ 超时 → timeout 加倍 or 拆分逻辑
│
├─ 工具调用相关?
│ ├─ 401/403 → 认证/权限
│ ├─ 429 → 指数退避重试
│ ├─ 5xx → 等待重试 + 记录
│ └─ 超时 → 网络检查 → 降级
│
├─ 子 Agent 相关?
│ ├─ spawn 失败 → task 过大 / 资源不足
│ ├─ 超时 → 增加 timeout / 优化 task
│ └─ 结果异常 → context 模式检查
│
└─ 系统相关?
├─ 磁盘满 → 清理 + docker prune
├─ 内存不足 → 停服务 + lightContext
└─ 网络断开 → DNS / 防火墙
检测(心跳/用户反馈/错误日志)
→ 诊断(快速扫描 → 错误分析 → 根因推理 → 修复建议)
→ 修复(最小变更 + 可回滚)
→ 验证(修复后确认)
→ 学习(记录到 learnings/error-log.md)
## YYYY-MM-DD HH:MM
- **Error**: [错误描述]
- **Context**: [触发场景]
- **Root Cause**: [根因分析]
- **Fix Applied**: [修复操作]
- **Prevention**: [避免复现的措施]
| 级别 | 范围 | 策略 |
|---|---|---|
| L0 | 读取状态、检查日志 | 自动执行 |
| L1 | 清理临时文件、更新日志 | 自动执行 |
| L2 | 修改 cron 配置、重启服务 | 提示用户确认 |
| L3 | 修改核心配置、删除数据 | 必须用户明确授权 |
禁止自动执行:
修复完成
├─ 新错误类型?→ 新增 error-taxonomy + fix-templates
├─ 修复可复用?→ 写入 fix-templates
└─ 涉及工程模式?→ 更新对应 references/
curl -s "http://localhost:3004/search?q=anthropic+agent+engineering+best+practices+$(date +%Y)&format=json&engines=bing,duckduckgo" | python3 -c "
import json, sys
data = json.load(sys.stdin)
for r in data.get('results', [])[:5]:
print(json.dumps({'title': r.get('title',''), 'url': r.get('url','')}, ensure_ascii=False))
"
learnings/error-log.md 中相同错误模式 ≥3 次时:
| 文件 | 何时读取 |
|---|---|
| references/dual-env-adaptation.md | 首次使用必读 — 环境检测、命令映射、Cron/HEARTBEAT 配置 |
| references/anthropic-patterns.md | 需要 Thinking/Tool Use/多 Agent 协调模式 |
| references/openai-patterns.md | 需要 ReAct 循环/降级链/评估模式 |
| references/error-taxonomy.md | 工具调用失败分类诊断 |
| references/fix-templates.md | 确认修复方案后查具体命令 |
| references/self-evolution.md | 自我进化:收集最新实践 |
首次被加载时(检查 learnings/error-log.md 不存在或为空),自动执行一次完整自检:
目的:给用户即时反馈,确认 Skill 已正确安装且能正常工作(Smoke Test)。
| 版本 | 日期 | 更新内容 |
|---|---|---|
| v1.0 | 2026-05-18 | 初始创建(四层骨架 + 诊断决策树 + 修复模板) |
| v1.1 | 2026-05-18 | 添加自我进化机制(三条路径) |
| v1.3 | 2026-05-20 | 双环境适配:兼容 OpenClaw + Hermes,环境自动检测、双路径命令映射、HEARTBEAT.md 与 Cron Job 双触发机制 |
| v1.4 | 2026-05-20 | 首次运行协议:安装后首次加载自动执行 Smoke Test 自检,给用户即时反馈 |