mlsanityData to 24 Nov 2026

Memory as Code: Declarative Retrieval over Codified Long-Term Memory

arXiv 2610.27700 ↗Submitted 20 Oct 2026cs.CLcited by 0

On the map: LLM reasoning → Knowledge- and tool-augmented reasoning

also in 1 more
Abstract (arXiv)

In long-term memory systems, memories are constructed from interaction histories and retrieved in response to queries, enhancing the reasoning ability of LLM agents. In complex scenarios, facts are scattered across sessions and their relationships evolve over time, making it difficult for existing memory systems to compose them to adapt to diverse queries. Motivated by the modularity and composability of code, we propose Memory as Code (MaC), a unified memory framework that jointly designs memory construction and retrieval through a shared code abstraction. MaC couples codified construction, which establishes executable memory abstractions, with declarative retrieval, which translates queries into structured retrieval programs. Specifically, codified construction builds a three-layer executable memory structure that progresses from an atomic function layer, through a relational layer, to a modular composition layer. Declarative retrieval recasts retrieval from relevance-based fact selection into declarative query processing over memory. Experiments on LoCoMo and LongMemEval show relative gains of up to 15.91% in overall LLM-judge accuracy over the strongest baseline in each setting, while substantially reducing token consumption, highlighting the effectiveness of memory as code for long-horizon memory tasks.

Key facts. No citing papers in the map yet (data through 24 Nov 2026). Placed in Knowledge- and tool-augmented reasoning, one of 17 directions in LLM reasoning. Builds on 23 of its 23 references that are in the map. Submitted 20 Oct 2026.

Builds on

23 of 23 references.

Closest ancestors · 2

Same direction, newest first

  1. 2025Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning12 Mar
  2. 2025Search-o1: Agentic Search-Enhanced Large Reasoning Models9 Jan

Other references · 21

  1. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,845
  2. 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 9,589
  3. 2023Generative Agents: Interactive Simulacra of Human Behaviorcited by 3,841
  4. 2023MemGPT: Towards LLMs as Operating Systemscited by 1,655
  5. 2021Improving language models by retrieving from trillions of tokenscited by 1,328
  6. 2025A-MEM: Agentic Memory for LLM Agentscited by 1,253
  7. 2024Evaluating Very Long-Term Conversational Memory of LLM Agentscited by 977
  8. 2025Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memorycited by 915
  9. 2024LongMemEval: Benchmarking Chat Assistants on Long-Term Interactive Memorycited by 876
  10. 2023MemoryBank: Enhancing Large Language Models with Long-Term Memorycited by 630
  11. 2025Zep: A Temporal Knowledge Graph Architecture for Agent Memorycited by 479
  12. 2023An LLM Compiler for Parallel Function Callingcited by 217
9 more
  1. 2024Retrieval-Augmented Generation with Graphs (GraphRAG)cited by 178
  2. 2025Memory OS of AI Agentcited by 175
  3. 2026MemSkill: Learning and Evolving Memory Skills for Self-Evolving Agentscited by 170
  4. 2025In Prospect and Retrospect: Reflective Memory Management for Long-term Personalized Dialogue Agentscited by 123
  5. 2025On Memory Construction and Retrieval for Personalized Conversational Agentscited by 118
  6. 2023Think-in-Memory: Recalling and Post-thinking Enable LLMs with Long-Term Memorycited by 71
  7. 2026StructMem: Structured Memory for Long-Horizon Behavior in LLMscited by 23
  8. 2026Memory is Reconstructed, Not Retrieved: Graph Memory for LLM Agentscited by 14
  9. 2025Text2Mem: A Unified Memory Operation Language for Memory Operating Systemcited by 4

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2026From Relevant Memories to Sufficient Evidence: Rethinking Memory Utilization in LLM Agents
  2. 2026Chain-of-Memory: Lightweight Memory Construction with Dynamic Evolution for LLM Agents
  3. 2026Test-Time Memory Construction
  4. 2026Diagnosing Retrieval vs. Utilization Bottlenecks in LLM Agent Memory
  5. 2026Reliable Post-Retrieval Assembly for Agent Memory: Separating Evidence Extraction from Policy Execution
  6. 2026Memora: A Harmonic Memory Representation Balancing Abstraction and Specificity
  7. 2026Auditing Long-Term Memory Evaluation: Repeated Judging, Reader Variation, and Negative Controls
  8. 2026Recall What Is Missing: Composing Evidence from Long-Term Agent Memory