MemoryCPT: An End-to-End Agent Memory Framework for Cost-Performance Trade-off

AuthorsSongxin Lei, Kun Ouyang, Weilin Ruan et al.

arXiv 20262026

TL;DR

MemoryCPT uses Query-agnostic Distillation plus cost-aware Query-aware Retrieval and Summarization to reach F1 0.479 on LoCoMo with Cost 4.31 (QPC 0.111).

SharePost on XLinkedIn

Read our summary here, or open the publisher PDF on the next tab.

THE PROBLEM

Long-horizon agents waste cost on redundant context

Long-horizon LLM agents must recover useful evidence from large histories, but existing memory pipelines introduce redundant context and high inference cost.

These training-free systems rely on hand-crafted heuristics and repeated LLM calls, making multi-session dialogue QA expensive while only a small fraction of tokens contain useful evidence.

HOW IT WORKS

MemoryCPT: Query-agnostic Distillation plus Query-aware Retrieval and Summarization

MemoryCPT’s core mechanism is Query-agnostic Distillation, Query-aware Retrieval and Summarization, RRF-based Retrieval, and a GRPO-trained Fine Summary adapter over a frozen QA model.

You can think of MemoryCPT like RAM and disk: QAD builds structured long-term storage, while QAR acts as a smart memory controller deciding which blocks to load.

This KEY_MECHANISM lets MemoryCPT learn when to construct, retrieve, and compress memories, achieving cost-aware context selection that a plain context window cannot match.

DIAGRAM

Online Query-aware Retrieval and Summarization Flow

This diagram shows how MemoryCPT processes a query online using RRF-based retrieval and GRPO-trained summarization before calling the frozen QA model.

DIAGRAM

Two-stage Training Pipeline for MemoryCPT

This diagram shows how MemoryCPT trains Query-agnostic Distillation and Query-aware Retrieval and Summarization to optimize Quality per Cost.

PROCESS

How MemoryCPT Handles a Long-horizon Memory QA Query

  1. 01

    Query-agnostic Distillation

    MemoryCPT runs Query-agnostic Distillation offline, where teacher traces train LoRA-A to perform BatchSegmenter, EpisodeGenerator, EpisodeMerger, and SemanticExtractor operations.

  2. 02

    Memory Store Construction

    MemoryCPT merges LoRA-A into the base model to form baseA, then builds episodic and semantic memories M = Mep ∪ Msem from raw histories H.

  3. 03

    Query-aware Retrieval and Summarization

    For each query q, MemoryCPT applies RRF-based Retrieval over M to get MRRF q and uses the GRPO-trained Fine Summary adapter LoRA-B to generate a compact mq.

  4. 04

    Final QA with Cost-aware Context

    MemoryCPT feeds q and mq into the frozen Qwen3-14B QA model, producing answer y^ while controlling token cost to maximize Quality per Cost.

KEY CONTRIBUTIONS

Key Contributions

  • 01

    End-to-end memory pipeline for cost-performance optimization

    MemoryCPT spans Query-agnostic Distillation and Query-aware Retrieval and Summarization, explicitly optimizing Quality per Cost on long-horizon multi-turn dialogue memory.

  • 02

    Two-stage post-training algorithm

    MemoryCPT trains LoRA-A via supervised fine-tuning on teacher reasoning traces, then trains LoRA-B with GRPO and a cost-aware reward while keeping the QA model frozen.

  • 03

    Empirical evaluation of Quality per Cost

    MemoryCPT introduces QPC and shows F1 0.479 with Cost 4.31 on LoCoMo, improving QPC over BudgetMem from 0.015 to 0.111 with Qwen-2.5-7B.

RESULTS

By the Numbers

F1

0.479

+0.106 over BudgetMem on LoCoMo with Qwen-2.5-7B

Judge

0.755

+0.115 over BudgetMem on LoCoMo with Qwen-2.5-7B

Cost

4.31 (USD×10^4 per query)

-19.80 vs BudgetMem’s 24.11 on LoCoMo with Qwen-2.5-7B

QPC

0.111

+0.096 vs No-Memory Qwen-3-14B’s 0.015 on LoCoMo

On LoCoMo, which tests long-horizon dialogue memory, MemoryCPT with Qwen-2.5-7B base achieves F1 0.479 and Cost 4.31, yielding QPC 0.111. This MAIN_RESULT shows MemoryCPT can increase answer quality while cutting inference cost compared to BudgetMem and other baselines.

BENCHMARK

By the Numbers

On LoCoMo, which tests long-horizon dialogue memory, MemoryCPT with Qwen-2.5-7B base achieves F1 0.479 and Cost 4.31, yielding QPC 0.111. This MAIN_RESULT shows MemoryCPT can increase answer quality while cutting inference cost compared to BudgetMem and other baselines.

BENCHMARK

Main Results on LoCoMo with Qwen-2.5-7B Base

F1 on LoCoMo for MemoryCPT and representative memory baselines using Qwen-2.5-7B as the base.

BENCHMARK

Cost per Query on LoCoMo with Qwen-2.5-7B Base

Inference Cost (USD×10^4 per query) on LoCoMo for MemoryCPT and baselines.

KEY INSIGHT

The Counterintuitive Finding

MemoryCPT with Fine Summary reaches F1 0.479 on LoCoMo at Cost 4.31, while a variant without FS has F1 0.446 at Cost 8.35.

It is surprising that adding a GRPO-trained summarizer both improves quality by 0.033 and cuts cost by 4.04, contradicting the intuition that better summaries must be more expensive.

WHY IT MATTERS

What this unlocks for the field

MemoryCPT unlocks long-horizon agents that can learn memory construction and query-aware compression jointly, targeting Quality per Cost instead of raw accuracy.

Builders can now deploy agents that maintain rich episodic and semantic memories while keeping inference budgets low, making multi-session personalization practical at scale.

~12 min read← Back to papers

Related papers

BenchmarkAgent Memory

Active Context Compression: Autonomous Memory Management in LLM Agents

Nikhil Verma

· 2026

Focus Agent adds start_focus, complete_focus, a persistent Knowledge block, and an optimized Persistent Bash plus String-Replace Editor scaffold to actively compress context during long software-engineering tasks. On five hard SWE-bench Lite instances against a Baseline ReAct agent, Focus Agent achieves 22.7% token reduction (14.9M → 11.5M) while matching 3/5 = 60% task success.

Agent Memory

ActMem: Bridging the Gap Between Memory Retrieval and Reasoning in LLM Agents

Xiaohui Zhang, Zequn Sun et al.

· 2026

ActMem transforms dialogue history into atomic facts via Memory Fact Extraction, groups them with Fact Clustering, links them through a Memory KG Construction module, and uses Counterfactual-based Retrieval and Reasoning for action-aware answers. On ActMemEval, ActMem reaches 76.52% QA accuracy with DeepSeek-V3, beating LightMem’s 63.97% by 12.55 points and NaiveRAG’s 61.54%.

Questions about this paper?

Paper: MemoryCPT: An End-to-End Agent Memory Framework for Cost-Performance Trade-off

Answers use this explainer on Memory Papers.

Checking…