MemCode: Discrete Semantic Representations for Long-Term Agent Memory
Abstract
Long-term memory remains a fundamental bottleneck for large language model (LLM) agents across sessions. Existing systems typically adopt a write-then-retrieve paradigm, storing context-dependent dialogue fragments and retrieving them via nearest-neighbor search in a continuous embedding space. This design yields unstable access units and systematically misses logically related but lexically distant evidence. We propose MemCode, a long-term agent memory framework that couples retrieval-oriented writing with discrete associative retrieval. MemCode rewrites dialogue into self-contained atomic memory units (AMUs), maps AMUs into a learnable codebook with isomorphic semantic quantization (ISQ), and uses codebook co-occurrence topology as a retrieval path complementary to vector search. For long-term memory stores, MemCode separates online atomic writes from asynchronous offline consolidation. On LongMemEval-S and LoCoMo with GPT-4o-mini and Qwen3-30B-A3B-Instruct-2507 backbones, MemCode achieves the best overall accuracy while keeping per-dialogue memory construction within roughly 40~130 seconds, making it 3~21 times faster than LightMem and over an order of magnitude faster than A-MEM and MemoryOS.
Create a lesson
Metadata
- Comments
- 27 Pages, Accepted by NeurIPS 2026
Related papers
MemCut: Every Secret Leaves a Trail in the Long-Term Memory of LLM Agents
Shared title terminologycs.AICheng Zhang, Xuanning Cao, Zhicheng Zheng et al.
Improving the Improver: Semantic PID Control for Medical Agent Self-Improvement
Shared title terminologycs.AIDexia Chen, YiLong Hu, Wenqi Zhong et al.
Engram: Multi-Stage Memory for Agentic Tuning of Heterogeneous Models
Shared title terminologycs.AIHuanran Li, Nhat X. T. Le, Kevin De Angeli et al.
SMAD: A Semantics-Guided Multi-Agent Framework for Unsupervised Time-Series Anomaly Detection
Shared title terminologycs.AIQinghua Liu, Junpeng Wang, Mingzhi Hu et al.
From Relevant Memories to Sufficient Evidence: Rethinking Memory Utilization in LLM Agents
Shared title terminologycs.AIShixuan Li, Wei Yang, Peiyu Zhang et al.
Testing the Planning Claims of LLM-Based Agents against Formal Semantics
Shared title terminologycs.AIOriol Miro-Lopez-Feliu, Oscar Miró López-Feliu, Victor Gimenez-Abalos et al.