cs.AIOct 14, 2026

MemCode: Discrete Semantic Representations for Long-Term Agent Memory

Authors: Xin Li, Liang Hu, Duoqian Miao, Ming Peng, Qi Zhang

Organizations: Tongji University · WorldMind

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 40130 seconds, making it 321 times faster than LightMem and over an order of magnitude faster than A-MEM and MemoryOS.

Figures & tables

Appendix figures & tables12 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. LazyMem: Retrieve Broadly, Construct Selectively for Efficient Long-Term Agent Memory

    Jul 17, 2026Jing Yu, Yibo Zhao, Jiaming Zhang +1Persistent Memory for Language ModelsLong-Term Conversational Memory

  2. DimMem: Dimensional Structuring for Efficient Long-Term Agent Memory

    May 15, 2026Wentao Qiu, Haotian Hu, Fanyi Wang +2LLM Agent MemoryPersistent Memory for Language Models