ResearchResearch paperRetrieval, RAG & Search · Efficiency & Inference · Large Language Models1 source · Oct 20, 2026

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

In long-term memory systems, memories are constructed from interaction histories and retrieved in response to queries, enhancing the reasoning ability of LLM agents.

Key points

  • 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.
  • 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.

Sources (1)

  • [1]Memory as Code: Declarative Retrieval over Codified Long-Term Memory
    arXiv (AI, ML, NLP, CV, robotics, multi-agent) · Oct 20, 06:17 AM
    In long-term memory systems, memories are constructed from interaction histories and retrieved in response to queries, enhancing the reasoning ability of LLM agents.
    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.

Extractive summary: sentences quoted from the sources.

Before this

  1. Oct 20, 2026Do Diffusion LLMs Scale? Testing Mercury 3 + Decide
  2. Oct 20, 2026MPS in PyTorch 2.15
  3. Oct 19, 2026Evaluating Agents on Highly Subjective Tasks
  4. Oct 19, 2026NIOCIS: Typed-Decision Next-Hop Routing with Node-Conditioned Option Spaces for Tool-Use Agents
  5. Oct 19, 2026AdaExploreBench: Benchmarking LLM Agents for Proactive Exploration and Test-time Adaptation in Evolving Environments
  6. Oct 18, 2026MemPrice: Online Memory Allocation via Adaptive Pricing for Long-Horizon Agents

Related