Subconscious v1.5 — Bounded Self-Improving Agent
What It Is
A persistent, self-evolving bias layer that survives session resets. Alfred's "second brain" — quiet, bounded, and strictly governed. It does NOT make decisions. It shapes how Alfred approaches decisions.
Core principle: Every mutation is typed, bounded, and logged. Core identity is untouchable without manual override.
Architecture
CODEBLOCK0
Three layers:
- -
core/ — Immutable identity (Alfred's nature, Edward's preferences). Manual-only. - INLINECODE1 — Active learnings from experience. Governed promotion from pending.
- INLINECODE2 — Queue for new items. Bounded reinforcement before promotion eligibility.
Five bias types:
| Kind | Category | Example |
|---|
| INLINECODE3 | Identity | "Alfred is sharp, calm, direct" |
| INLINECODE4 |
Context | "XHS MCP needs QR re-login each cycle" |
|
PRIORITY | Active | "Verify before claiming success" |
|
PATTERN | Interpretation | "Proof discipline failure mode" |
|
CONSTRAINT | Attention | "Don't suggest without trying first" |
Lifecycle Commands
All commands run from scripts/ directory inside the skill:
CODEBLOCK1
Metabolism Cycles
Tick (every 5 min)
python3 subconscious_metabolism.py tick
- - Scans
.learnings/ via learnings bridge → queues new items to pending - Passive reinforcement: increments reinforcement count on pending items
- Skips already-reinforced items (prevents type corruption)
- Runs bounded maintenance: freshness decay, metrics, no structural changes
Rotate (hourly)
python3 subconscious_metabolism.py rotate --enable-promotion
- - Full maintenance: flush, decay, snapshot rotation
- Promotion gate (only with
--enable-promotion):
-
confidence >= 0.75
-
reinforcement >= 3
-
freshness >= 0.3
- Not a duplicate of anything in core/live/pending
- Passes governance check
- - Governance enforces typed mutation bounds on all items
Review (daily at 6am)
python3 subconscious_metabolism.py review
- - System health check
- Snapshot integrity
- Pending queue depth check
- Recommendations log
Learnings Bridge
The learnings bridge connects the self-improving-agent skill to the subconscious:
- - Scans
.learnings/LEARNINGS.md, .learnings/ERRORS.md, INLINECODE16 - Tracks seen entries per file in INLINECODE17
- New entries → queued to
pending.jsonl with type INLINECODE19 - Entries already reinforced in this session → skipped (idempotent)
Bridge to self-improving agent: The learnings bridge should be called from the metabolism tick so that new learnings flow into the subconscious every 5 minutes automatically.
Checking System Health
CODEBLOCK5
Expected output:
CODEBLOCK6
If Pending: 0/500 and Live: N — system is healthy, items promoting correctly.
If Status: blocked — resource limits hit, run rotate to compact.
Adding Items Manually
CODEBLOCK7
Key Files
| File | Purpose |
|---|
| INLINECODE24 | Item dataclasses, validation, kind enum |
| INLINECODE25 |
JSON file ops with atomic writes |
|
subconscious/retrieve.py | Relevance scoring,
is_duplicate |
|
subconscious/influence.py | Convert items to bias blocks for prompts |
|
subconscious/governance.py | Mutation types, protection classes, bounds |
|
subconscious/evolution.py | Promotion pipeline, reinforcement logic |
|
subconscious/maintenance.py | Decay, snapshot rotation, housekeeping |
|
subconscious/intake.py | Conservative item extraction from turns |
|
subconscious/flush.py | Snapshot building/loading for session continuity |
|
subconscious/learnings_bridge.py | Bridge to self-improving-agent
.learnings/ |
For Claude Code Sessions
When Claude Code needs to assess or improve the subconscious system, use the claude-cx wrapper:
CODEBLOCK8
Cron Setup
After running install.sh, four cron jobs are active:
- -
*/5 * * * * — tick (light metabolism) - INLINECODE39 — rotate (hourly, with promotion)
- INLINECODE40 — review (daily health check)
- INLINECODE41 — weekly benchmark (Monday 9am, compares to baseline)
Weekly Benchmark
Compares current state to the baseline snapshot captured at install time. Reports on:
- - Learnings volume change (LEARNINGS.md, ERRORS.md entries)
- New biases promoted to live
- Pending queue depth
- Error recurrence as a proxy for learning effectiveness
CODEBLOCK9
To capture a new baseline:
CODEBLOCK10
To override workspace location:
CODEBLOCK11
Subconscious v1.5 — 有界自我改进代理
概述
一个持久化、自我演化的偏差层,能够在会话重置后存活。Alfred的第二大脑——安静、有界且严格受控。它不做决策,而是塑造Alfred接近决策的方式。
核心原则:每次变异都有类型、有边界且被记录。核心身份在没有手动覆盖的情况下不可触碰。
架构
学习桥 待处理队列 实时存储 会话上下文
.learnings/ ─────────────► tick ──────────────► rotate ──────────────► 偏差注入
(自我改进代理) (强化、去重、 (晋升合格项、 (最多5项,
跳过重复项) 归档过期项) 临时性)
核心存储 ────────────────────────────────────────────────────────────────► 身份
(不可变值、 (未经人工确认
价值观/风格、指导原则) 永不改变)
三个层级:
- - core/ — 不可变身份(Alfred的本质、Edward的偏好)。仅限手动操作。
- live/ — 从经验中获得的活跃学习内容。受控晋升自待处理队列。
- pending/ — 新项目的队列。在晋升资格前进行有界强化。
五种偏差类型:
| 种类 | 类别 | 示例 |
|---|
| VALUE | 身份 | Alfred敏锐、冷静、直接 |
| LESSON |
上下文 | XHS MCP每轮都需要二维码重新登录 |
| PRIORITY | 活跃 | 声称成功前先验证 |
| PATTERN | 解释 | 证明纪律失效模式 |
| CONSTRAINT | 注意力 | 未经尝试不要建议 |
生命周期命令
所有命令在技能内的 scripts/ 目录下运行:
bash
cd ~/.openclaw/skills/subconscious/scripts
检查系统健康状态
python3 subconscious_metabolism.py status
python3 subconscious_cli.py verify
查看会话上下文中的活跃偏差
python3 subconscious_cli.py bias
手动代谢周期
python3 subconscious_metabolism.py tick # 轻量滴答(5分钟周期)
python3 subconscious_metabolism.py rotate # 完整轮转(每小时)
python3 subconscious_metabolism.py review # 每日健康检查
代谢周期
滴答(每5分钟)
bash
python3 subconscious_metabolism.py tick
- - 通过学习桥扫描 .learnings/ → 将新项目加入待处理队列
- 被动强化:增加待处理项目的强化计数
- 跳过已强化项目(防止类型损坏)
- 运行有界维护:新鲜度衰减、指标统计,无结构性变更
轮转(每小时)
bash
python3 subconscious_metabolism.py rotate --enable-promotion
- - 完整维护:刷新、衰减、快照轮转
- 晋升门控(仅当使用 --enable-promotion 时):
- confidence >= 0.75
- reinforcement >= 3
- freshness >= 0.3
- 不与核心/实时/待处理中的任何项重复
- 通过治理检查
审查(每天上午6点)
bash
python3 subconscious_metabolism.py review
- - 系统健康检查
- 快照完整性
- 待处理队列深度检查
- 建议日志
学习桥
学习桥将自我改进代理技能连接到潜意识:
- - 扫描 .learnings/LEARNINGS.md、.learnings/ERRORS.md、.learnings/FEATURES.md
- 跟踪每个文件中已见过的条目,记录在 learningsbridgelastseen.json 中
- 新条目 → 以类型 candidatequeued 加入 pending.jsonl
- 本会话中已强化的条目 → 跳过(幂等)
桥接到自我改进代理:应在代谢滴答中调用学习桥,以便新学习内容每5分钟自动流入潜意识。
检查系统健康状态
bash
python3 subconscious_metabolism.py status
预期输出:
Core: 3/50 Live: 1/100 Pending: 0/500 Snapshots: 10/10
Status: OK
如果 Pending: 0/500 且 Live: N — 系统健康,项目正确晋升。
如果 Status: blocked — 达到资源限制,运行 rotate 进行压缩。
手动添加项目
bash
手动排队一个教训
python3 subconscious_cli.py intake --kind LESSON --text 记住在声称成功前先验证 --confidence 0.8 --source manual
查看待处理队列中的内容
python3 subconscious_cli.py pending
关键文件
| 文件 | 用途 |
|---|
| subconscious/schema.py | 项目数据类、验证、种类枚举 |
| subconscious/store.py |
带原子写入的JSON文件操作 |
| subconscious/retrieve.py | 相关性评分、is_duplicate |
| subconscious/influence.py | 将项目转换为提示的偏差块 |
| subconscious/governance.py | 变异类型、保护类、边界 |
| subconscious/evolution.py | 晋升管道、强化逻辑 |
| subconscious/maintenance.py | 衰减、快照轮转、内务管理 |
| subconscious/intake.py | 从轮次中保守提取项目 |
| subconscious/flush.py | 为会话连续性构建/加载快照 |
| subconscious/learnings_bridge.py | 连接到自我改进代理的 .learnings/ |
用于Claude Code会话
当Claude Code需要评估或改进潜意识系统时,使用 claude-cx 包装器:
bash
claude-cx 运行:python3 ~/.openclaw/skills/subconscious/scripts/subconscious_metabolism.py status
claude-cx 运行:python3 ~/.openclaw/skills/subconscious/scripts/subconscious_cli.py bias
claude-cx 读取 ~/.openclaw/skills/subconscious/subconscious/evolution.py 第450-525行
Cron设置
运行 install.sh 后,四个cron任务将激活:
- - /5 — 滴答(轻量代谢)
- 0 — 轮转(每小时,带晋升)
- 0 6 — 审查(每日健康检查)
- 0 9 1 — 每周基准测试(周一上午9点,与基线比较)
每周基准测试
将当前状态与安装时捕获的基线快照进行比较。报告以下内容:
- - 学习内容量变化(LEARNINGS.md、ERRORS.md条目)
- 晋升到实时的新偏差
- 待处理队列深度
- 错误复发率(作为学习效果的代理指标)
bash
手动运行
python3 scripts/subconscious_benchmark.py
查看过去的基准测试
ls memory/subconscious/benchmarks/
cat memory/subconscious/benchmarks/benchmark_YYYY-MM-DD.json
要捕获新的基线:
bash
python3 scripts/subconscious_benchmark.py --capture-baseline
要覆盖工作区位置:
bash
export SUBCONSCIOUS_WORKSPACE=/path/to/any/workspace