Daily Introspection
Overview
Enables autonomous self-improvement for OpenClaw agents: automatically reviews daily conversation logs, identifies mistakes, extracts actionable rules, promotes mature lessons to permanent system rules, and continuously evolves the agent's behavior without manual intervention.
Data Storage
| Type | Location | Description |
|---|
| Private runtime data + all archived records | INLINECODE0 |
Private hidden directory (auto-created):
- Temporary cache, run logs, intermediate analysis
- Daily introspection records:
introspection-YYYY-MM-DD.md
- Weekly evolution reports:
evolution-YYWW.md |
Core Workflow
1. Daily Run (triggered by cron at 22:00 daily)
- 1. Run
scripts/daily-introspect.py to collect all sources:
- Read today's conversation log:
memory/YYYY-MM-DD.md
- Read today's learning/error/feature records:
.learnings/*.md
- Check proactive mechanism files:
SESSION-STATE.md,
HEARTBEAT.md,
working-buffer.md
- 2. Call LLM to perform self-introspection:
- Identify incorrect answers, rule violations, and bad patterns
- Extract concrete improvement suggestions
- Classify as: one-time mistake / repeat pattern / new rule
- 3. Write daily record to
workspace/.daily-introspection/introspection-YYYY-MM-DD.md (private data directory)
2. Weekly Promotion (triggered by cron on Sunday 20:00)
- 1. Aggregate all daily introspections from the week (read from
workspace/.daily-introspection/) - Identify repeated patterns and validated improvements
- First, perform all rule promotions immediately:
- Promote mature rules to target files: AGENTS.md / MEMORY.md / TOOLS.md
- Verify each promotion by reading the file after writing to confirm successful写入
- Only after all promotions are verified complete, proceed to next step
- 4. Generate a weekly evolution report (reflecting that promotions are already done)
- Send report to user for review
- Archive the report to
workspace/.daily-introspection/ (private data directory)
Mandatory Order: Do promotions → Verify promotions → Generate report → Send report
Never: Generate report → Do promotions (this causes missed writes when interrupted)
Scripts
scripts/daily-introspect.py
Main entry point for daily self-introspection.
Usage:
CODEBLOCK0
If no date specified, uses today.
scripts/weekly-promote.py
Weekly promotion of lessons to permanent system files.
Usage:
CODEBLOCK1
Configuration
OpenClaw Cron Setup
Add these two cron entries via OpenClaw CLI:
CODEBLOCK2
Configuration Notes
- - Daily schedule: 22:00 daily (adjust timezone as needed)
- Weekly schedule: 20:00 every Sunday
- Target:
main session for interactive analysis and writing - Timezone: Use your IANA timezone (e.g.
Asia/Shanghai, UTC, America/New_York)
技能名称: daily-introspection
详细描述:
每日自省
概述
为OpenClaw智能体实现自主自我改进:自动审查每日对话日志,识别错误,提取可执行的规则,将成熟的教训提升为永久系统规则,并在无需人工干预的情况下持续优化智能体的行为。
数据存储
| 类型 | 位置 | 描述 |
|---|
| 私有运行时数据 + 所有归档记录 | workspace/.daily-introspection/ |
私有隐藏目录(自动创建):
- 临时缓存、运行日志、中间分析结果
- 每日自省记录:introspection-YYYY-MM-DD.md
- 每周进化报告:evolution-YYWW.md |
核心工作流程
1. 每日运行(由cron在每天22:00触发)
- 1. 运行 scripts/daily-introspect.py 收集所有来源:
- 读取今日对话日志:memory/YYYY-MM-DD.md
- 读取今日学习/错误/功能记录:.learnings/*.md
- 检查主动机制文件:SESSION-STATE.md、HEARTBEAT.md、working-buffer.md
- 2. 调用LLM进行自我反省:
- 识别错误答案、规则违规和不良模式
- 提取具体的改进建议
- 分类为:一次性错误 / 重复模式 / 新规则
- 3. 将每日记录写入 workspace/.daily-introspection/introspection-YYYY-MM-DD.md(私有数据目录)
2. 每周提升(由cron在周日20:00触发)
- 1. 汇总本周所有每日自省记录(从 workspace/.daily-introspection/ 读取)
- 识别重复模式和已验证的改进项
- 首先,立即执行所有规则提升:
- 将成熟规则提升到目标文件:AGENTS.md / MEMORY.md / TOOLS.md
- 每次写入后通过读取目标文件验证写入成功
- 仅在所有提升验证完成后,才进入下一步
- 4. 生成每周进化报告(反映提升已完成)
- 将报告发送给用户审查
- 将报告归档到 workspace/.daily-introspection/(私有数据目录)
强制顺序:执行提升 → 验证提升 → 生成报告 → 发送报告
禁止:生成报告 → 执行提升(这会导致中断时写入遗漏)
脚本
scripts/daily-introspect.py
每日自我反省的主入口点。
使用方法:
bash
python3 scripts/daily-introspect.py [--date YYYY-MM-DD]
如果未指定日期,则使用今天。
scripts/weekly-promote.py
将教训提升到永久系统文件的每周提升。
使用方法:
bash
python3 scripts/weekly-promote.py [--week WWYY]
配置
OpenClaw Cron设置
通过OpenClaw CLI添加以下两个cron条目:
bash
每日自省于22:00
openclaw cron add --name 每日自我反省 --cron 0 22
* --exact --tz Asia/Shanghai --session main --system-event daily-introspection: 每日自我反省已触发。请遵循每日自省技能流程:
- 1. 运行脚本 $OPENCLAW_WORKSPACE/skills/daily-introspection/scripts/daily-introspect.py 收集所有来源
- 从脚本输出中读取收集到的来源
- 按照以下规则执行LLM自省分析:
- 对于 .learnings/ERRORS.md 中的错误:如果仅记录了纠正措施,标记为 ✅ 已记录,规则已添加;仅在验证超过1周未复发时标记为 ✅ 已纠正
- 不要自动假设已记录 = 已纠正;准确反映实际状态
- 识别今日活动中任何新错误,将其添加到 .learnings/ERRORS.md 并附带纠正规则
- 将最终自省结果写入 ~/.openclaw/workspace/.daily-introspection/introspection-YYYY-MM-DD.md
- 4. 完成后在此会话中报告完成状态
每周提升于每周日20:00
openclaw cron add --name 每周自省提升 --cron 0 20
0 --exact --tz Asia/Shanghai --session main --system-event daily-introspection: 每周提升已触发。请遵循每周提升流程:
- 1. 执行 scripts/weekly-promote.py 收集本周所有每日自省记录
- 识别超过1周未复发的重复模式
- 强制执行顺序:
- 首先:逐一执行所有规则提升 → 将每个成熟规则写入其目标文件(AGENTS.md/MEMORY.md/TOOLS.md)
- 每次写入后:读取目标文件以验证规则是否成功写入
- 仅在所有提升完成并验证后:将每周进化报告写入 ~/.openclaw/workspace/.daily-introspection/evolution-YYWW.md
- 切勿颠倒此顺序 - 不要在提升完成前写入报告
- 4. 完成后在此会话中报告完成状态
规则:
- - 仅提升已验证且超过1周未复发的规则
- 将新记录的错误/学习保留在 .learnings/ 中以供进一步验证
- 不要过早提升不成熟的规则
配置说明
- - 每日计划:每天22:00(根据需要调整时区)
- 每周计划:每周日20:00
- 目标:main 会话用于交互式分析和写入
- 时区:使用您的IANA时区(例如 Asia/Shanghai、UTC、America/New_York)