[KongchangAI]
· 2 min read· 1,234 words

MemCompile: A Query-Conditioned Compilation Framework for Long-Term Agent Memory

MemCompile: A Query-Conditioned Compilation Framework for Long-Term Agent Memory

MemCompile decouples memory addressing from evidence presentation through query-conditioned evidence compilation, improving answer quality in long-term memory systems.

The MemCompile framework addresses context redundancy or missing information caused by "retrieval-as-concatenation" in long-term memory systems by splitting memory addressing and evidence presentation into an Address Plane and an Evidence Plane. The Address Plane locates evidence using source-linked descriptors and capacity-aware units and resolves heterogeneous hits into stable SourcePackets via a normalization boundary; the Evidence Plane compiles answer-ready context under a bounded budget. It achieves 80.52% Judge Accuracy on LoCoMo and validates generalization on LongMemEval-S. This work shows that controllable compilation at the evidence level is more effective than simply expanding retrieval, offering a new paradigm for agent memory design.

Long-term memory is a key capability for agents to maintain continuous conversations and handle complex tasks, but how to precisely recover "evidence that can answer a question" from massive historical interactions remains an open challenge. Existing systems typically concatenate retrieved memory units directly into the context, causing the final input to be either redundant or missing key information. A recent paper proposes the MemCompile framework, which attempts to bridge this gap through query-conditioned evidence compilation.

MemCompile paper title screenshot

The Core Pain Point of Existing Memory Systems

Current long-term memory systems generally adopt a paradigm of "structured memory + adaptive retrieval," but they have clear deficiencies in the evidence presentation stage. The paper points out that such systems often couple memory addressing with evidence presentation: retrieved units or expanded fragments are passed directly to the reader, with neither secondary filtering based on query requirements nor unified normalization of heterogeneous retrieval results. As a result, the final context may contain a large amount of irrelevant content while missing complementary evidence scattered across different sessions.

This "retrieval-as-concatenation" approach is especially inefficient in long-conversation scenarios—the larger the memory store, the more severe the redundancy, while the clues that truly support the answer may be hidden across multiple sources. The starting point of MemCompile is precisely to split "finding relevant memories" and "organizing them into answerable evidence" into two independent but coordinated steps.

Reader in retrieval-augmented generation (RAG) and long-term memory systems refers to the module that receives retrieval results and generates the final answer, usually a large language model. The quality of its input directly determines the quality of its output: if the context is redundant, the model may be distracted by irrelevant information; if the context lacks key evidence, the model cannot reason correctly. Therefore, the "evidence presentation" link between retrieval and the reader is one of the bottlenecks of system performance, which also explains why MemCompile makes evidence compilation an independent dedicated module.

MemCompile's Two-Layer Architecture: Addressing and Evidence Compilation

The core design of MemCompile is divided into an Address Plane and an Evidence Plane, which are connected through a unified identity identifier.

Address Plane: Locating Supporting Evidence from Massive Memory

The Address Plane is responsible for quickly locating relevant support from long-term memory given a query. It organizes memory using compact, source-linked descriptors and capacity-aware Cells. Each Cell can hold a certain number of memory items and establishes links to original sources through descriptors. When retrieval hits multiple heterogeneous sources, a normalization boundary resolves these hits into stable SourcePacket identities. The key here is that it does not directly output raw text fragments, but rather outputs "evidence packets" with source identifiers, providing clean and traceable input for subsequent compilation.

SourcePacket is the basic unit in MemCompile that represents an "evidence packet." It normalizes multiple heterogeneous sources hit by a single retrieval (such as different sessions or different memory units) into a unified identity and retains source links for traceability. Unlike raw text fragments, SourcePacket carries structured source identifiers and descriptor information, enabling downstream modules to judge the complementarity and credibility of evidence. This design avoids the format chaos and source loss caused by directly concatenating raw fragments, and is the prerequisite for budget allocation and rendering in the Evidence Plane.

Evidence Plane: Compiling Answer-Ready Context under Budget Constraints

The Evidence Plane receives the set of SourcePackets from the Address Plane and allocates the evidence budget according to query requirements. Specifically, it:

  • Allocates a bounded evidence budget among complementary evidence packets, prioritizing the information most relevant to the query;
  • Allows limited additional support to be added to cover supplementary evidence scattered across multiple locations;
  • Renders the retained assertions associated with each selected evidence packet into answer-ready context for direct use by the downstream reader.

This "compile first, generate later" process ensures that the final context is neither excessively bloated nor missing the key evidence needed for answering.

Experimental Results: Dual Advantages in Quality and Cost

The paper validates the effectiveness of MemCompile on multiple long-term conversational memory benchmarks. On the LoCoMo dataset, MemCompile achieves 80.52% Judge Accuracy and extends to a higher quality region on the quality-cost Pareto frontier. This means that at the same cost, it can provide better answer quality; or, to achieve the same quality, its cost is lower.

In addition, strong performance on the LongMemEval-S benchmark further demonstrates that the benefits of query-conditioned compilation can generalize to different long-term conversational memory tasks. The authors believe that this design, which decouples memory addressing from evidence presentation, provides a more controllable and efficient paradigm for long-term agent memory.

Pareto frontier in multi-objective optimization refers to a set of solutions in which "no objective can be improved without sacrificing another." In memory systems, quality and cost (such as context length and computational overhead) often constrain each other. MemCompile's extension to a higher region on the quality-cost Pareto frontier means it can improve quality without increasing cost, or reduce cost without lowering quality, thereby outperforming the trade-off curves of existing methods. This metric reflects the practical deployment value of the system better than a single accuracy number.

Implications for Agent Memory Design

The proposal of MemCompile reflects a trend in long-term memory research: shifting from "retrieve more" to "compile more accurately." Traditional methods tend to expand the retrieval window or increase the number of memory units, but MemCompile proves that lossy but controllable compilation at the evidence level can instead improve the accuracy of final answers.

For developers building practical agent systems, this approach offers two lessons. First, memory systems should output normalized evidence packets with source identifiers rather than raw fragments, so that downstream modules can perform traceable filtering and composition. Second, explicit management of the evidence budget helps control context length and avoid performance degradation caused by "memory explosion" in long-conversation scenarios.

At present, the details of MemCompile have been disclosed in the paper; if its code and implementation are open-sourced later, it is expected to become a strong baseline for long-term memory systems.

Lossy but controllable compilation draws on ideas from compiler theory: when a compiler converts source code into target code, it discards redundant information but preserves semantic equivalence. In memory systems, this means the Evidence Plane does not need to retain all retrieved content, but selectively compresses and reorganizes evidence according to query requirements, while ensuring that key information is not lost through budget constraints and source identifiers. This "compilation" perspective elevates memory organization from simple retrieval concatenation to active information distillation, and is the core philosophy that distinguishes MemCompile from traditional methods.

One-line Summary

MemCompile decouples memory addressing from evidence presentation through query-conditioned evidence compilation, improving answer quality in long-term memory systems.

Paragraph Summary

The MemCompile framework addresses the problem of context redundancy or missing information caused by "retrieval-as-concatenation" in long-term memory systems by splitting memory addressing and evidence presentation into an Address Plane and an Evidence Plane. The Address Plane uses source-linked descriptors and capacity-aware units to locate evidence and resolves heterogeneous hits into stable SourcePackets through a normalization boundary; the Evidence Plane compiles answer-ready context under a bounded budget, prioritizing complementary evidence and allowing limited additional support. It achieves 80.52% Judge Accuracy on the LoCoMo dataset and validates generalization on LongMemEval-S. This work shows that controllable compilation at the evidence level is more effective than simply expanding retrieval, providing a new paradigm for agent memory design.

#MemCompile#long-term memory#agent memory#query-conditioned compilation#LoCoMo#memory addressing#evidence compilation
Share:

Related articles