Local Self-Healing Machine Learning
"Your agent learns from its own mistakes — without ever calling home, revealing your machine ID, or exposing any security holes."
A fully local machine learning engine that makes your OpenClaw agent smart over time. It watches your agent's runtime history, detects recurring failures, clusters similar errors using semantic embeddings, and autonomously evolves fix strategies — all running 100% on your machine with zero network calls.
The engine uses a feedback loop that tracks whether each fix actually works: after 3 clean cycles a fix is marked "proven", and if the error comes back within 5 cycles it's marked "failed". A k-NN predictor learns from these outcomes and gets better at picking the right fix over time. Lessons compound in a persistent knowledge base that never decays — the longer it runs, the smarter it gets.
Every evolution is auditable through the GEP (Genetic Evolution Protocol), which produces structured, content-hashed assets: genes (reusable fix strategies), capsules (successful evolution records), and an append-only event log. You can inspect exactly what changed, why it changed, and whether it worked.
No telemetry. No fingerprinting. No cloud dependencies. No data leaves your device.
ML Capabilities
- - Feedback Loop: Tracks whether fixes actually work. After 3 clean cycles, a fix is "proven". If the error recurs within 5 cycles, the fix is marked "failed".
- Embedding-Based Error Clustering: Uses Ollama + llama3.2:3b to generate semantic embeddings for error messages. Similar errors are clustered together instead of matched by regex.
- Success Predictor: k-NN classifier trained on feedback data. Predicts which gene will fix a given error cluster. Gets better over time.
- Persistent Knowledge Base: Lessons compound forever. No decay. Confidence scores adjust with each outcome.
Dashboard
View your ML engine's status, training progress, and knowledge base in a local web dashboard:
CODEBLOCK0
Opens at http://localhost:8420. Shows feedback loop stats, predictor training progress, error clusters, knowledge base health, and recent evolution events. No external dependencies — runs entirely in your browser.
Optional: Ollama Integration
For semantic error matching (recommended but not required):
CODEBLOCK1
Without Ollama, the engine falls back to regex-based heuristics. Everything still works — you just get smarter matching with it.
Usage
Standard Run (Automated)
CODEBLOCK2
Review Mode (Human-in-the-Loop)
CODEBLOCK3
Continuous Loop
CODEBLOCK4
Configuration
| Environment Variable | Default | Description |
|---|
| INLINECODE1 | INLINECODE2 | Allow evolution to modify its own source code. Not recommended. |
| INLINECODE3 |
2.0 | Maximum 1-minute load average before backing off. |
|
EVOLVE_STRATEGY |
balanced | Strategy:
balanced,
innovate,
harden,
repair-only,
early-stabilize,
steady-state, or
auto. |
|
OLLAMA_URL |
http://localhost:11434 | Ollama API endpoint for embeddings. |
|
OLLAMA_EMBED_MODEL |
llama3.2:3b | Model to use for embeddings. |
|
LSHML_DASHBOARD_PORT |
8420 | Port for the standalone dashboard server. |
How It Works
- 1. Signal Extraction: Scans logs for errors, feature requests, performance issues (19 signal types, 4 languages)
- ML Clustering: Groups similar errors using embedding vectors (or regex fallback)
- Gene Selection: Picks the best fix strategy using knowledge base + k-NN predictor
- Evolution: Applies the fix with blast radius protection, validation, and rollback
- Feedback: Monitors subsequent cycles to verify the fix holds
- Learning: Records outcomes to knowledge base — proven fixes get higher confidence
Data Files
All data stays local in memory/:
| File | Purpose |
|---|
| INLINECODE21 | Fix outcome tracking (append-only) |
| INLINECODE22 |
Cached embedding vectors |
|
knowledge.json | Persistent lessons (no decay) |
|
predictor.json | Trained model weights |
|
cluster-registry.json | Semantic error cluster map |
GEP Protocol (Auditable Evolution)
Every evolution produces structured, auditable assets:
- -
assets/gep/genes.json: Reusable fix strategies - INLINECODE27 : Successful evolution records
- INLINECODE28 : Append-only audit trail
Safety
- - Blast radius limits (max files/lines changed per cycle)
- Critical path protection (cannot modify itself or core configs)
- Validation commands run before committing
- Canary check (index.js must still load)
- Ethics committee (blocks dangerous patterns)
- Full rollback on any failure
Author
Built by Joe Che
License
MIT
本地自愈机器学习
您的智能体从自身错误中学习——无需回传数据、不暴露机器ID、不留下任何安全漏洞。
一个完全本地的机器学习引擎,让您的OpenClaw智能体随时间推移变得更加智能。它会监控智能体的运行时历史记录,检测重复出现的故障,使用语义嵌入对相似错误进行聚类,并自主演化修复策略——所有操作100%在您的机器上运行,无需任何网络调用。
该引擎使用反馈循环来追踪每次修复是否真正有效:经过3次干净周期后,修复被标记为已验证,如果错误在5个周期内再次出现,则标记为失败。k-NN预测器从这些结果中学习,并随时间推移更好地选择正确的修复方案。经验会在持久知识库中不断累积,永不衰减——运行时间越长,智能体越聪明。
每一次演化都可通过GEP(遗传演化协议)进行审计,该协议生成结构化的、内容哈希化的资产:基因(可复用的修复策略)、胶囊(成功的演化记录)以及仅追加的事件日志。您可以精确检查发生了什么变化、为何变化以及是否有效。
无遥测。无指纹识别。无云依赖。无数据离开您的设备。
机器学习能力
- - 反馈循环:追踪修复是否真正有效。经过3次干净周期后,修复被标记为已验证。如果错误在5个周期内再次出现,则修复被标记为失败。
- 基于嵌入的错误聚类:使用Ollama + llama3.2:3b为错误消息生成语义嵌入。相似错误被聚类在一起,而非通过正则表达式匹配。
- 成功预测器:基于反馈数据训练的k-NN分类器。预测哪个基因能修复给定的错误聚类。随时间推移表现更佳。
- 持久知识库:经验永久累积,永不衰减。置信度分数随每次结果调整。
仪表盘
在本地Web仪表盘中查看您的ML引擎状态、训练进度和知识库:
bash
node index.js --dashboard
在 http://localhost:8420 打开。显示反馈循环统计、预测器训练进度、错误聚类、知识库健康状况以及最近的演化事件。无外部依赖——完全在浏览器中运行。
可选:Ollama集成
用于语义错误匹配(推荐但非必需):
bash
安装Ollama
curl -fsSL https://ollama.com/install.sh | sh
拉取嵌入模型
ollama pull llama3.2:3b
没有Ollama时,引擎会回退到基于正则表达式的启发式方法。一切仍可正常工作——只是有了它匹配会更智能。
使用方法
标准运行(自动化)
bash
node index.js
审查模式(人在回路中)
bash
node index.js --review
持续循环
bash
node index.js --loop
配置
| 环境变量 | 默认值 | 描述 |
|---|
| EVOLVEALLOWSELFMODIFY | false | 允许演化修改自身源代码。不推荐。 |
| EVOLVELOAD_MAX |
2.0 | 回退前允许的最大1分钟平均负载。 |
| EVOLVE_STRATEGY | balanced | 策略:balanced、innovate、harden、repair-only、early-stabilize、steady-state或auto。 |
| OLLAMA_URL | http://localhost:11434 | 用于嵌入的Ollama API端点。 |
| OLLAMA
EMBEDMODEL | llama3.2:3b | 用于嵌入的模型。 |
| LSHML
DASHBOARDPORT | 8420 | 独立仪表盘服务器的端口。 |
工作原理
- 1. 信号提取:扫描日志中的错误、功能请求、性能问题(19种信号类型,4种语言)
- 机器学习聚类:使用嵌入向量(或正则表达式回退)对相似错误进行分组
- 基因选择:使用知识库 + k-NN预测器选择最佳修复策略
- 演化:应用修复,附带爆炸半径保护、验证和回滚
- 反馈:监控后续周期以验证修复是否持续有效
- 学习:将结果记录到知识库——已验证的修复获得更高置信度
数据文件
所有数据保留在本地 memory/ 目录中:
| 文件 | 用途 |
|---|
| feedback.jsonl | 修复结果追踪(仅追加) |
| embeddings-cache.json |
缓存的嵌入向量 |
| knowledge.json | 持久经验(永不衰减) |
| predictor.json | 训练好的模型权重 |
| cluster-registry.json | 语义错误聚类映射 |
GEP协议(可审计演化)
每次演化都会生成结构化的、可审计的资产:
- - assets/gep/genes.json:可复用的修复策略
- assets/gep/capsules.json:成功的演化记录
- assets/gep/events.jsonl:仅追加的审计追踪
安全性
- - 爆炸半径限制(每次周期最多更改的文件/行数)
- 关键路径保护(不能修改自身或核心配置)
- 提交前运行验证命令
- 金丝雀检查(index.js必须仍能加载)
- 伦理委员会(阻止危险模式)
- 任何失败时完全回滚
作者
由 Joe Che 构建
许可证
MIT