MemOS Local Plugin v2.0.8 — 深度研究报告
Codex 核验(2026-10-09):本报告为当时的源码观察。式
(1−λ)+λ·γ^(T−t)中,γ 调低会增强对近期步骤的偏重;γ→1 或 λ=0 才趋于均匀。V̄_with−V̄_without是观察分组差值,未经随机对照不能称为策略的因果增益。当前 Hermes 的memory.provider一次激活一个 provider;gbrain 与 MemOS 共存需要显式组合 provider/独立工具,不是设置两个名称即自动共存。首次下载本地 embedding 模型需要网络;LLM 回退到远端时内容仍会出机。依据Hermes memory provider 源码。
基于完整源码分析:
@memtensor/memos-local-plugin(Reflect2Evolve V7) 研究日期: 2026-07-15
1. 整体架构
1.1 模块关系图
┌─────────────────────────────────────────────────────────────────────┐
│ agent-contract/ (DTO + JSON-RPC + Events) │
│ TurnInputDTO, TurnResultDTO, InjectionPacket, CoreEvent, Errors │
└────────────┬────────────────────────────────────────────────┬───────┘
│ JSON-RPC (stdio/TCP) │ in-process
┌────────────▼──────────┐ ┌────────────────▼────────┐
│ bridge/ (stdio.ts) │ │ adapters/hermes/ │
│ bridge.cts │◄──── JSON-RPC ────►│ __init__.py (Python) │
│ methods.ts (dispatch)│ │ MemTensorProvider │
└────────────┬──────────┘ └─────────────────────────┘
│
┌────────────▼────────────────────────────────────────────────────────┐
│ core/ │
│ │
│ ┌─────────┐ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
│ │ capture │───►│ reward │───►│ L2 (policy)│───►│ L3 (world │ │
│ │ (L1) │ │(backprop)│ │ induction │ │ model) │ │
│ └─────────┘ └──────────┘ └──────────┘ └───────┬───────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────▼───────┐ │
│ │ retrieval │◄───│ feedback │◄───│ skill │ │
│ │ (T1/T2/T3) │ │ (repair) │ │ (crystallization) │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │
│ ┌──────────┐ ┌─────────┐ ┌──────────┐ ┌────────┐ ┌────────────┐ │
│ │ session │ │ config │ │ storage │ │ llm │ │ embedding │ │
│ │ manager │ │ schema │ │ (SQLite) │ │ client │ │ engine │ │
│ └──────────┘ └─────────┘ └──────────┘ └────────┘ └────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ pipeline/ (orchestrator.ts + memory-core.ts) │ │
│ │ The single `createPipeline` -> MemoryCore facade │ │
│ └──────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────────────────┐
│ server/ (HTTP) │ │ viewer/ (Preact SPA) │
│ port :18800 │ │ Memory Viewer Dashboard │
│ REST API + SSE │ │ Tasks/Policies/Skills/Logs │
└─────────────────┘ └──────────────────────────────┘
1.2 数据流(一次完整的用户交互周期)
User Turn
│
▼
onTurnStart() ──► Intent Classifier ──► Injection Scheduler
│ │
│ ▼
│ Three-Tier Retrieval (T1/T2/T3)
│ │
│ ▼
│ InjectionPacket (context)
│
▼
Agent acts (LLM call + tool calls)
│
▼
onTurnEnd() ──► Lite Capture (extract steps, summarize, embed)
│
▼ (episode finalized?)
Topic-End Reflection ──► Reward Scoring (R_human) ──► Backprop (V_t)
│
▼
L2 Induction (policy discovery from traces)
│
▼
L3 Abstraction (world model from policy clusters)
│
▼
Skill Crystallization (procedures from policies)
│
▼
Feedback/Repair (failure detection, decision guidance)
2. 三层记忆模型
2.1 L1 Trace (Step-Level Grounded Records)
文件: core/capture/, core/types.ts (TraceRow)
- 定义: 每一条 L1 trace 对应 agent 的一步操作(一个 tool call 或一段 assistant 文本),记录 action + observation + reflection + value
- 核心字段:
id,episodeId,sessionId,userText,agentText,summary,toolCalls,reflection,value,alpha,rHuman,priority,tags,errorSignatures,vecSummary,vecAction,turnId - Capture 流程 (core/capture/capture.ts):
runLite(): 每轮对话后增量提取新 steps → normalize → 生成 summary → embed → 写入 trace rows (reflection=null, alpha=0)runReflect(): 主题结束后批量 reflection 评分(windowed batch mode)→ 回写 reflection + alpha → 触发 downstream reward- Windowed batch 模式: 主窗口 20 条(overlap 3),退化到 9 条(overlap 3),episode 级别回退。反射分类: PIVOTAL(alpha=1) > RELATED/RELATED_DEFAULT(alpha=0.5) > IRRELEVANT(alpha=0)
- Embedding: 双向量
vecSummary(用户意图语义)+vecAction(agent 行为语义),支持 6 种 embedding provider(local/openai/gemini/cohere/voyage/mistral)
2.2 L2 Policy (Sub-Task Strategies)
文件: core/memory/l2/l2.ts
- 定义: 跨 trace 归纳出的子任务策略模式,核心是触发条件 + 操作步骤 + 验证标准 + 边界条件
- PolicyRow 核心字段:
id,title,trigger,procedure,verification,boundary,support,gain,status(candidate|active|archived),experienceType,evidencePolarity,decisionGuidance(preference/antiPattern),skillEligible - Induction 流程 (runL2):
- Associate: 每个高 V trace 与现有 policy 做 cosine + signature 匹配。匹配到的 bump support;未匹配的进入 candidate pool
- Candidate Pool: 按 PatternSignature 分桶,等待收集足够多的 episodes (
minEpisodesForInduction) - Induce: 对 ready buckets 运行
l2.inductionLLM prompt → 生成 draft policy - Dedup: 检查 content duplication + cosine similarity 去重
- Gain Computation:
G = V̄_with − V̄_without,经 EMA 平滑 (gainEmaAlpha=0.4) - Status Transition:
candidate → active(gain ≥ minGain, support ≥ minSupport),active → archived(gain < archiveGain)
- PatternSignature: 从 trace 的 error signatures + tool names + tags 计算的语义指纹,用于跨候选池匹配
2.3 L3 World Model (Environmental Cognition)
文件: core/memory/l3/l3.ts
- 定义: 从多个相关 L2 policy 中抽象出的环境认知模型,包含拓扑结构 (ℰ)、行为规则 (ℐ)、约束禁忌 (𝒞)
- WorldModelRow 核心字段:
id,title,body(markdown),structure({environment, inference, constraints}),domainTags,confidence,policyIds,status(active|archived),version - Abstraction 流程 (runL3):
- Gather: 收集所有 active policies(gain ≥ minPolicyGain=0.02, support ≥ minPolicySupport=1)
- Cluster: 使用
clusterPolicies()按 domain key + centroid proximity 分簇(minSimilarity=0.6) - Cooldown: 每个 domain tag 有 cooldown 保护(默认 1 天),避免反复抽象
- Abstract: 对每个存活 cluster 运行
l3.abstractionLLM prompt → 生成结构化 (ℰ, ℐ, 𝒞) draft - Merge or Create: 与现有 world model 做 cosine 比较,高于阈值则 merge/update,否则 insert new
- Confidence: 初始 confidence=0.5,positive feedback +0.05,negative -0.05;confidence < 0.2 的隐藏于 Tier-3 检索
3. 反射加权回报回传算法
文件: core/reward/backprop.ts
这是 MemOS 的核心信用分配机制,公式:
f_t = (1-λ) + λ·γ^(T-t) # 时序位置权重
recovery_t = 1 if α_t>0 and α_{t-1}=0 else 0 # 恢复信号
r_t = 1 + δ·recovery_t # 恢复加成
w_t = α_t · f_t · r_t # 综合权重
V_t = (w_t / Σw) · R_human # 当 Σw>0
V_t = 0 # 当 Σw=0
参数:
γ (gamma=0.9): 时序衰减因子,越靠近任务结束的步骤权重越高λ (lambda=0.5): 位置偏置混合系数,0=全平坦,1=纯 γ^(T-t) 衰减δ (delta=0.1): 恢复加成系数,当 alpha 从 0 变为 >0 时给予额外权重α_t (alpha): 反射权重,从 reflection 分类映射:IRRELEVANT→0, RELATED→0.5, RELATED_DEFAULT→0.5, PIVOTAL→1
Priority 衰减:
priority_t = max(V_t, 0) · 0.5^(Δt_days / halfLifeDays)
decayHalfLifeDays=30: 30 天内 priority 衰减到一半
完整 Reward 管线 (core/reward/reward.ts):
- Episode 终了 → 构建 task summary
- 收集 explicit/implicit feedback
scoreHuman(): R_human ∈ [-1, 1],通过 LLM 评分或 heuristic 回退backprop(): 按上述公式分配 V_t 到每个 trace- Persist: 更新 trace 的 value/alpha/rHuman/priority,更新 episode 的 rTask/outcome
- Emit
reward.updated→ 触发下游 L2/L3/Skill
Episode Outcome:
rTask ≥ 0.5→ successrTask ≤ -0.15→ failure- 中间值 → unknown
4. 技能结晶机制
文件: core/skill/skill.ts, core/skill/crystallize.ts
4.1 Eligibility 评估
evaluateEligibility() 对每个 L2 policy:
- success 模式: support ≥ minSupport(2), gain ≥ minGain(0.02) →
crystallize - 已有 skill 的新 evidence: 与现有 skill 内容比对 →
rebuild或skip - 无证据 / 低质量:
skip
4.2 Crystallization 流程
- Gather evidence: 从 policy 关联的 trace 中精选高 V traces
- Gather counter-examples: V<0 的 negative trace(用于 anti-pattern)
- LLM call:
SKILL_CRYSTALLIZE_PROMPT(或SKILL_REBUILD_PROMPT) → 生成结构化 draft - Verifier:
verifyDraft()— 启发式一致性检查 - Build SkillRow:
packager.buildSkillRow()— 构建完整技能行 - Upsert: 写入 skills 表,状态为
candidate - Graduation: 经过
candidateTrials(3)次 trial(tracked in skill_trials),通过验证后晋升为active
4.3 SkillRow 核心字段
name: 规范化名称invocationGuide: 调用指南(Markdown,注入到 agent prompt)procedureJson: 结构化过程(工具序列)eta: 采用率 [0,1],η < 0.1 时归档support,gain: 从源 policy 继承evidenceAnchors: 结晶时的证据 L1 trace 列表decisionGuidance: { preference, antiPattern }repairOrigin: 是否从修复流程产生(晋升门槛更高)
4.4 Rebuild 机制
- L1 (minor): 仅更新 eta/support/gain,不修改 procedure
- L2 (major): 重新生成整个 skill(允许改名,仅限于 repair-origin skill 的首次 rebuild)
- L3 (full): 重建 invocationGuide + procedure + evidence 全部
5. 检索策略
文件: core/retrieval/retrieve.ts
5.1 Three-Tier Architecture
| Trigger | T1 (Skill) | T2 (Trace/Episode/Experience) | T3 (World Model) |
|---|---|---|---|
turn_start | ✓ (3) | ✓ (5) | ✓ (2) |
tool_driven | ✗ | ✓ (5+3) | ✓ (2) |
skill_invoke | ✓ (3) | ✓ (2) | ✗ |
sub_agent | ✗ | ✓ (5) | ✓ (2) |
decision_repair | ✓ (3) | ✓ (5) | ✗ |
(数字 = 默认 topK)
5.2 多通道检索
每个 tier 使用多个通道并行查询,最后通过 RRF (Reciprocal Rank Fusion) 融合:
- Vector (cosine):
vecSummary/vecAction/vec - FTS5 (full-text): SQLite FTS5 索引
- Pattern (LIKE): CJK 双字母 + 短 ASCII 回退
- Structural (error signatures): V7 §2.6 精确错误签名匹配
5.3 Ranking Pipeline
- Channels → Candidates: 每个通道返回 (id, score) 对
- Fusion (RRF):
score = Σ[1/(k + rank_per_channel)],k=60 - Blend: 最终 relevance =
weightCosine·cosine + weightPriority·priority(0.6:0.4) - MMR (Maximal Marginal Relevance): λ=0.7 平衡相关性与多样性
- LLM Filter: 小模型 LLM 判断 semantic relevance,丢弃无关项
- Relative Threshold: 低于
topRelevance × 0.2的丢弃
5.4 Injection Scheduler
文件: core/injection/scheduler.ts
基于 Intent 分类的结果决定检索计划:
| Intent | Plan |
|---|---|
| CHITCHAT (≥0.6) | 跳过所有检索 |
| CHITCHAT (low) | T1+T2+T3 全量 |
| META | 跳过 |
| MEMORY_PROBE | 按 intent.retrieval 配置 |
| NEW_TASK | 按 intent.retrieval 配置 |
| FOLLOW_UP | 按 intent.retrieval 配置 (默认全量) |
| UNKNOWN | T1+T2+T3 全量 |
6. Hermes 集成方式
文件: adapters/hermes/memos_provider/__init__.py (MemTensorProvider)
6.1 生命周期钩子映射
| Hermes Hook | MemOS Action | RPC Method |
|---|---|---|
initialize(session_id) | spawn bridge + open session (episode deferred) | core.init, session.open |
on_turn_start() | record turn count, stash message | (local state) |
prefetch(user_text) | turn.start RPC → Tier 1+2+3 retrieval → InjectionPacket | turn.start |
queue_prefetch() | background thread: prefetch + flush pending | turn.start |
sync_turn(agent_text) | queue a deferred turn.end RPC | turn.end |
on_session_end() | flush pending + close episode + close session | episode.close, session.close |
on_pre_compress() | extract a short memory summary | memory.timeline |
on_delegation() | record a subagent outcome as a trace | subagent.record |
get_tool_schemas() | expose memory, skill, environment tools | (schema generation) |
handle_tool_call() | dispatch to MemOS JSON-RPC tool methods | various |
shutdown() | close bridge + stop heartbeat | core.shutdown |
6.2 Communication Protocol
- Transport: stdio (JSON-RPC 2.0 over stdin/stdout to Node.js bridge.cts)
- Alternative: TCP mode (bridge.cts with
--daemon) - Python → Node: JSON-RPC request messages
- Node → Python: JSON-RPC responses + notifications (events, logs)
- Host LLM Bridge: Python adapter registers
host.llm.completehandler → MemOS 可以回退到 Hermes 自己的 LLM 做 scoring/skill-evolution
6.3 关键适配细节
- Tool call capture: 注册
post_tool_callhook 实时捕获工具调用 → 在sync_turn中 flush - Model thinking capture: 从
post_llm_call的conversation_history提取 reasoning 块 - Verifier feedback 识别:
_is_verifier_feedback_prompt()检测自然反馈模式 - Hermes 内部 review 过滤: 识别 Hermes 的 background memory/skill review turns 并跳过
- Tool failure 检测:
_on_transform_tool_result()在连续失败 ≥3 次后附加 repair hint
6.4 工具清单
Hermes 可用的记忆工具(get_tool_schemas()):
memos_search— 语义搜索记忆memos_get— 获取单条 tracememos_timeline— 时间线预览memos_environment— 环境/世界认知memos_skill_list— 列出技能memos_skill_get— 获取完整技能
7. 配置项详解
7.1 顶层配置
| 配置项 | 默认值 | 说明 |
|---|---|---|
version | 1 | 配置文件版本 |
domain | "" | 任务领域预设;“ir” 启用 IR-only 行为 |
viewer.port | 18800 (Hermes) | Viewer HTTP 端口 |
viewer.bindHost | ${LOCALIP} | 监听地址 |
bridge.port | 18911 | Bridge TCP 端口(TCP 模式) |
bridge.mode | stdio | 桥接模式 |
7.2 Provider 配置
| 配置项 | 默认值 | 说明 |
|---|---|---|
embedding.provider | local | 嵌入引擎: local/openai_compatible/gemini |
embedding.model | Xenova/all-MiniLM-L6-v2 | 嵌入模型(local 默认 384 维) |
llm.provider | host (Hermes) | LLM 提供方: host/local_only/openai_compatible/anthropic/gemini/bedrock |
llm.fallbackToHost | true | provider 失败时回退到 host LLM |
skillEvolver.* | (optional) | 专用技能进化模型,留空则使用主 LLM |
7.3 Algorithm 配置
Capture:
| 参数 | 默认 | 说明 |
|---|---|---|
batchMode | windowed | 反射模式,固定为 windowed |
maxTextChars | 4000 | 文本截断上限 |
maxToolOutputChars | 2000 | 工具输出截断上限 |
embedTraces | true | 是否生成 trace 向量 |
alphaScoring | true | 是否 LLM 评分反射 α |
Reward:
| 参数 | 默认 | 说明 |
|---|---|---|
gamma | 0.9 | 时序衰减因子 γ |
lambda | 0.5 | 位置偏置混合 λ |
delta | 0.1 | 恢复加成 δ |
tauSoftmax | 0.5 | L2 关联 softmax 温度 τ |
decayHalfLifeDays | 30 | 优先级衰减半衰期(天) |
llmScoring | true | 启用 LLM 评分 R_human |
minExchangesForCompletion | 1 | 最小评分对话轮次 |
feedbackWindowSec | 600 | 评分等待窗口(秒) |
L2 Induction:
| 参数 | 默认 | 说明 |
|---|---|---|
minSimilarity | 0.72 | trace → policy 关联余弦阈值 |
candidateTtlDays | 30 | 候选池 TTL(天) |
minEpisodesForInduction | 1 | 最小 induction episode 数 |
minTraceValue | 0.01 | trace 最小 V 值门槛 |
useLlm | true | 是否使用 LLM 归纳 policies |
gainEmaAlpha | 0.4 | Gain EMA 平滑系数 |
archiveGain | -0.05 | 归档 gain 阈值 |
L3 Abstraction:
| 参数 | 默认 | 说明 |
|---|---|---|
minPolicies | 1 | 最小 policy 数触发抽象 |
minPolicyGain | 0.02 | policy 最小 gain |
clusterMinSimilarity | 0.6 | 聚类余弦阈值 |
useLlm | true | 是否使用 LLM 生成 world model |
cooldownDays | 1 | 同 domain 抽象冷却(天) |
confidenceDelta | 0.05 | 每次 feedback 置信度变化 |
minConfidenceForRetrieval | 0.2 | 检索隐藏置信度下限 |
Skill:
| 参数 | 默认 | 说明 |
|---|---|---|
minSupport | 2 | 结晶最小 support |
minGain | 0.02 | 结晶最小 gain |
candidateTrials | 3 | candidate → active trial 数 |
traceCharCap | 500 | 证据 trace 截断 |
evidenceLimit | 6 | 最大证据 trace 数 |
useLlm | true | 是否使用 LLM 结晶 |
etaDelta | 0.1 | 用户反馈 η 变化量 |
archiveEta | 0.1 | η 归档阈值 |
repairCandidateMinEta | 0.5 | 修复 origin 候选人晋升门槛 |
Retrieval:
| 参数 | 默认 | 说明 |
|---|---|---|
tier1TopK | 3 | T1 (Skill) 注入数 |
tier2TopK | 5 | T2 (Trace/Episode) 注入数 |
tier3TopK | 2 | T3 (World Model) 注入数 |
candidatePoolFactor | 4 | SQLite 候选池因子 |
weightCosine | 0.6 | cosine 融合权重 |
weightPriority | 0.4 | priority 融合权重 |
mmrLambda | 0.7 | MMR 相关性/多样性平衡 |
rrfConstant | 60 | RRF 常数 k |
minSkillEta | 0.1 | Skill 检索 η 下限 |
minTraceSim | 0.35 | Trace 检索 cosine 下限 |
llmFilterEnabled | true | LLM 相关性过滤 |
llmFilterMaxKeep | 8 | LLM 过滤后最大保留数 |
skillInjectionMode | summary | T1 注入模式 (summary/full) |
Session:
| 参数 | 默认 | 说明 |
|---|---|---|
followUpMode | merge_follow_ups | 后续对话处理模式 |
mergeMaxGapMs | 2h | 合并 episode 最大时间间隔 |
8. JSON-RPC 协议接口
文件: agent-contract/jsonrpc.ts, bridge/methods.ts
JSON-RPC 2.0 完整方法注册表:
Lifecycle: core.init, core.shutdown, core.health
Session/Episode: session.open, session.close, episode.open, episode.close
Turn Pipeline: turn.start, turn.end
Memory Queries: memory.search, memory.get_trace, memory.get_policy, memory.get_world, memory.list_episodes, memory.timeline, memory.list_traces, memory.list_world_models
Skills: skill.list, skill.get, skill.archive
Retrieval: retrieval.query
Subagent: subagent.record
Config: config.get, config.patch
Hub: hub.status, hub.publish, hub.pull
Observability: logs.tail, logs.forward, events.subscribe, events.unsubscribe
9. Viewer & Server
文件: server/http.ts, server/routes/*, viewer/dist/
- HTTP Server: 纯 Node.js http 模块(无框架),扁平路由
- Viewer SPA: Preact (Dist 文件在
viewer/dist/),在浏览器中渲染 - API: RESTful JSON API at
/api/v1/* - SSE Events: 实时事件流 (
events.subscribe→events.notify),驱动 Overview 面板 - 端口: Hermes →
:18800, OpenClaw →:18799 - 安全: API key gating + session cookie (可选密码保护)
- Viewer 仪表板:
- Overview: 实时活动流(记忆/经验/环境/技能/反馈摘要)
- Tasks: 任务列表(episodes)按时间线排列
- Memories: L1 trace 浏览
- Policies: L2 经验/策略
- Skills: 已结晶技能
- Environment: L3 世界模型
- Logs: 结构化日志查看器
- Settings: 配置管理
10. 最佳实践总结
10.1 部署配置建议
-
轻量模式 vs 完整模式:
algorithm.lightweightMemory.enabled: true— 仅摘要+检索,适合大多数用户false— 完整自演化闭环(L2/L3/Skill),需要强 LLM(建议 skillEvolver 使用专用模型)
-
LLM 策略:
llm.provider = host— 复用 Hermes 的 LLM(零配置)- 若启用了完整 self-evolution,设置
skillEvolver.provider+skillEvolver.model为更强模型 llm.fallbackToHost: true— provider 失败时回退,确保健壮性
-
Embedding:
local(默认) — 零配置,all-MiniLM-L6-v2384 维,离线可用- 生产环境可切换到
openai_compatible/voyage以获得更高精度
-
Reward 调参:
gamma0.9 关注近期步骤;调低会更偏重近期,趋近 1 才更均匀decayHalfLifeDays30 天:适合长期记忆;短期工作流可调低minExchangesForCompletion保持 1(支持单轮 CLI 模式)
10.2 检索场景优化
-
LLM Filter:
llmFilterEnabled: true+llmFilterMaxKeep: 8— 推荐,大幅降低无关注入llmFilterCandidateBodyChars:默认 500 chars,token 预算充足时可调高
-
Skill 注入模式:
skillInjectionMode: summary— 默认,只在 prompt 中注入摘要 + 调用提示- 通过
memos_skill_get工具在需要时拉取完整内容 - 这比
full模式更 token 高效
-
域名 (
domain) 预设:- 默认
""— 适用于通用 agent 会话 domain: ir— 信息检索专用模式,使用readOnlyInjectionProfile约束注入类型
- 默认
10.3 Session 与 Episode 策略
followUpMode: merge_follow_ups— 适合需要连续上下文的场景(默认)mergeMaxGapMs默认 2h — 超过 2 小时自动新 episode- 如果需要精确的逐任务信用分配,使用
episode_per_turn
10.4 运维
- SQLite 数据库自动管理,无需手动维护
- Viewer 位于
:18800— 浏览器实时监控记忆活动 - 日志轮转默认 50MB × 14 份,审计日志永久保存
- 配置修改后无需重启 agent(通过
/api/v1/config热更新)
11. 与现有架构(gbrain + multi-layer-memory)的对比和互补
11.1 对比
| 维度 | MemOS Plugin | gbrain + multi-layer-memory |
|---|---|---|
| 记忆分层 | L1 Trace / L2 Policy / L3 World Model / Skill | 多层但未标准化为分层体系 |
| 存储 | 本地 SQLite(单文件) | PostgreSQL + 向量数据库 |
| 检索 | 三级检索 (T1/T2/T3) + RRF + MMR + LLM 过滤 | 混合搜索 (vector + keyword) |
| 自主学习 | 反射加权回报回传 + 跨任务归纳 + 技能结晶 | 基于提取事实 (extra facts) 的增量学习 |
| 技能体系 | 自结晶+自验证技能,有 trial/graduation 管线 | SKILL.md 文件系统,人工维护为主 |
| 反馈机制 | Explicit (R_human) + Implicit (V backprop) + Verifier | 无结构化的反馈闭环 |
| LLM 集成 | 内置 LLM client,支持 6+ 提供方 | 通过 MCP 工具调用,依赖 Hermes LLM |
| 社区 | 开源 Apache 2.0, MemTensor 团队 | 开源,Nous Research 生态 |
| 论文支撑 | ArXiv 2507.03724 (MemOS), OmniMemEval 基准 | 无独立论文 |
11.2 互补关系
两者不是替代关系,而是互补的:
-
MemOS 强在「从经验中学习」:
- 自动归纳跨任务策略(L2 Policy Induction)
- 构建环境认知模型(L3 World Model)
- 自主结晶可调用技能(Skill Crystallization)
- 反射加权回报回传(Reflection-Weighted Backprop)
-
gbrain 强在「知识管理」:
- 结构化的知识图谱(页面+链接+事实)
- Schema pack 类型系统
- 语义搜索 + 假设推理
- 多源联邦查询
-
推荐的融合方式:
- gbrain 作为长期知识库:存储结构化知识、公司信息、人脉关系、决策记录
- MemOS 作为经验记忆系统:存储 agent 的操作经验、成功模式、失败教训、自生成的技能
- 共存设计需组合 memory provider 或将另一系统暴露为独立工具——gbrain 提供知识检索,MemOS 提供经验检索;尚未证明原生自动共存
-
具体分工建议:
- 文档和知识类 → gbrain (put_page/query 等)
- agent 历史交互和经验模式 → MemOS (memos_search/memos_skill_get)
- 用户反馈来自每个 Hermes 对话自然流入 MemOS 的反射+回传回路
- MemOS 结晶的技能可作为
skill_view的补充来源
11.3 数据流图(共存场景)
Hermes Agent
│
├── on_turn_start()
│ ├── gbrain.query() → 知识注入
│ └── memos.turn.start() → 经验检索 (T1/T2/T3)
│
├── agent acts
│
└── on_turn_end()
├── gbrain.extract_facts() → 知识提取
└── memos.turn.end() → 痕迹捕获 → 反射 → 回报 → 归纳 → 结晶
附录: 关键文件索引
| 模块 | 路径 |
|---|---|
| 核心入口 | core/index.ts |
| 管线编排 | core/pipeline/orchestrator.ts |
| MemoryCore 门面 | core/pipeline/memory-core.ts |
| 领域模型 | core/types.ts, core/domain.ts |
| 捕捉 (L1) | core/capture/capture.ts |
| 回报回传 | core/reward/backprop.ts, core/reward/reward.ts |
| 策略归纳 (L2) | core/memory/l2/l2.ts |
| 世界模型 (L3) | core/memory/l3/l3.ts |
| 检索 | core/retrieval/retrieve.ts, core/retrieval/types.ts |
| 技能结晶 | core/skill/skill.ts, core/skill/crystallize.ts |
| 反馈/修复 | core/feedback/ |
| 会话管理 | core/session/manager.ts |
| 注入调度 | core/injection/scheduler.ts |
| 嵌入引擎 | core/embedding/embedder.ts |
| LLM 客户端 | core/llm/client.ts |
| 存储层 | core/storage/ (SQLite + repos + migrations) |
| 配置 | core/config/schema.ts, core/config/defaults.ts |
| DTO 协议 | agent-contract/dto.ts |
| MemoryCore 接口 | agent-contract/memory-core.ts |
| JSON-RPC 方法 | agent-contract/jsonrpc.ts |
| 错误码 | agent-contract/errors.ts |
| 事件定义 | agent-contract/events.ts |
| Hermes 适配器 | adapters/hermes/memos_provider/__init__.py |
| Bridge (stdio) | bridge/stdio.ts, bridge/methods.ts |
| HTTP 服务 | server/http.ts |
| Viewer (Preact SPA) | viewer/dist/ |
| Hermes 配置模板 | templates/config.hermes.yaml |
| 实际配置 | config.yaml |