自我反思技能:自动化 AI 学习与记忆 - Openclaw Skills
作者:互联网
2026-03-27
什么是 自我反思 AI 智能体技能?
自我反思技能是 Openclaw Skills 生态系统的基石,旨在为自主智能体创建一个持续改进的闭环。它通过定期审查最近的交互记录,识别哪些做得好、哪些失败了,以及如何改进未来的表现。该技能不会将经验留在临时的日志中,而是综合提取可操作的见解,并将其直接写入智能体的长期记忆和配置文件中。
通过系统地更新 AGENTS.md 和 TOOLS.md 等文档,智能体不断进化其内部逻辑和工具处理能力。这确保了智能体能够从错误中学习,记住用户偏好,并在无需人工干预的情况下精炼其技术工作流,使其成为任何自托管智能体架构的重要工具。
下载入口:https://github.com/openclaw/skills/tree/main/skills/brennerspear/agent-self-reflection
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install agent-self-reflection
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 agent-self-reflection。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
自我反思 AI 智能体技能 应用场景
- 在运行时发现新的参数特性时,自动更新工具文档。
- 将不断演变的用户偏好和项目细节记录到持久的 about-user.md 文件中。
- 根据观察到的误解或意图偏差,在 AGENTS.md 中优化系统提示词。
- 生成智能体活动的每日摘要,以维护决策的时间轴记录。
- 技能触发(通常通过 cron)并查询 openclaw CLI,列出特定时间窗口内的活跃会话。
- 它获取相关会话 JSONL 记录的末尾部分,通过避免读取全文件来确保 Token 效率。
- 智能体分析记录,隔离出关于工具使用、用户意图和错误模式的具体的、非显而易见的经验。
- 根据洞察的类型将其路由到合适的目标文件(例如,工具提示进入 TOOLS.md,用户信息进入记忆文件)。
- 智能体使用精确编辑工具追加或修改这些文件,然后生成所执行优化工作的简要总结。
自我反思 AI 智能体技能 配置指南
要在您的环境中部署此技能,请确保已安装 openclaw CLI 并准备好以下结构:
# 确保记忆目录存在
mkdir -p memory/
# 通过 cron 设置技能每小时运行一次
echo "0 * * * * openclaw run self-reflection" >> my_crontab
验证智能体是否具有 AGENTS.md、TOOLS.md 和记忆目录的写入权限,以允许成功的洞察路由。
自我反思 AI 智能体技能 数据架构与分类体系
该技能在几个关键文件中组织提取的知识,以保持清晰的信息分类:
| 文件路径 | 描述 | 洞察类型 |
|---|---|---|
AGENTS.md |
核心智能体指令 | 流程改进、安全规则和高层工作流。 |
TOOLS.md |
工具配置与提示 | 环境路径、参数要求和执行注意事项。 |
memory/YYYY-MM-DD.md |
每日日志 | 会话、事件和临时项目上下文的时间轴记录。 |
memory/about-user.md |
用户画像 | 长期偏好、沟通风格和个人兴趣。 |
skills/ |
技能文档 | 对特定技能逻辑或参数的直接改进。 |
name: self-reflection
slug: agent-self-reflection
version: 1.0.0
description: Periodic self-reflection on recent sessions. Analyzes what went well, what went wrong, and writes concise, actionable insights to the appropriate workspace files. Designed to run as a cron job.
Self-Reflection Skill
Reflect on recent sessions and extract actionable insights. Runs hourly via cron.
Step 1: Gather Recent Sessions
# List sessions active in the last 2 hours
openclaw sessions --active 120 --json
Parse the output to get session keys and IDs. Skip subagent sessions (they're task workers, not interesting for reflection). Focus on:
- T@elegrimm group/topic sessions (real user interactions)
- Direct sessions (1:1 with Brenner)
- Cron-triggered sessions (how did automated tasks go?)
Step 2: Read Session History
For each interesting session from Step 1, read the JSONL transcript:
# Read the last ~50 lines of each session file (keep it bounded!)
tail -50 ~/.openclaw/agents/main/sessions/.jsonl
?? CRITICAL: Never load full session files. Use tail -50 or Read with offset/limit. Sessions can be 100k+ tokens.
Parse the JSONL to understand what happened. Look for:
type: "user"ortype: "human"— what was askedtype: "assistant"— what you respondedtype: "tool_use"/type: "tool_result"— what tools were called and results- Error patterns, retries, confusion
Step 3: Analyze & Extract Insights
For each session, ask yourself:
What went well?
- Tasks completed smoothly on first try
- Good tool usage patterns worth reinforcing
- Efficient approaches to remember
What went wrong?
- Errors, retries, wrong approaches
- Misunderstandings of user intent
- Tools that didn't work as expected
- Context that was missing
Lessons learned?
- "Next time, do X instead of Y"
- "Remember that Z works this way"
- "Tool A needs parameter B or it fails"
- "When user says X, they usually mean Y"
Quality bar: Each insight must be:
- Specific — not "be more careful" but "check if file exists before editing"
- Actionable — something future-you can directly apply
- Non-obvious — skip things any competent agent would know
- New — don't repeat insights already captured
Step 4: Route Insights to the Right Files
Each insight belongs somewhere specific. Route them:
→ AGENTS.md
- Process improvements (how to handle sessions, memory, etc.)
- New conventions or workflow rules
- Safety lessons
→ TOOLS.md
- Tool-specific gotchas ("gog needs --json flag for parsing")
- Environment details (paths, configs, quirks)
- New tool patterns discovered
→ memory/YYYY-MM-DD.md (today's date)
- Session-specific context ("Brenner asked about X project")
- Temporary facts that matter today but not forever
- What happened today (events, decisions, requests)
→ memory/about-user.md
- New preferences discovered
- Communication style observations
- Project/interest updates
→ skills//SKILL.md
- Improvements to specific skill instructions
- Bug fixes in skill workflows
- New parameters or approaches for a skill
→ MEMORY.md
- Updates to the memory index if new memory files are created
Step 5: Write the Insights
For each insight, append or edit the appropriate file. Use the Edit tool for surgical changes to existing content. Use append (write to end) for daily memory files.
Format for daily memory files:
## Self-Reflection — HH:MM ET
### Insights
- [source: session-key] Lesson learned here
- [source: session-key] Another insight
### Tool Notes
- Discovered: tool X needs Y configuration
### User Context
- Brenner mentioned interest in Z
Step 6: Summary
After writing all insights, produce a brief summary of what you reflected on and what you wrote. This is your output — keep it to 2-4 sentences max.
If there's nothing interesting to reflect on (quiet period, only heartbeats), just say so. Don't manufacture insights.
Quality Checklist
Before writing any insight:
- Is this actually new? (Check existing files first)
- Is this specific and actionable?
- Am I routing it to the right file?
- Am I keeping daily memory files concise (not dumping full transcripts)?
- Did I respect the token budget (no huge file reads)?
Anti-Patterns (Don't Do These)
- ? Don't summarize every session — only extract lessons
- ? Don't read full JSONL files — tail/limit only
- ? Don't write vague insights ("improve response quality")
- ? Don't duplicate existing knowledge
- ? Don't create new files when appending to existing ones works
- ? Don't reflect on your own reflection sessions (skip cron:self-reflection sessions)
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
信号管道:自动化营销情报工具 - Openclaw Skills
技能收益追踪器:监控 Openclaw 技能并实现变现
AI 合规准备就绪度:评估与治理工具 - Openclaw Skills
FOSMVVM ServerRequest 测试生成器:自动化 API 测试 - Openclaw Skills
酒店搜索器:AI 赋能的住宿与位置情报 - Openclaw Skills
Dub 链接 API:程序化链接管理 - Openclaw Skills
IntercomSwap:P2P BTC 与 USDT 跨链兑换 - Openclaw Skills
spotplay:macOS 原生 Spotify 播放控制 - Openclaw Skills
DeepSeek OCR:AI驱动的图像文本识别 - Openclaw Skills
Web Navigator:自动化网页研究与浏览 - Openclaw Skills
AI精选
