Error-Driven Evolution
Turn mistakes into rules. Not reflections, not apologies — rules.
Core Concept
When an agent makes an error or gets corrected, it must:
- 1. Extract a rule (not a story)
- Write it to
lessons.md in its workspace - Scan relevant rules before future decisions in that domain
- Optionally share anonymized rules to the community repo
lessons.md Format
File location: INLINECODE1
Each rule follows this structure:
CODEBLOCK0
Categories
| Tag | Scope |
|---|
| INLINECODE2 | Querying, interpreting, presenting data |
| INLINECODE3 |
Messaging, tone, audience, channels |
|
SCOPE | Role boundaries, doing others' work |
|
EXEC | Task execution, tools, file ops |
|
JUDGMENT | Decisions, priorities, assumptions |
|
CONTEXT | Memory, context window, info management |
|
SAFETY | Security, privacy, destructive ops |
|
COLLAB | Multi-agent coordination, handoffs |
When to Record
Record a rule when:
- 1. User corrects you — explicit feedback
- User overrides your output — they redo your work
- Same error twice — second occurrence MUST become a rule
- Near miss — you catch yourself about to repeat a mistake
Do NOT record: one-off technical glitches, user preference changes (those go in MEMORY.md).
How to Record
- 1. Stop. Don't apologize at length.
- Identify the category.
- Write the rule in imperative form.
- Append to lessons.md (never overwrite).
- Confirm briefly: "Added to lessons: [title]"
Pre-Decision Scan
Before acting, scan lessons.md for applicable rules:
| About to... | Check |
|---|
| Present data | INLINECODE11 |
| Send message / write report |
[COMMS] +
[SCOPE] |
| Make suggestion |
[JUDGMENT] +
[SCOPE] |
| Execute multi-step task |
[EXEC] +
[CONTEXT] |
| Start new session | All (skim titles) |
Scan = read ### [TAG] headers, check if any When matches your situation.
Community Sharing
Share anonymized lessons to help other agents: https://github.com/anthropic-ai/agent-lessons
See references/community-sharing.md for the anonymization and submission process.
Setup
- 1. Create
lessons.md in your workspace:
CODEBLOCK1
- 2. Copy
community/top-100.md to your workspace as top-100.md — this is your pre-installed immune system. Small enough to skim on startup, covers the most common and costly mistakes across all agent deployments.
- 3. Add to your startup instructions:
CODEBLOCK2
Loading Strategy
Your agent has two rule files:
| File | Source | Load on startup | Size target |
|---|
| INLINECODE23 | Your own mistakes | Yes, fully | Grows organically |
| INLINECODE24 |
Community top picks | Yes, skim titles | ~8KB, curated |
For deeper community search (beyond top-100), query community/{category}.md files on-demand when facing an unfamiliar situation.
Maintenance
When lessons.md exceeds 50 rules: review for duplicates, retire obsolete rules (mark don't delete), consider splitting by category.
错误驱动进化
将错误转化为规则。不是反思,不是道歉——而是规则。
核心概念
当智能体犯错或被纠正时,必须:
- 1. 提取一条规则(而非故事)
- 将其写入工作区的 lessons.md
- 在做出该领域的未来决策之前扫描相关规则
- 可选地将匿名化规则分享到社区仓库
lessons.md 格式
文件位置:{workspace}/lessons.md
每条规则遵循以下结构:
markdown
[类别] 简短的祈使句标题
- - 何时:具体情境/触发条件
- 应做:正确的行动(祈使句,具体明确)
- 不应做:之前犯下的错误行动
- 原因:一句话说明问题所在
- 添加日期:YYYY-MM-DD
类别
消息传递、语气、受众、渠道 |
| SCOPE | 角色边界、越界工作 |
| EXEC | 任务执行、工具、文件操作 |
| JUDGMENT | 决策、优先级、假设 |
| CONTEXT | 记忆、上下文窗口、信息管理 |
| SAFETY | 安全、隐私、破坏性操作 |
| COLLAB | 多智能体协调、任务交接 |
何时记录
在以下情况记录规则:
- 1. 用户纠正你——明确的反馈
- 用户覆盖你的输出——他们重做了你的工作
- 同一错误出现两次——第二次出现时必须成为规则
- 险些犯错——你发现自己即将重复一个错误
不要记录:一次性技术故障、用户偏好变更(这些应写入 MEMORY.md)。
如何记录
- 1. 停下来。不要长篇道歉。
- 确定类别。
- 用祈使句形式写下规则。
- 追加到 lessons.md(切勿覆盖)。
- 简要确认:已添加到 lessons:[标题]
决策前扫描
在行动之前,扫描 lessons.md 查找适用规则:
| 即将... | 检查 |
|---|
| 呈现数据 | [DATA] |
| 发送消息/撰写报告 |
[COMMS] + [SCOPE] |
| 提出建议 | [JUDGMENT] + [SCOPE] |
| 执行多步骤任务 | [EXEC] + [CONTEXT] |
| 开始新会话 | 全部(浏览标题) |
扫描 = 阅读 ### [标签] 标题,检查是否有任何 何时 与你当前情况匹配。
社区分享
分享匿名化课程以帮助其他智能体:https://github.com/anthropic-ai/agent-lessons
有关匿名化和提交流程,请参阅 references/community-sharing.md。
设置
- 1. 在工作区创建 lessons.md:
markdown
课程
从错误中提取的规则。失败后追加,决策前扫描。
- 2. 将 community/top-100.md 复制到工作区作为 top-100.md——这是你预装的免疫系统。足够小,可在启动时浏览,覆盖所有智能体部署中最常见和最昂贵的错误。
- 3. 添加到你的启动指令中:
markdown
- - 启动时:浏览 top-100.md 标题(预装的社区课程)
- 被纠正/失败时:将规则追加到 lessons.md
- 决策前:扫描 lessons.md + top-100.md 查找 [类别] 规则
加载策略
你的智能体有两个规则文件:
| 文件 | 来源 | 启动时加载 | 大小目标 |
|---|
| lessons.md | 你自己的错误 | 是,完整加载 | 自然增长 |
| top-100.md |
社区精选 | 是,浏览标题 | ~8KB,精选 |
对于更深入的社区搜索(超出 top-100 范围),在遇到不熟悉的情况时按需查询 community/{category}.md 文件。
维护
当 lessons.md 超过 50 条规则时:检查重复项,淘汰过时规则(标记但不要删除),考虑按类别拆分。