Simplified overview
Written by Abrar Akhunji
If you build autonomous AI agents today, you are probably making an expensive mistake with how your agents remember things.
Whenever an agent finishes a task, you have to decide what to save to long-term memory. Most developer stacks take the easy way out: they take the entire conversation transcript, throw it at a massive, expensive frontier model (like Claude Opus or GPT-4o), and prompt it: "Extract the important facts and update the database."
THE FRONTIER MODEL MEMORY TRAP
Traditional Memory Extraction:
┌────────────────────────────────────────────────────────┐
│ 1. Raw transcript (45,000 tokens) │ ──► Frontier API Cost: $0.15 / turn
│ 2. Generalist LLM extracts 50 redundant facts │ Context Bloat: Massive
│ 3. Contradictions go unresolved │ Downstream Accuracy: 54%
│ 4. CEO model is acting as an expensive secretary │ "Why did we store my lunch order?"
└────────────────────────────────────────────────────────┘
Tencent Hy-Memory 2.0 Pipeline:
┌────────────────────────────────────────────────────────┐
│ 1. Raw transcript routed to Hy-Memory-30B-A3B │ ──► Dedicated 3B-Active Sparse MoE
│ 2. Attributed RL prunes useless noise before storage │ Downstream Accuracy: 72.6%
│ 3. Tripartite split: Chat, Working, and Code Memory │ 80% Token and Cost Savings
│ 4. MemHub syncs state across all local coding tools │ Unified Cross-Session Recall
└────────────────────────────────────────────────────────┘
Think of it like hiring a Fortune 500 Chief Executive Officer at $2,000 an hour just to sit in your daily standup, transcribe notes, and file receipts into a folder. It works, but it is slow, wildly expensive, and prone to stuffing the filing cabinet with useless clutter.
On October 24, 2026, Tencent Hunyuan released Hy-Memory 2.0 and the open-source Hy-Memory-30B-A3B model under the Apache 2.0 license. It completely rethinks how AI remembers.
The Three Structural Shifts in Hy-Memory 2.0
1. A Dedicated 3B-Active Memory Model (Hy-Memory-30B-A3B)
Instead of using a 200-billion-parameter generalist model, Tencent built a compact Mixture-of-Experts (MoE) network with 30 billion total parameters, but only 3 billion active parameters during inference.
This model does not care about writing poetry or playing chess. It is trained on exactly one job: reading messy conversations, deduplicating facts, resolving conflicting rules, and writing clean, structured memory entries. Because it only activates 3B parameters, it runs locally on consumer GPUs and executes four times faster than cloud API calls.
2. Attributed Reinforcement Learning (Anti-Hoarding Training)
Most memory systems suffer from digital hoarding. They save every minor detail, filling your database with junk that distracts the agent later.
Tencent trained Hy-Memory using Attributed Memory Reinforcement Learning (AMRL). During training, the model is tested on downstream tasks over days of simulated user interactions. If the model saves a fact that helps solve a future problem, it gets a reward. If it saves useless fluff that burns tokens without providing answers, it receives a harsh mathematical penalty.
3. Tripartite Storage: Chat, Working, and Code Memory
Human brains do not dump phone numbers, active coding tasks, and project architecture into a single bucket. Hy-Memory splits memory into three distinct operational engines:
- Chat Memory: Temporal facts anchored by time, place, and people (e.g., "The user moved to Berlin on October 12").
- Working Memory: Active task state. If an agent is executing a 10-step refactor, working memory tracks completed steps, active blockers, and planned next actions so you can pause and resume tasks across days.
- Code Memory: Custom-built for software engineers. It records repository decisions, library constraints, and compiler gotchas so your agent never repeats a failed build pattern.
Let us inspect the MoE tensor specifications, the AMRL loss formulations, benchmark scorecards, and deployment pipelines.
Hy-Memory 2.0 Cognitive Execution Pipeline
- Raw Interaction Streaming: Multi-turn transcripts, terminal execution logs, and AST diffs are streamed directly into the Hy-Memory ingestion buffer without manual pre-filtering.
- Sparse 3B-Active MoE Dispatch: Tokens route through 64 sparse experts (8 active per token), extracting atomic facts and resolving conflicting updates at sub-50ms inference latency.
- Structured Storage Segregation: Facts are dispatched to Chat Memory (temporal event graph), Working Memory (task execution trees), or Code Memory (architectural constraints).
- Universal IPC & Storage Bus: MemHub broadcasts memory mutations across local CLI agents, IDE copilots, and background daemons using conflict-free replicated data structures.
Long-Term Memory Benchmark Accuracy vs. Token Overhead
Comparative evaluation on the LoCoMo benchmark measuring factual answerability against cumulative context token consumption.
| system | LoCoMo Retrieval Accuracy (%) | Token Storage Footprint (kTokens) |
|---|---|---|
| Raw Transcript History | 48.2 | 142.5 |
| Naive LangChain Buffer | 54.1 | 88.4 |
| Mem0 + GPT-4o-mini | 63.8 | 46.2 |
| EverMemOS + Claude 3.5 | 68.4 | 41.8 |
| Hy-Memory 2.0 (30B-A3B) | 72.6 | 28.4 |
Technical breakdown
Written by Abrar Akhunji
Long-term memory systems for autonomous agents have historically been architected as an afterthought, relying on heuristic vector RAG pipelines or generalist LLM prompt wrappers. When deployed on production software engineering tasks spanning multiple days and thousands of repository modifications, these approaches fail due to three core systems breakdowns:
- The Write-Path Generalization Tax: Using frontier models (Claude 3.5 Sonnet, GPT-4o, DeepSeek-V3) to parse conversation histories and extract state changes creates prohibitive operating expenses. Memory writing is fundamentally an extractive, conflict-resolving task that does not require 200B+ active parameters.
- Context Bloat from Over-Storage: Standard memory extraction pipelines maximize recall at the expense of precision. Because LLMs lack counterfactual feedback during extraction, they store irrelevant conversational noise, polluting vector databases and degrading downstream retrieval precision.
- Cross-Agent State Fragmentation: Engineers frequently run Claude Code in the terminal, Cursor in the editor, and local background cron agents simultaneously. Without an OS-level shared memory coordinator, each agent maintains a fragmented, conflicting world state.
Tencent Hunyuan's Hy-Memory 2.0 suite addresses these limitations by introducing a purpose-built 3B-active sparse Mixture-of-Experts model, an attributed reinforcement learning objective, and a local cross-process memory hub.
+---------------------------------------------------------------------------------------------------------------+
| HY-MEMORY 2.0 ARCHITECTURAL SPECIFICATION |
+-----------------------------------+---------------------------------------------------------------------------+
| Architectural Subsystem | Systems Implementation / Engine Responsibility |
+-----------------------------------+---------------------------------------------------------------------------+
| Dedicated Memory Writer Model | Hy-Memory-30B-A3B (Tencent Hunyuan Sparse MoE) |
| Total Parameter Count ($\Theta$) | 30.4 Billion parameters |
| Active Parameters per Token ($A$) | 3.2 Billion parameters (8 active experts out of 64 routed experts) |
| Context Window Length | 32,768 tokens (optimized for multi-turn session dumps) |
| Training Paradigm | Stage 1: Memory On-Policy Distillation (OPD) |
| | Stage 2: Attributed Memory Reinforcement Learning (AMRL) |
| Memory Modalities | Chat Memory (Event Graphs), Working Memory (DAGs), Code Memory (Rules) |
| Sync Daemon | MemHub: Local IPC daemon with SQLite WAL + ChromaDB vector storage |
| Hardware Footprint (INT4 / FP8) | 16.4 GB VRAM (FP8) / 8.8 GB VRAM (INT4 GGUF/AWQ) |
| Inference Runtimes | vLLM, SGLang, Ollama, llama.cpp, Hugging Face TGI |
| Open Source License | Apache 2.0 (Weights and Source Code) |
+-----------------------------------+---------------------------------------------------------------------------+
1. The Write-Path Dilemma: Separating Read and Write Compute
In conventional agent pipelines (such as Mem0 or LangChain Memory), memory operations are handled symmetrically by the primary generation model:
Legacy Symmetrical Pipeline:
User Request ──► [Frontier LLM (200B+)] ──► Response Generation
│
▼
[Frontier LLM (200B+)] ──► Extract Memory Entries (High Latency, High Cost)
This architecture is deeply inefficient. Generation requires broad world knowledge, creative planning, and deep code synthesis. Memory writing, by contrast, requires:
- Strict entity-relation tuple extraction.
- Temporal resolution (determining if "tomorrow" refers to October 25).
- Contradiction reconciliation (updating "database=PostgreSQL" to "database=ClickHouse").
- Noise elimination (discarding conversational filler).
Hy-Memory decouples the write path into an asynchronous, specialized sub-tier:
Hy-Memory Decoupled Architecture:
User Request ──► [Any Target LLM] ──► Fast Response to User
│ (Asynchronous Event Stream)
▼
[Hy-Memory-30B-A3B] (3B Active MoE)
│
├─► Chat Memory (Temporal Event Graph)
├─► Working Memory (Task DAG State)
└─► Code Memory (Architectural Rules)
By offloading the write path to a 3B-active model running locally on the same host or on cheap GPU instances, the primary agent operates with zero added latency, while memory maintenance costs drop by over 80%.
2. Hy-Memory-30B-A3B Model Topology: Sparse MoE Specialization
Hy-Memory-30B-A3B is structured as a decoder-only sparse Mixture-of-Experts transformer. Out of 32 total layers, 28 layers utilize routed MoE feed-forward networks:
Where:
- Total routed experts: experts per MoE layer.
- Active experts per token: experts.
- Shared experts: 2 dedicated shared experts active across all tokens for general syntactic cohesion.
- Hidden dimension: .
- Feed-forward intermediate dimension: per expert.
Because only 8 of the 64 routed experts fire per token, the computational density during inference is identical to a dense 3.2-billion-parameter model, while retaining the parametric capacity of a 30.4-billion-parameter network.
3. Two-Stage Training: Memory On-Policy Distillation and Attributed RL
Training a small MoE model to surpass 200B+ parameter models on complex memory reasoning required a novel two-stage training curriculum:
TWO-STAGE TRAINING CURRICULUM
Raw Multi-Session Transcripts
│
▼
┌───────────────────────────────────────────┐
│ Stage 1: Memory On-Policy Distillation │ ──► Dense token-level supervision from
│ (OPD) │ teacher models on student rollout states
└────────────────────┬──────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ Stage 2: Attributed Memory RL (AMRL) │ ──► Multi-turn trajectory evaluations
│ - Answerability Reward (+) │ Penalizes over-storage and noise
│ - Memory Bloat Penalty (-) │ Optimizes downstream utility
└───────────────────────────────────────────┘
Stage 1: Memory On-Policy Distillation (OPD)
Standard distillation applies teacher supervision on offline target datasets. In dynamic memory systems, student models generate their own intermediate memory states that drift from the training distribution.
Tencent's OPD forces the student model to generate memory candidate graphs on-policy. A frontier teacher model (Hunyuan-Large) then evaluates the student's generated state transitions, providing dense step-level KL divergence feedback:
Stage 2: Attributed Memory Reinforcement Learning (AMRL)
The primary failure mode of memory systems is storing facts that look plausible but are never useful. AMRL resolves this through downstream trajectory rollouts.
Given a multi-turn session trajectory , the model generates a memory bank . Downstream probe tasks then query the agent across subsequent synthetic sessions. The reward function is explicitly partitioned:
Where:
- measures whether downstream questions can be answered using retrieved memory chunks.
- penalizes total token consumption, directly discouraging the model from storing trivial pleasantries or redundant facts.
- computes the contradiction index across stored facts.
This dual-reward optimization produces a model that aggressively filters conversational noise, yielding compact, high-utility memory snapshots.
4. Tripartite Memory Topology: Chat, Working, and Code Memory
Hy-Memory 2.0 abandons flat vector stores in favor of three specialized cognitive storage engines:
HY-MEMORY 2.0 TRIPARTITE ENGINES
┌─────────────────────────┬─────────────────────────┬─────────────────────────┐
│ Chat Memory │ Working Memory │ Code Memory │
├─────────────────────────┼─────────────────────────┼─────────────────────────┤
│ - Temporal Event Graph │ - Active Goal DAGs │ - Architecture Rules │
│ - Entity Relationships │ - Step Preconditions │ - Compiler Constraints │
│ - Conflict Resolution │ - Checkpoint / Resume │ - Anti-Pattern Warnings │
│ - User Preferences │ - Failure Recovery Tree │ - File Ownership Maps │
└─────────────────────────┴─────────────────────────┴─────────────────────────┘
Chat Memory (Temporal Event Graph)
Facts are modeled as temporal assertions . When a new user interaction states "I no longer live in London, I relocated to Zurich yesterday", the conflict engine updates the validity window of the previous location assertion rather than appending a contradictory duplicate.
Working Memory (Task Execution DAGs)
Working memory maintains the active execution graph of long-horizon tasks. If a coding agent crashes during a database migration on Step 4 of a 7-step plan, working memory preserves the execution stack, environmental variables, and failed intermediate outputs. When the session resumes, the agent continues from Step 4 without re-executing Steps 1 through 3.
Code Memory (Repository Architectural Constraints)
Specifically engineered for software development, Code Memory records repository invariants:
- Approved architectural patterns (e.g., "All API handlers must use zod validation schema").
- Hard environmental constraints (e.g., "Node.js runtime limited to v20 on target runner").
- Known regression traps discovered during past debugging sessions.
5. MemHub: Local Multi-Agent Coordination Protocol
In production engineering workflows, developers run multiple autonomous tools simultaneously. Without coordination, Claude Code in the terminal and Cursor in the editor overwrite each other's assumptions.
MemHub operates as a background daemon over Unix domain sockets or local HTTP:
MEMHUB LOCAL COORDINATION TOPOLOGY
[Claude Code CLI] [Cursor IDE] [Background Cron Bot]
│ │ │
└──────────┐ │ ┌──────────┘
▼ ▼ ▼
┌───────────────────────────────┐
│ MemHub Local IPC Bus │
│ (Unix Socket / HTTP 8787) │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ Hy-Memory-30B-A3B Write Engine│
└───────────────┬───────────────┘
│
┌───────────┴───────────┐
▼ ▼
[SQLite WAL Store] [Chroma Vector DB]
(Structured State) (Semantic Embeddings)
MemHub uses conflict-free replicated data structures (CRDTs) to ensure concurrent updates from multiple CLI sessions merge without state corruption.
6. Benchmark Evaluation: LoCoMo, LongMemEval, and Latency Profiles
Hy-Memory 2.0 was benchmarked against leading open-source and proprietary memory frameworks on the LoCoMo and LongMemEval benchmark suites:
+---------------------------------------------------------------------------------------------------------------+
| BENCHMARK EVALUATION: HY-MEMORY 2.0 VS. PRODUCTION MEMORY FRAMEWORKS |
+-----------------------------------+--------------------+--------------------+---------------------------------+
| Evaluation Metric | Mem0 (GPT-4o-mini) | EverMemOS (Sonnet) | Hy-Memory 2.0 (30B-A3B) |
+-----------------------------------+--------------------+--------------------+---------------------------------+
| LoCoMo Overall Accuracy (%) | 63.8% | 68.4% | 72.6% |
| Temporal Event Tracking (%) | 58.2% | 64.1% | 74.8% |
| Contradiction Resolution Rate (%) | 61.4% | 67.9% | 79.2% |
| Code Constraint Adherence (%) | 54.0% | 69.2% | 81.4% |
| Average Memory Write Latency (ms) | 1,840 ms | 2,120 ms | 380 ms (Local FP8) |
| Context Storage Overhead (kTok) | 46.2 kTokens | 41.8 kTokens | 28.4 kTokens (32% reduction) |
| Relative Monthly Operating Cost | 1.0x (Baseline) | 1.45x | 0.18x (82% cost reduction) |
+-----------------------------------+--------------------+--------------------+---------------------------------+
Key Engineering Insights:
- 79.2% Contradiction Resolution: Hy-Memory-30B-A3B achieved a 79.2% success rate in identifying and updating conflicting statements, outperforming Claude 3.5 Sonnet by 11.3%. The AMRL training directly penalizes contradictory memory entries.
- Sub-400ms Memory Write Latency: Running locally in FP8 precision on a single RTX 4090 or Apple Silicon Mac, write latency averaged 380ms, eliminating the 2-second cloud round-trip latency of proprietary APIs.
- 32% Reduction in Storage Footprint: By punishing conversational noise, the AMRL objective pruned non-essential facts, keeping the long-term context store lean and preventing downstream context saturation.
7. Production Deployment: SDK Setup and vLLM Serving
Deploying Hy-Memory 2.0 into an agent workflow can be accomplished using the open-source Python SDK:
Serving Hy-Memory-30B-A3B with vLLM
Launch the model endpoint using vLLM with FP8 quantization:
vllm serve tencent/Hy-Memory-30B-A3B \
--quantization fp8 \
--max-model-len 32768 \
--gpu-memory-utilization 0.90 \
--port 8080
Python SDK Integration
Integrate Hy-Memory 2.0 directly into an existing agent loop:
# -*- coding: utf-8 -*-
"""
Hy-Memory 2.0 Integration Example
Demonstrating tripartite memory management for autonomous coding agents.
"""
from hy_memory import HyMemoryClient, MemoryConfig
# Initialize client pointing to local vLLM endpoint
client = HyMemoryClient(
base_url="http://localhost:8080/v1",
storage_path="~/.local/share/memhub/memory.db",
config=MemoryConfig(
enable_chat_memory=True,
enable_working_memory=True,
enable_code_memory=True,
contradiction_threshold=0.85
)
)
def handle_coding_turn(session_id: str, transcript: list[dict]):
"""
Asynchronously extracts architectural decisions and updates working memory.
"""
# Step 1: Update memory state in background
write_receipt = client.write_turn(
session_id=session_id,
messages=transcript,
domain="code"
)
# Step 2: Query active constraints for next generation turn
active_constraints = client.query_memory(
session_id=session_id,
query="What database migration constraints are active?",
modalities=["code", "working"]
)
return active_constraints
if __name__ == "__main__":
test_transcript = [
{"role": "user", "content": "We are migrating from SQLite to Postgres 16. Do not use raw SQL queries."},
{"role": "assistant", "content": "Understood. I will enforce Drizzle ORM schemas for all migrations."}
]
constraints = handle_coding_turn("dev_session_01", test_transcript)
print("Retrieved Constraints:", constraints)
8. Architectural Takeaways for Senior Systems Engineers
The release of Hy-Memory 2.0 demonstrates three foundational shifts in autonomous AI architecture:
- The Write Path Demands Model Specialization: Forcing a single generalist model to handle user dialogue, tool calling, code generation, and memory maintenance is an anti-pattern. Specialized 3B-active MoE models trained via Attributed RL outperform frontier models at memory extraction while slashing latency and operational cost.
- Attributed Loss Prevents Context Rot: Without counterfactual reinforcement learning that penalizes memory bloat based on downstream answerability, memory systems inevitably degenerate into unmanageable context dumps.
- Cognitive Tripartition Over Flat Vector RAG: Treating chat history, active execution goals, and code constraints as interchangeable text chunks degrades agent reliability. Explicitly partitioning memory into Chat, Working, and Code engines provides the structural rigor required for multi-day autonomous workflows.
Primary References & Technical Repositories
- Tencent Hunyuan Hy-Memory Technical Report: arXiv:2610.22196
- Model Weights on Hugging Face: huggingface.co/tencent/Hy-Memory-30B-A3B
- Hy-Memory Framework Repository: github.com/Tencent-Hunyuan/Hy-Memory
- MemHub Multi-Agent Local Daemon: github.com/Tencent-Hunyuan/MemHub
