Memory Harness
A reliable memory harness that makes byterover recall happen at the right times without running heavy recall on every turn.
Architecture
CODEBLOCK0
3-Stage Harness
Stage 1: Session Preflight
Runs ONLY at the start of a new session.
Fetches:
- - active project
- pinned facts
- unresolved items
- recent important entities
- recent session summary
Does NOT fetch:
- - full raw history
- large raw memory dumps
- low-signal old notes
Output: compact session_digest (hard capped)
Stage 2: Triggered Recall
Runs targeted byterover recall only when needed.
Trigger conditions:
- - Continuation words: 続き, 前回, 再開, 引き継ぎ, continue, resume, previous work
- Known entity/project name: ClawHub, OpenClaw, Agent-OS, BOSS-memory-loop, etc.
- Task requires user-specific/project-specific context
- Implementation / modification / design / planning request
- Ambiguous task likely depending on prior context
Skip conditions:
- - Generic factual Q&A
- Small self-contained questions
- Casual short exchange
- Clearly answerable without prior context
Recall modes:
- -
preflight_query: start-of-session only - INLINECODE2 : when named entities detected
- INLINECODE3 : for previous-session continuation
- INLINECODE4 : when advice depends on prior rules
- INLINECODE5 : immediately before execution
Stage 3: Pre-Execution Recall Gate
MANDATORY before:
- - file edits
- code generation
- architecture proposals
- configuration changes
- planning depending on prior project state
- any meaningful change suggestion
Checks for:
- - prior constraints
- unresolved issues
- conflicting past decisions
- project-specific conventions
- safety-sensitive context
Memory Shaping
Never inject raw byterover results directly.
Pipeline:
- 1. retrieve
- rank
- dedupe
- compress
- inject bounded digest
Hard limits:
- - maxmemoryitems: 5
- maxdigestlines: 8
- prefer recent + high-signal + tagged items
Status Tracking
Every recall records one of:
- - INLINECODE6
- INLINECODE7
- INLINECODE8
- INLINECODE9
- INLINECODE10
Scripts
intent-classifier.js
Classifies turn intent as one of:
- - INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
- INLINECODE17
- INLINECODE18
entity-detector.js
Detects known entities in user input:
- - Scans for known entity/project names
- Maps aliases to canonical names
- Returns matched entities for recall routing
session-preflight.sh
Runs lightweight recall at session start:
- - Fetches pinned facts, active project, unresolved items
- Creates compact session_digest
- Hard capped length
targeted-recall.sh
Runs targeted recall based on intent:
- - Takes intent, entities, session state
- Chooses appropriate recall mode
- Returns compressed digest
pre-execution-gate.sh
Runs before execution-like actions:
- - Checks for constraints, conflicts, safety issues
- Returns go/no-go with relevant context
memory-compress.js
Compresses and dedupes raw memory:
- - Ranks by relevance and recency
- Dedupes repeated items
- Hard caps output size
writeback.sh
Writes high-signal info back to memory:
- - Only for important decisions/outcomes
- Skips trivial chat and low-value text
Configuration
CODEBLOCK1
Logging
Structured logs for observability:
- - INLINECODE19
- INLINECODE20
- INLINECODE21
- INLINECODE22
- INLINECODE23
- INLINECODE24
- INLINECODE25
- INLINECODE26
- INLINECODE27
- INLINECODE28
Known Entities
Default entity list (expandable):
- - ClawHub
- OpenClaw
- Agent-OS
- BOSS-memory-loop
- ByteRover
- MISO
- Obsidian
- Telegram
Continuation Triggers
Japanese: 続き, 前回, 再開, 引き継ぎ, 前の, さっきの
English: continue, resume, previous, earlier, last time, back to
Success Criteria
- - Reliable recall when turn depends on context
- Generic turns stay lightweight
- Execution actions always get constraint check
- Behavior inspectable in logs
- No reliance on SKILL.md text alone
记忆驾驭工具
一个可靠的记忆驾驭工具,能让字节漫游者在恰当的时机进行回忆,而无需在每一轮对话中都执行繁重的回忆操作。
架构
用户输入
-> 意图分类
-> 会话预检(如果是新会话)
-> 条件性定向回忆
-> 规划
-> 执行前回忆门控(如果是执行类操作)
-> 执行或响应
-> 可选的回写
三阶段驾驭工具
第一阶段:会话预检
仅在新会话开始时运行。
获取内容:
- - 活跃项目
- 固定事实
- 未解决事项
- 近期重要实体
- 近期会话摘要
不获取内容:
输出:紧凑的会话摘要(硬性上限)
第二阶段:触发式回忆
仅在需要时执行定向的字节漫游回忆。
触发条件:
- - 接续词:続き、前回、再開、引き継ぎ、continue、resume、previous work
- 已知实体/项目名称:ClawHub、OpenClaw、Agent-OS、BOSS-memory-loop等
- 任务需要用户特定/项目特定的上下文
- 实施/修改/设计/规划请求
- 可能依赖先前上下文的模糊任务
跳过条件:
- - 通用事实问答
- 小型独立问题
- 随意简短交流
- 无需先前上下文即可明确回答的问题
回忆模式:
- - 预检查询:仅会话开始时
- 实体查询:检测到命名实体时
- 接续查询:用于延续上一会话
- 约束查询:建议依赖先前规则时
- 执行前查询:执行前立即执行
第三阶段:执行前回忆门控
以下情况必须执行:
- - 文件编辑
- 代码生成
- 架构提案
- 配置变更
- 依赖先前项目状态的规划
- 任何有意义的变更建议
检查内容:
- - 先前约束
- 未解决问题
- 冲突的过往决策
- 项目特定约定
- 安全敏感上下文
记忆塑形
绝不直接注入原始的字节漫游结果。
处理流程:
- 1. 检索
- 排序
- 去重
- 压缩
- 注入有界摘要
硬性限制:
- - 最大记忆条目数:5
- 最大摘要行数:8
- 优先选择近期 + 高价值 + 已标记条目
状态追踪
每次回忆记录以下状态之一:
- - 不需要
- 已查询无结果
- 已查询低置信度
- 已查询成功
- 查询失败
脚本
intent-classifier.js
将对话轮次意图分类为:
- - 通用问答
- 随意交流
- 接续
- 实体引用
- 用户特定上下文
- 实施请求
- 设计请求
- 执行请求
entity-detector.js
检测用户输入中的已知实体:
- - 扫描已知实体/项目名称
- 将别名映射为标准名称
- 返回匹配的实体用于回忆路由
session-preflight.sh
在会话开始时执行轻量级回忆:
- - 获取固定事实、活跃项目、未解决事项
- 创建紧凑的会话摘要
- 硬性长度上限
targeted-recall.sh
基于意图执行定向回忆:
- - 接收意图、实体、会话状态
- 选择合适的回忆模式
- 返回压缩摘要
pre-execution-gate.sh
在执行类操作前运行:
- - 检查约束、冲突、安全问题
- 返回通过/不通过及相关上下文
memory-compress.js
压缩并去重原始记忆:
- - 按相关性和时效性排序
- 去重重复条目
- 硬性限制输出大小
writeback.sh
将高价值信息写回记忆:
配置
json
{
memory_policy: {
preflightonsession_start: true,
preflight_depth: light,
preexecutionrecall: true,
maxmemoryitems: 5,
maxdigestlines: 8,
triggerqueryif: [
mentionsknownproject,
askstocontinuepreviouswork,
requiresuserspecific_context,
requestscodedesignorchange,
containsknownentity
],
skipqueryif: [
generic_qa,
casual_chat,
selfcontainedquestion
]
}
}
日志记录
结构化日志用于可观测性:
- - 轮次ID
- 会话ID
- 意图
- 回忆触发条件
- 回忆模式
- 回忆状态
- 回忆条目数
- 注入条目数
- 执行前门控
- 耗时(毫秒)
已知实体
默认实体列表(可扩展):
- - ClawHub
- OpenClaw
- Agent-OS
- BOSS-memory-loop
- ByteRover
- MISO
- Obsidian
- Telegram
接续触发词
日语:続き、前回、再開、引き継ぎ、前の、さっきの
英语:continue、resume、previous、earlier、last time、back to
成功标准
- - 当对话轮次依赖上下文时,能可靠进行回忆
- 通用对话轮次保持轻量
- 执行操作始终获得约束检查
- 行为可通过日志检查
- 不单独依赖SKILL.md文本