ReMe 架构与设计思路分析
agentscope-ai/ReMe 是 AgentScope 生态的 memory management toolkit。它同时保留“memory as files”的 ReMeLight 和更完整的 vector/service pipeline:personal memory、task memory、tool memory、working memory 都有独立 summary/retrieve op,目标是解决长对话 context window 和跨 session stateless 两个问题。
核心架构图
┌──────────────────────────── agent conversation / trajectory ─────────────────┐
│ messages · tool results · task traces · user preferences │
└───────────────────────────────┬───────────────────────────────────────────────┘
│
┌───────────────────────────────▼───────────────────────────────────────────────┐
│ ReMe memory orchestration │
│ context check · compact · summarize · retrieve · pre_reasoning_hook │
└───────────────┬───────────────────────────────┬───────────────────────────────┘
│ │
┌───────────────▼──────────────┐ ┌─────────────▼──────────────────────────────┐
│ ReMeLight file memory │ │ vector/service pipeline │
│ MEMORY.md · daily journal │ │ personal/task/tool/working ops + vector DB │
└───────────────┬──────────────┘ └─────────────┬──────────────────────────────┘
│ │
┌───────────────▼───────────────────────────────▼──────────────────────────────┐
│ recalled context: compact summary · semantic/BM25 hits · task/tool lessons │
└───────────────────────────────────────────────────────────────────────────────┘
模块分层
| 层/目录 | 责任 |
|---|---|
reme/reme_light.py + reme/memory/file_based/** |
文件型记忆系统:MEMORY.md、daily journal、dialog JSONL、tool_result cache。 |
reme_ai/summary/** |
personal/task/tool/working 四类总结 pipeline,包含 observation、reflection、dedup、validation、trajectory segmentation。 |
reme_ai/retrieve/** |
personal/task/tool/working 检索 pipeline,包含 query rewrite、semantic rank、rerank/fusion、文件 grep/read/write。 |
reme_ai/vector_store/** |
向量记忆更新、频率/效用更新、recall op。 |
关键数据流
- ReMeLight 在 pre-reasoning 前检查 token,过阈值则压缩老消息、保留近期上下文,并把长 tool output offload 到文件。
- 长期记忆写入
MEMORY.md和memory/YYYY-MM-DD.md,原始对话进入dialog/YYYY-MM-DD.jsonl,便于人工迁移/修改。 - vector pipeline 将 personal/task/tool/working memory 拆成不同 summary 和 retrieve op,按场景选择信息,而不是用一个大表统管所有记忆。
设计决策
- 文件优先版本适合个人 agent:可读、可迁移、可手改;vector/service 版本适合规模化 AgentScope 应用。
- 按 memory type 拆 pipeline 比 mem0 的通用 memory layer 更重,但更贴合 agent 工作流。
- 把 tool result 单独 offload,说明 ReMe 主要关心 context 爆炸,不只是长期偏好。
对比定位
和 mem0 相比,ReMe 更框架内生,记忆类型更细;和 memsearch 相比,它不是 Markdown journal + Milvus shadow index,而是 context management + file/vector memory;和 tencentdb-agent-memory 相比,ReMe 更轻、更贴 AgentScope hooks。
相关链接
- GitHub 当前状态底稿:src-github-stars-backlog-current-state
- 选型地图:github-stars-backlog-implementation-map