腾讯开源Hy Memory:面向LLM Agent的双系统认知记忆引擎
Tencent-Hunyuan/Hy-Memory
Agent记忆是当前的核心痛点,这套方案给出了从SDK到本地存储再到专用小模型的完整落地路径,做Agent开发的同学值得深入研究其双系统架构。
GitHub repository created 2026-10-15 · 1001 stars in 4.7 days (about 212 a day) · Python
GitHub 仓库创建于 2026-10-15 · 4.7 天内获得 1001 颗星(约每天 212 颗)· Python
Hy Memory
Production-grade dual-system cognitive memory for LLM agents.
面向 LLM 智能体的生产级双系统认知记忆。
English | 中文
Hy Memory (Official Website) is a production-grade dual-system cognitive memory engine and Python SDK (`hy-memory`) for self-evolving LLM agents, providing specialized memory pipelines across three task scenes: hierarchical long-term cognitive memory for Chat, two-layer fact and reusable-experience memory for Working, and version-evolution diff-chain tracking for Coding. Built on top of Hy Memory, MemHub is a local-first desktop and CLI product that unifies conversation history and coding traces from user-authorized AI applications (such as Claude Code, Cursor, Codex, OpenCode, and Qwen Code) into a single managed runtime and local data directory, enabling governed cross-application memory recall.
Hy Memory(官方网站)是一个面向自进化 LLM 智能体的生产级双系统认知记忆引擎及 Python SDK(`hy-memory`),提供针对三个任务场景的专用记忆管道:Chat 场景下的分层长期认知记忆、Working 场景下的双层事实与可复用经验记忆,以及 Coding 场景下的版本演进差异链追踪。基于 Hy Memory 构建的 MemHub 是一款本地优先的桌面端和 CLI 产品,它将用户授权的 AI 应用(如 Claude Code、Cursor、Codex、OpenCode 和 Qwen Code)中的对话历史和编码痕迹统一到一个受管运行时和本地数据目录中,从而实现跨应用的受控记忆召回。
MemHub Demo Video
MemHub 演示视频
Latest News
最新动态
* *[new]* 🔥🔥🔥 **[2026-10]**: 🚀 Open-sourced quantized FP8 (**Hy-Memory-30B-A3B-FP8**) and GGUF (**Hy-Memory-30B-A3B-GGUF**) versions of Hy-Memory-30B-A3B on Hugging Face! * *[new]* 🔥🔥🔥 **[2026-10]**: 📦 Released MemHub v1.0.4 and memhub-cli 1.0.5, with a signed macOS desktop app and verified macOS/Linux Runtimes! * *[new]* 🔥🔥🔥 **[2026-10]**: 🚀 Released Hy Memory 2.0 (`hy-memory==2.0.4`) on PyPI and open-sourced the Hy-Memory monorepo together with MemHub! * *[new]* 🔥🔥🔥 **[2026-10]**: 🚀 Open-sourced Hy-Memory-30B-A3B on Hugging Face along with its technical report on attributed reinforcement learning for long-term memory writing! * *[new]* 🔥🔥 **[2026-09]**: 📊 Released CMB: A Coding Memory Benchmark for Long-Horizon and Interleaved Coding Agents (submitted to ICLR 2027). * *[new]* 🔥🔥 **[2026-08]**: 🎉 Accepted at EMNLP 2026: **Memory Beyond Recall: A Dual-Process Cognitive Memory System for Self-Evolving LLM Agents**! * 🔥 **[2026-05]**: 🌟 Initial Release Released Hy Memory 1.0, our first-generation dual-system cognitive memory framework for self-evolving LLM agents.
* *[最新]* 🔥🔥🔥 **[2026-10]**: 🚀 在 Hugging Face 上开源了 Hy-Memory-30B-A3B 的量化 FP8 (**Hy-Memory-30B-A3B-FP8**) 和 GGUF (**Hy-Memory-30B-A3B-GGUF**) 版本! * *[最新]* 🔥🔥🔥 **[2026-10]**: 📦 发布了 MemHub v1.0.4 和 memhub-cli 1.0.5,包含签名版 macOS 桌面应用并验证了 macOS/Linux 运行时! * *[最新]* 🔥🔥🔥 **[2026-10]**: 🚀 在 PyPI 上发布了 Hy Memory 2.0 (`hy-memory==2.0.4`) 并与 MemHub 一起开源了 Hy-Memory 单体仓库! * *[最新]* 🔥🔥🔥 **[2026-10]**: 🚀 在 Hugging Face 上开源了 Hy-Memory-30B-A3B 及其关于长期记忆写入的属性强化学习技术报告! * *[最新]* 🔥🔥 **[2026-09]**: 📊 发布了 CMB:面向长周期和交错式编码智能体的编码记忆基准测试(已提交至 ICLR 2027)。 * *[最新]* 🔥🔥 **[2026-08]**: 🎉 被 EMNLP 2026 录用:**Memory Beyond Recall: A Dual-Process Cognitive Memory System for Self-Evolving LLM Agents**! * 🔥 **[2026-05]**: 🌟 初始版本发布:推出了 Hy Memory 1.0,这是我们面向自进化 LLM 智能体的第一代双系统认知记忆框架。
Papers
论文
Welcome to the Hy Memory Research Family, covering cognitive chat memory, long-horizon coding memory, and RL-trained memory writing models:
欢迎来到 Hy Memory 研究家族,涵盖认知聊天记忆、长周期编码记忆以及经过 RL 训练的记忆写入模型:
> **Memory Beyond Recall: A Dual-Process Cognitive Memory System for Self-Evolving LLM Agents** *(Accepted at EMNLP 2026)* > TL;DR: Proposes the dual-process (System 1 + System 2) cognitive memory architecture for Chat, organizing personal memory into an 8-layer hierarchy (raw dialogues, atomic facts, summaries, schemas, and prospective intentions) with conflict reconciliation and cross-domain schema induction. > 📄 Paper: https://arxiv.org/abs/2606.09483
> **超越回忆的记忆:面向自进化大语言模型智能体的双过程认知记忆系统** *(已接收 EMNLP 2026)* > TL;DR:提出了一种用于聊天场景的双过程(系统1 + 系统2)认知记忆架构,将个人记忆组织为8层层次结构(原始对话、原子事实、摘要、模式及前瞻性意图),并包含冲突协调与跨领域模式归纳。 > 📄 论文:https://arxiv.org/abs/2606.09483
> CMB: A Coding Memory Benchmark for Long-Horizon and Interleaved Coding Agents *(Submitted to ICLR 2027)* > TL;DR: Introduces a benchmark and two-layer + version-evolution diff-chain memory method for long-horizon Coding agents, preserving both reusable engineering experiences and exact code revision trajectories across interleaved tasks. > 📄 Paper: docs/papers/CMB_A_Coding_Memory_Benchmark_for_Long_Horizon_and_Interleaved_Coding_Agents.pdf
> CMB:面向长周期与交错式编码智能体的编码记忆基准 *(已提交 ICLR 2027)* > TL;DR:引入了一个基准测试以及一种两层+版本演进差异链记忆方法,专为长周期编码智能体设计,在交错任务中同时保留可复用的工程经验和精确的代码修订轨迹。 > 📄 论文:docs/papers/CMB_A_Coding_Memory_Benchmark_for_Long_Horizon_and_Interleaved_Coding_Agents.pdf
> **Hy-Memory-30B-A3B: Attributed Reinforcement Learning for Long-Term Memory Writing** *(Open Model Technical Report)* > TL;DR: Trains a 30B-A3B MoE model via attributed reinforcement learning specifically for high-precision long-term memory extraction and conflict reconciliation. > 📄 Paper: https://arxiv.org/abs/2610.22196 · Model: https://huggingface.co/tencent/Hy-Memory-30B-A3B
> **Hy-Memory-30B-A3B:归因强化学习用于长期记忆写入** *(开源模型技术报告)* > TL;DR:通过归因强化训练了一个30B-A3B MoE模型,专门用于高精度的长期记忆提取和冲突协调。 > 📄 论文:https://arxiv.org/abs/2610.22196 · 模型:https://huggingface.co/tencent/Hy-Memory-30B-A3B
Quick Start
快速开始
1. Installation
1. 安装
2. Configuration
2. 配置
Only an LLM and an embedding endpoint are needed; any OpenAI-compatible service works:
仅需一个大语言模型和一个嵌入端点;任何兼容 OpenAI 的服务均可使用:
Or use the OpenAI defaults with a single key:
或者使用带有单个密钥的 OpenAI 默认设置:
See the Environment Variable Reference for the full list.
完整列表请参阅环境变量参考。
3. Chat Memory
3. 聊天记忆
4. Working & Coding Memory
4. 工作 & 编码记忆
Writes must include a tool-call trace (`tool_calls` or `role="tool"` messages) and take effect in `pro` / `ultra` mode only (`lite` ignores `scene` and stores everything as raw memory):
写入操作必须包含工具调用轨迹(`tool_calls` 或 `role="tool"` 消息),且仅在 `pro` / `ultra` 模式下生效(`lite` 会忽略 `scene` 并将所有内容存储为原始记忆):
5. Routing, Source Isolation & Advanced APIs
5. 路由、源隔离 & 高级 API
- Automatic scene routing: When `scene` is omitted, writes without tool calls go straight to `chat` (zero LLM calls), and writes with tool calls are classified once into `chat` / `working` / `coding`. For searches, `search_mode="default"` goes to `chat` with zero LLM calls, while `search_mode="agentic"` performs scene classification, query rewriting, and time-range parsing. See Working/Coding Scenes. - Separate memories by source: Pass `source="openclaw" | "cursor" | "codex"` on `add()` and filter with `include_sources` / `exclude_sources` on `search()` to isolate caller applications independently of `agent_id`. - CRUD & System 2 evolution: `client.get(id)`, `client.update(id, text)`, `client.delete(id)`, `client.list_memories(user_id=...)`, and `client.evolve(user_id=...)` (triggers System 2 in `ultra` mode). - Per-call embedding endpoint override: Pass `embed_override={"base_url": ..., "api_key": ...}` to `add()` / `search()` or use `with embed_endpoint_override(...):` for concurrency-safe endpoint switching.
- 自动场景路由:当省略 `scene` 时,不带工具调用的写入直接发送至 `chat`(零 LLM 调用),带工具调用的写入则被分类至 `chat` / `working` / `coding`。对于搜索,`search_mode="default"` 以零 LLM 调用进入 `chat`,而 `search_mode="agentic"` 会执行场景分类、查询重写和时间范围解析。参见 Working/Coding Scenes。 - 按来源分离记忆:在 `add()` 上传递 `source="openclaw" | "cursor" | "codex"`,并在 `search()` 上使用 `include_sources` / `exclude_sources` 进行过滤,以独立于 `agent_id` 隔离调用方应用程序。 - CRUD 与 System 2 演进:`client.get(id)`、`client.update(id, text)`、`client.delete(id)`、`client.list_memories(user_id=...)` 以及 `client.evolve(user_id=...)`(在 `ultra` 模式下触发 System 2)。 - 每次调用的嵌入端点覆盖:向 `add()` / `search()` 传递 `embed_override={"base_url": ..., "api_key": ...}`,或使用 `with embed_endpoint_override(...):` 以实现并发安全的端点切换。
For provider configuration, storage backends, scenes, and the complete API, see the Usage Guide.
有关提供商配置、存储后端、场景和完整 API,请参阅使用指南。
System Architecture
系统架构
Hy Memory provides three memory scenes (`scene`), one per kind of task. `add()` / `search()` go through the scene router first, then into the Chat or the Working / Coding pipeline (orange parts in the diagram are coding-only; without them the pipeline is Working):
Hy Memory 提供三种记忆场景(`scene`),每种任务类型对应一种。`add()` / `search()` 首先经过场景路由器,然后进入 Chat 或 Working / Coding 管道(图中橙色部分仅用于编码;若无这些部分,管道则为 Working):
| `scene` | Tasks | Memory shape | ||
|---|---|---|---|---|
| `chat` | Small talk, personal information, preferences, general Q&A | Hierarchical memory (L0–L7) | ||
| `working` | Productivity work: documents, spreadsheets, research, financial analysis, content creation, computer operation | Two-layer memory: session facts + reusable experiences | ||
| `coding` | Software engineering: coding, debugging, testing, builds, APIs/SDKs, scripts, SQL | The same two-layer memory as `working`, plus a code version-evolution chain (diff chain) |
| `scene` | 任务 | 记忆结构 | ||
|---|---|---|---|---|
| `chat` | 闲聊、个人信息、偏好设置、通用问答 | 分层记忆(L0–L7) | ||
| `working` | 生产力工作:文档、电子表格、研究、财务分析、内容创作、计算机操作 | 双层记忆:会话事实 + 可复用经验 | ||
| `coding` | 软件工程:编码、调试、测试、构建、API/SDK、脚本、SQL | 与 `working` 相同的双层记忆,外加代码版本演进链(diff chain) |
1. Chat: Memory Hierarchy
1. Chat:记忆层级
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力