关于 self-reflection
self-reflection 是帮助 Agent 持续记录错误、经验和改进事项的技能。它通过心跳触发检查,并提供记录、回顾和统计反思的命令,同时说明了 OpenClaw 配置方式。
主要功能
- 01检查是否需要反思
- 02记录经验与改进事项
- 03读取近期反思
- 04查看反思统计
- 05配置 OpenClaw 心跳集成
适用场景
- 01在定时 Agent 心跳中回顾经验
- 02在 Agent 出错后记录修正方法
- 03查看近期反思和活动
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ sundial-org/ awesome-openclaw-skills --skill self-reflection安装后在 Claude Code 中输入/self-reflection确认已加载。
附带文件README.mdself-reflection.example.json
详细介绍
🪞 自我反思
一项用于持续自我改进的技能。Agent 会通过定期触发的心跳反思,持续记录错误、经验教训和改进。
快速开始
# Check if reflection is needed
self-reflection check
# Log a new reflection
self-reflection log "error-handling" "Forgot timeout on API call" "Always add timeout=30"
# Read recent lessons
self-reflection read
# View statistics
self-reflection stats
工作原理
Heartbeat (60m) → Agent reads HEARTBEAT.md → Runs self-reflection check
│
┌─────────┴─────────┐
▼ ▼
OK ALERT
│ │
Continue Reflect
│
┌─────────┴─────────┐
▼ ▼
read log
(past lessons) (new insights)
命令
| 命令 | 描述 |
|---|---|
check [--quiet] | 检查是否需要反思(OK 或 ALERT) |
log <tag> <miss> <fix> | 记录一条新的反思 |
read [n] | 阅读最近的 n 条反思(默认为 5) |
stats | 显示反思统计信息 |
reset | 重置计时器 |
OpenClaw 集成
在 ~/.openclaw/openclaw.json 中启用心跳:
{
"agents": {
"defaults": {
"heartbeat": {
"every": "60m",
"activeHours": { "start": "08:00", "end": "22:00" }
}
}
}
}
在工作区的 HEARTBEAT.md 中添加:
## Self-Reflection Check (required)
Run `self-reflection check` at each heartbeat.
If ALERT: read past lessons, reflect, then log insights.
配置
创建 ~/.openclaw/self-reflection.json:
{
"threshold_minutes": 60,
"memory_file": "~/workspace/memory/self-review.md",
"state_file": "~/.openclaw/self-review-state.json",
"max_entries_context": 5
}
作者
由 hopyky 创建
许可证
MIT
评论
支持 Markdown