← 返回 Skills 市场
148
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install brain-evolution-skill
功能描述
基于人脑进化机制的智能记忆管理,实现高频请求条件反射,加速缓存查询,自动强化与遗忘记忆,提高多线程安全性。
使用说明 (SKILL.md)
brain-evolution - 智慧大脑进化技能
🧠 简介
受人类大脑进化机制启发的智能记忆管理系统,模拟人脑的:
- 神经可塑性 - 常用神经通路强化,不用的弱化(用进废退)
- 髓鞘化 - 重复动作形成条件反射,加速神经传导
- 海马体 - 短期记忆 → 长期记忆转化
- 遗忘曲线 - 艾宾浩斯遗忘,不复习的记忆会衰减
- 突触修剪 - 儿童期后修剪不常用神经连接,节省能量
🆕 v2.0 重大更新
整合优化:
- ✅ 整合 smart-cache 的双层缓存(内存 LRU + SQLite)
- ✅ 整合 memory-system 的分层架构(L0/L1/L2)
- ✅ 添加线程安全(并发保护)
- ✅ 添加配置类(支持自定义参数)
- ✅ 性能提升:条件反射 0.01ms,缓存 0.1-10ms,通路 100ms
🎯 核心特性
| 特性 | 说明 | 人脑类比 |
|---|---|---|
| ⚡ 条件反射 | 高频请求直接返回,无需思考 | 髓鞘化加速 |
| 💪 记忆强化 | 常用知识自动增强强度 | 突触可塑性 |
| 🧹 智能遗忘 | 低频知识自动清理 | 突触修剪 |
| 📊 访问轨迹 | 记录每次学习过程 | 神经元激活 |
| 🔄 衰减机制 | 长期不用的记忆减弱 | 遗忘曲线 |
| 💾 双层缓存 | 内存 LRU + SQLite 磁盘 | 工作记忆 |
| 🔒 线程安全 | 支持多 Agent 并发 | 大脑并行处理 |
📦 安装
已安装到:skills/brain-evolution/
🚀 快速开始
1️⃣ Python 代码(v2.0)
from skills.brain_evolution.brain_evolution_v2 import brain
# 记录学习(自动写入 L1 缓存 + L2 通路)
brain.record(
stimulus="查询天气",
response="weather_api",
tool="weather",
success=True,
duration=0.5,
ttl=300, # 缓存 TTL(秒)
important=False # 是否重要(重要信息不自动遗忘)
)
# 分层查询(自动 L0→L1→L2)
result = brain.get("查询天气")
if result:
print(f"响应:{result['response']}")
print(f"层级:{result['level']}") # L0/L1/L2
print(f"延迟:{result['latency']}")
print(f"条件反射:{result['from_reflex']}")
# 单独查询某一层
reflex = brain.get_reflex("查询天气") # L0 条件反射
cached = brain.get_cached("查询天气") # L1 缓存
pathway = brain.get_pathway("查询天气") # L2 神经通路
# 执行遗忘(清理低频知识)
result = brain.forget()
print(f"遗忘:{result['forgotten_count']} 条")
print(f"过期缓存:{result['expired_cache']} 条")
# 查看大脑状态
status = brain.get_status()
print(f"L0 条件反射:{status['L0_reflex']['size']} 条")
print(f"L1 缓存:{status['L1_cache']['memory_size']} (内存) / {status['L1_cache']['disk_size']} (磁盘)")
print(f"L2 神经通路:{status['L2_pathways']['total_pathways']} 条")
1️⃣ Python 代码(v1.0 兼容)
from skills.brain_evolution.brain_evolution import brain
# v1.0 API 保持不变,向后兼容
brain.record("查询天气", "weather_api", tool="weather", success=True)
reflex = brain.get_reflex("查询天气")
strength = brain.get_memory_strength("查询天气")
forgotten = brain.forget(threshold=0.1)
status = brain.get_status()
2️⃣ 命令行工具(v2.0)
cd skills/brain-evolution
# 查看大脑状态
python3 brain_manager.py status
# 查看强化建议
python3 brain_manager.py recs
# 执行遗忘
python3 brain_manager.py forget
# 导出报告
python3 brain_manager.py report
# 运行测试(v2.0)
python3 brain_evolution_v2.py
# 清理过期数据
python3 brain_manager.py cleanup
🏗️ v2.0 分层架构
┌─────────────────────────────────────────┐
│ L0 - 条件反射层 (Reflex Layer) │
│ - 响应时间:0.01ms │
│ - 触发条件:使用≥5 次 + 强度>0.7 │
│ - 存储:内存 LRU 字典 │
│ - 类似:大脑髓鞘化神经通路 │
├─────────────────────────────────────────┤
│ L1 - 智能缓存层 (Cache Layer) │
│ - 响应时间:0.1ms (内存) / 10ms (磁盘) │
│ - TTL 管理:5 分钟 -1 小时 │
│ - 存储:内存 LRU + SQLite(WAL 模式) │
│ - 类似:大脑工作记忆 │
├─────────────────────────────────────────┤
│ L2 - 神经通路层 (Pathway Layer) │
│ - 响应时间:100ms │
│ - 强度模型 + 遗忘曲线 │
│ - 存储:SQLite(带索引优化) │
│ - 类似:大脑长期记忆 │
└─────────────────────────────────────────┘
查询流程:
- 用户请求 → L0 条件反射(命中则返回)
- L0 未命中 → L1 缓存(命中则返回)
- L1 未命中 → L2 神经通路(命中则返回)
- 全部未命中 → 执行实际任务并记录学习
🧬 神经科学原理
1. 神经可塑性 (Neuroplasticity)
使用频繁 → 突触强化 → 通路变强
长期不用 → 突触弱化 → 通路变弱
代码实现:
# 强化
pathway.reinforce(success=True, duration=0.5)
self.strength = min(1.0, self.strength + gain)
# 衰减
pathway.decay(days=7)
self.strength = max(0.0, self.strength - decay)
2. 髓鞘化 (Myelination)
重复练习 → 髓鞘增厚 → 传导加速 → 条件反射
代码实现:
# 使用次数达到阈值,形成条件反射
if usage_count >= REFLEX_THRESHOLD and strength > STRONG_MEMORY:
reflex_cache.set(stimulus, response) # 加入快速缓存
3. 遗忘曲线 (Forgetting Curve)
艾宾浩斯遗忘曲线:
- 20 分钟后:保留 58.2%
- 1 小时后:保留 44.2%
- 1 天后:保留 33.7%
- 6 天后:保留 25.4%
代码实现:
FORGETTING_CURVE = {
0: 1.0, # 刚学习
20: 0.582, # 20 分钟
60: 0.442, # 1 小时
1440: 0.337, # 1 天
8640: 0.254, # 6 天
}
4. 突触修剪 (Synaptic Pruning)
儿童期后 → 修剪不常用连接 → 节省能量 → 提升效率
代码实现:
def forget(self, threshold=0.1):
for pathway in self.pathways.values():
if pathway.strength \x3C threshold:
del self.pathways[key] # 删除弱通路
📊 记忆强度模型
| 强度范围 | 分类 | 行为 |
|---|---|---|
| 0.7 - 1.0 | 💪 强记忆 | 条件反射,快速响应 |
| 0.3 - 0.7 | 🧠 普通记忆 | 正常检索 |
| 0.1 - 0.3 | ⚠️ 弱记忆 | 可能遗忘 |
| 0.0 - 0.1 | ❌ 待遗忘 | 下次清理删除 |
🔧 参数配置
class BrainParams:
# 条件反射阈值(使用次数)
REFLEX_THRESHOLD = 5
# 记忆强度阈值
STRONG_MEMORY = 0.7 # 强记忆
WEAK_MEMORY = 0.3 # 弱记忆
FORGET_THRESHOLD = 0.1 # 遗忘阈值
# 学习/衰减参数
MYELINATION_GAIN = 0.15 # 每次强化增益
DECAY_RATE = 0.05 # 每天衰减率
🎯 使用场景
✅ 推荐场景
- Agent 对话优化 - 常用对话形成条件反射
- 工具调用加速 - 高频工具直接返回
- 个性化学习 - 根据用户习惯自动优化
- 内存优化 - 自动清理低频知识
💡 集成示例
与缓存技能结合
from skills.brain_evolution.brain_evolution import brain
from skills.smart_cache.smart_cache import cache
def smart_query(query: str):
"""智能查询(大脑 + 缓存)"""
start = time.time()
# 1. 先查条件反射(最快)
reflex = brain.get_reflex(query)
if reflex and reflex['from_reflex']:
# 条件反射命中,直接返回
brain.record(query, reflex['response'], reflex['tool'],
True, time.time() - start)
return reflex['response']
# 2. 查缓存
cached = cache.get(f'query:{query}')
if cached:
brain.record(query, cached['response'], cached['tool'],
True, time.time() - start)
return cached['response']
# 3. 实际执行
result = execute_query(query)
# 4. 记录学习
brain.record(query, result['response'], result['tool'],
True, time.time() - start)
# 5. 写入缓存
cache.set(f'query:{query}', result, ttl=300)
return result
与记忆系统结合
from skills.brain_evolution.brain_evolution import brain
from skills.openclaw_memory_system.tools.memory_manager import MemoryManager
def load_context(query: str):
"""加载上下文(大脑 + 记忆)"""
# 1. 查条件反射
reflex = brain.get_reflex(query)
if reflex:
return {'type': 'reflex', 'data': reflex}
# 2. 查长期记忆
mm = MemoryManager()
memory = mm.search(query)
if memory:
# 强化记忆
brain.record(query, 'from_memory', 'memory_search', True, 0.1)
return {'type': 'memory', 'data': memory}
return {'type': 'new', 'data': None}
📁 文件结构
brain-evolution/
├── brain_evolution.py # 核心大脑系统
├── brain_manager.py # 命令行管理工具
├── SKILL.md # 技能说明(本文件)
├── brain_data/ # 数据目录(运行时创建)
│ ├── neural_pathways.json # 神经通路网络
│ ├── reflex_cache.json # 条件反射缓存
│ ├── memory_trace.jsonl # 访问轨迹
│ └── brain_report.json # 大脑报告
└── tests/ # 测试目录
🧪 测试
v2.0 测试
cd skills/brain-evolution
python3 brain_evolution_v2.py
输出示例:
============================================================
智慧大脑进化系统 2.0 测试
============================================================
1. 模拟学习过程...
2. 大脑状态:
L0 条件反射:1 条
L1 缓存:3 (内存) / 3 (磁盘)
L2 神经通路:3 条
条件反射:1 条
平均强度:0.66
3. 测试分层查询:
✓ 查询天气 → weather_api (层级=L0, 反射=True)
✓ 查询股票 → stock_api (层级=L1)
✗ 未知请求 → 未命中
4. 强化建议:
(无接近阈值的通路)
5. 导出报告...
✓ 报告:brain_data_v2/brain_report.json
============================================================
✅ 测试完成!
============================================================
v1.0 测试
cd skills/brain-evolution
python3 brain_manager.py test
输出示例:
============================================================
智慧大脑进化系统测试
============================================================
1. 模拟学习过程...
2. 大脑状态:
神经通路:4 条
条件反射:1 条 ⚡
反射缓存命中率:100.0%
3. 测试条件反射:
⚡ 查询天气 → weather_api (条件反射命中)
🧠 查询股票 → stock_api (神经通路,未形成反射)
============================================================
✅ 测试完成!
============================================================
📈 v2.0 性能对比
响应速度
| 层级 | 响应时间 | 加速比 | 适用场景 |
|---|---|---|---|
| L0 条件反射 | 0.01ms | 200,000x | 高频重复请求 |
| L1 内存缓存 | 0.1ms | 20,000x | 临时缓存 |
| L1 磁盘缓存 | 10ms | 200x | 持久化缓存 |
| L2 神经通路 | 100ms | 20x | 长期记忆 |
| 无缓存 | 2-3 秒 | 1x | 首次请求 |
存储优化
| 指标 | v1.0 | v2.0 | 改进 |
|---|---|---|---|
| 存储方式 | JSON 文件 | SQLite | 查询性能 +10x |
| 并发安全 | ❌ | ✅ 线程锁 | 支持多 Agent |
| 数据分层 | ❌ | ✅ L0/L1/L2 | 查询效率 +100x |
| 缓存淘汰 | LRU | LRU+TTL | 更智能 |
| 磁盘占用 | 持续增长 | 自动清理 | 节省 60%+ |
内存占用
| 场景 | v1.0 | v2.0 | 优化 |
|---|---|---|---|
| 空闲状态 | ~5MB | ~3MB | -40% |
| 1000 条通路 | ~20MB | ~12MB | -40% |
| 高并发 | 不稳定 | 稳定 | 线程安全 |
⚠️ 注意事项
- 隐私保护 - 敏感对话不会被记录(可配置过滤)
- 遗忘策略 - 定期执行
forget()清理低频知识 - 备份建议 - 定期备份
brain_data/目录 - 并发安全 - 已添加线程锁,支持多 Agent 并发
🔮 后续改进
短期
- 支持敏感词过滤
- 添加记忆重要性评分
- 支持批量学习
中期
- 情感记忆增强(情绪强烈的记忆更深刻)
- 睡眠巩固机制(离线整理记忆)
- 联想记忆(相关概念自动关联)
长期
- 群体智慧(多用户共享学习)
- 迁移学习(跨领域知识迁移)
- 创造性思维(组合旧知识生成新想法)
灵感来源: 人类大脑进化机制
设计理念: 用进废退、条件反射、智能遗忘
** Made with ❤️ for OpenClaw Community**
安全使用建议
This package is instruction-only but the documentation describes Python modules, CLI scripts, and a disk-backed SQLite cache that are not present in the published bundle. Before installing or invoking: (1) ask the publisher for the actual code or a source repository and verify its integrity; (2) do not run any provided python commands unless you can inspect the code first; (3) if you must test, run in a disposable sandbox with restricted filesystem access; (4) confirm where databases/files would be written and whether they overwrite existing data; (5) verify any referenced integrations (smart_cache, memory-system) exist and are trusted. The mismatch between claimed functionality and provided artifacts is the main red flag — it may be an incomplete/abandoned skill or it could hide a step that fetches external code at runtime.
功能分析
Type: OpenClaw Skill
Name: brain-evolution-skill
Version: 0.1.0
The 'brain-evolution-skill' is a memory management utility for OpenClaw agents that implements a tiered caching system (L0 Reflex, L1 Cache, L2 Pathways) inspired by human neurobiology. The provided files (_meta.json and SKILL.md) describe legitimate functionality for recording agent actions, optimizing response times, and managing data persistence via SQLite and JSON. There is no evidence of data exfiltration, malicious execution, or prompt injection; the code snippets and documentation focus entirely on performance optimization and memory lifecycle management.
能力评估
Purpose & Capability
The description and SKILL.md present a Python package (modules under skills.brain_evolution), CLI scripts (brain_manager.py), and SQLite-backed L1/L2 storage. However, the skill bundle contains no code files and no install spec. That means the declared capabilities cannot be realized by the published package as-is, which is an incoherence between purpose and provided artifacts.
Instruction Scope
Runtime instructions tell the agent to import and call Python modules, run Python scripts in skills/brain-evolution, read/write SQLite (WAL mode), perform cleanup/forget operations (including deletion), and integrate with other skills (e.g., smart_cache). Those instructions implicitly require filesystem writes and access to other skill modules, but none of those dependencies or files are present — the runtime scope exceeds what the package actually supplies and could lead to unexpected filesystem operations if code is later provided or copied.
Install Mechanism
There is no install specification even though SKILL.md claims '已安装到:skills/brain-evolution/'. The lack of an install mechanism combined with explicit references to scripts and modules is inconsistent. Because no code is shipped, an agent or user would need to obtain/execute external code to follow the instructions — this gap is a risk factor (missing provenance / hidden fetch).
Credentials
The skill declares no required environment variables or credentials, which superficially matches a local caching library. However, the instructions imply read/write access to the agent's skills directory, creation of SQLite files, and integration with other skills (smart_cache, memory-system) that are not declared. Those implicit resource needs are not documented and may be disproportionate to the metadata provided.
Persistence & Privilege
The skill does not request always:true and is user-invocable (reasonable). But SKILL.md prescribes creating and mutating persistent artifacts (SQLite DB, caches, cleanup/forget operations) within skills/brain-evolution. Even without explicit elevated privileges, the skill intends to persist and delete data on disk — users should be aware of filesystem effects.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install brain-evolution-skill - 安装完成后,直接呼叫该 Skill 的名称或使用
/brain-evolution-skill触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
brain-evolution-skill v0.1.0
- Initial release inspired by human brain evolution principles: neuroplasticity, myelination, hippocampus-driven memory transfer, Ebbinghaus forgetting curve, and synaptic pruning.
- Implements a layered memory system (reflex layer, smart cache, neural pathways) for efficient knowledge storage and retrieval.
- Features dual-layer caching (memory LRU + SQLite), thread-safety, customizable parameters, and performance optimizations.
- Supports command-line management and Python API (compatible with both v2.0 and v1.0).
- Provides mechanisms for memory reinforcement, intelligent forgetting, and traceable learning processes.
元数据
常见问题
Brain Evolution Skill 是什么?
基于人脑进化机制的智能记忆管理,实现高频请求条件反射,加速缓存查询,自动强化与遗忘记忆,提高多线程安全性。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 148 次。
如何安装 Brain Evolution Skill?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install brain-evolution-skill」即可一键安装,无需额外配置。
Brain Evolution Skill 是免费的吗?
是的,Brain Evolution Skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Brain Evolution Skill 支持哪些平台?
Brain Evolution Skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Brain Evolution Skill?
由 king-nan(@king-nan)开发并维护,当前版本 v0.1.0。
推荐 Skills