Compact-Memory LLM Agents via Online Max-Member Clustering and Atom-Aware Packing
Abstract
Many long-horizon LLM deployments face tight prompt budgets: latency, cost, and context limits make full-context prompting impractical as interaction length grows. The key question is then not raw recall alone, but which memory design gives the best quality--token trade-off in the compact-memory regime. We present RSM-full, an online clustered-memory pipeline designed for a strong quality--token Pareto point. RSM-full combines two design choices: a cosine-gated max-member merge write rule and an atom-aware grouped context packer. On AMA-Bench, our primary compact-memory benchmark, it reaches of Full-Context quality at of the token cost at a k budget; under four-seed averaging it beats the closest streaming-clustered baseline (Online K-Means) by --,pp () across the whole k--k regime. Three-seed ablations show most of this gain comes from the merge rule (,pp over Online K-Means and matched- DP-means) and the grouped packer (,pp over flat concatenation). The pattern reproduces on RealMem, an independent long-horizon persona-memory benchmark: RSM-full improves on Budget-RAG (,pp, ), is on par with BM25-RAG (paired ,pp, ; we do not claim BM25 equivalence in the equivalence-test sense), and significantly outperforms Streaming-Proto (,pp) and the closest reproduced 2025 agentic-memory baseline A-MEM (,pp, ). Across benchmarks the message is consistent: under tight budgets, compact-memory performance is driven mainly by how streaming memories are merged and how retrieved content is assembled. Overall, RSM-full is most useful when answeroughly -- prompt tokens, where itdefines a strong compact-memory Pareto point; higher-token baselines remain stronger outside this regime.
Figures & tables
| Method | Avg (per-ep) | Recall | CausInf | StaUpd | StaAbs | TotalTok ♡ | Avg/kTok |
| Full-Context | 0.373 | 0.430 | 0.369 | 0.380 | 0.249 | 12,519 | |
| BM25-RAG | 0.357 | 0.405 | 0.366 | 0.363 | 0.234 | 22,648 | |
| Full-RAG | 0.355 | 0.415 | 0.373 | 0.340 | 0.234 | 20,642 | |
| RSM-full-int8 (ours, ) ∗ | 0.315 | 0.373 | 0.337 | 0.295 | 0.196 | 4,003 | |
| RSM-full (ours, ) | 0.311 | 0.361 | 0.342 | 0.308 | 0.169 | 4,001 | |
| Streaming-Proto | 0.302 | 0.337 | 0.347 | 0.280 | 0.203 | 3,982 |
| Multi-seed mean (per-QA) | Mean gain vs. RSM-full ref. (percentage points) | ||||
| Method | bt= 2048/4096/8192 | Seeds | 2.6k | 4k | 5k |
| RSM-full (ref.) | 4/4/4 | ref | ref | ref | |
| Oja ( ) | 4/4/3 | ||||
| Online K-Means | 4/4/3 | ||||
| retrieval | Centroid cosine retrieval | Retrieval contrast | |
| RSM (cosine gate, no cap) | A: | D: | A D (NS, ) |
| Online K-Means ( ) | B: | C: | B C ( ) |
| DP-means ( , ) | E: | F: | E F (NS, ) |
| Clustering contrasts at retrieval endpoint : | |||
| RSM vs K-Means | A B CI , | ||
| RSM vs DP-means | A E CI , | ||
| Seed | Atom-aware ( ) | Flat ( ) | (pp) | Note |
| seed 43 | ( ) | ( ) | Single-seed bootstrap CI , | |
| seed 44 | ( ) | ( ) | Matched-protocol replication | |
| seed 45 | ( ) | ( ) | Matched-protocol replication | |
| 3-seed mean | -CI ; per seed | |||
| Atom-aware numbers are the 3-seed RSM-full results reported in Table 2 . | ||||
| Method | Seed 43 | Seed 44 | Seed 45 | Pool. | |
| RSM-full ( ) | — | ||||
| K-Means (centroid) | — | ||||
| (RSM KM, pp) | |||||
| CI | |||||
| Domain breakdown (pooled; RSM K-Means) | |||||
| OPENWORLD-QA ( ) | |||||
| Method | 3-seed mean Acc | TotalTok ♡ | vs RSM-full (pp) | -value |
| RSM-full ( , ours) | — | — | ||
| BM25-RAG | NS | |||
| Budget-RAG | ||||
| Full-RAG | ||||
| A-MEM † | ||||
| RSM-full-int8 |
| Method / slice | Causal ( ) | State ( ) | Goal ( , new) | Value ( , new) |
| RSM-full ( , ) | / | / | / | / |
| RSM-cent-retr ( -free) | / | / | / | / |
| Full-RAG | / | / | / | / |
| Budget-RAG | / | / | / | / |
| Streaming-Proto | / | / | / | / |
| A-MEM ‡ | / | / | / | / |
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Benchmark | Atoms | (Basis%) | AvgSize | Control | Judge | |
| High- regime ( ): clustered-memory advantage activates | ||||||
| ToolBench-catbal ( ) | 227 | 8.8 | pp | RSM-centroid | GPT-4o | |
| AMA-Bench (208 ep) | 2.3/ep | 10.2 | pp | RSM-centroid | GPT-5.4 | |
| Intermediate regime (partially untested) | ||||||
| ToolBench-hard ( ) | 282 | 1.8 | pp (int8) | RSM-centroid | GPT-4o | |
| Low- regime ( ): RSM-full centroid, graceful degradation | ||||||
| Name | Rank ( ) | Retrieval | Context builder | Storage/atom |
| RSM-full | 2–8 | atom-aware | floats | |
| RSM-full-int8 | 2–8 | atom-aware | int8 | |
| RSM-centroid | 0 | basic (flat) | floats |
| Protocol | RSM-full ( , ) | RSM-cent-retr | Budget-RAG | Streaming- Proto | Full-RAG |
| flat | / | / | / | / | / |
| grouped | / | / | / | / | / |
| (grouped flat) | / | / | / | / | / |
| Method | Mean score (correct/ ) | vs RSM-full | CI | |
| RSM-full ( , ambient cosine, ref) | ( ) | (ref) | — | — |
| Algorithm E ( , subspace-projected) | ( ) |
| Section | Stored object | Retrieval rule | Write gate | Charged storage |
| § F (LLaMA h.s.) | Full subspace centroid ( ) | Proj. (Eq. 2 ) | Cosine | B (f32); int8 optional |
| Appendix B.4 (Latency) | Full subspace (col-major) | Proj. precomputed | N/A (isolated profiling) | B |
| § F (MMLU seq.) | Full subspace centroid ( ) | Proj. (Eq. 2 ) | Cosine | B (f32); int8 optional |
| § 4.1 (AMA main table) | Full subspace centroid ( ) | Proj. | Cosine | B (f32); int8 optional |
| § 4.1 (LoCoMo main table) | Full subspace centroid ( ) | Proj. (pure dense) | Cosine | B (f32); int8 optional |
| Full-RAG (ms) | RSM-full-Naive (ms) | RSM-full-Opt (ms) | Speedup (Naive/Opt) | |
| 10 | 0.030 | 3.390 | 0.176 | |
| 20 | 0.033 | 1.213 | 0.340 | |
| 50 | 0.085 | 3.354 | 0.367 | |
| 100 | 0.060 | 10.997 | 9.889 | |
| 200 | 4.481 | 14.775 | 18.699 | — |
| Symbol | Description |
| Trajectory matrix ( time steps, hidden dimension ) | |
| Subspace basis matrix of atom (orthonormal columns) | |
| Orthogonal projection onto span | |
| Coefficient summary vector of atom | |
| Reconstruction vector (legacy evaluation proxy only) | |
| Grassmann manifold of -planes in |
| bt=2k | bt=4k | bt=8k | ||||
| Method | 4o | 5.4 | 4o | 5.4 | 4o | 5.4 |
| RSM-full-int8 | ||||||
| RSM-full | ||||||
| Streaming-Proto | ||||||
| RSM-centroid | ||||||
| Budget-RAG | ||||||
| Setting | RSM-full ( ) | Budget-RAG | Stream-Proto | KMeans ‡ | Storage | Compression |
| Full-RAG (ref.) | — | — | — | 25,600 KB | ||
| k=4, float32 | 2,624 KB | |||||
| k=4, int8 | 1,064 KB | |||||
| k=2, float32 | 1,616 KB | |||||
| k=2, int8 | 812 KB |
| Budget/Compression | RSM-centroid | Budget-RAG | Stream-Proto | KMeans ‡ |
| ( ) | ||||
| ( ) | ||||
| ( ) | ||||
| ( ) | ||||
| ( ) |
| Method | Storage | Recall@1 ( ) | Coverage ( ) |
| Full-RAG | 1657.5 KB | 10/10 | |
| Budget-RAG ( bytes) | 174.0 KB | ||
| Streaming-Proto ( bytes) | 174.0 KB | 10/10 | |
| RAG-KMeans ‡ ( bytes) | 174.0 KB | 10/10 | |
| RSM-full ( , ) | 174.0 KB | (5 seeds) | 10/10 |
| RSM-full ( ) | 277.5 KB | 10/10 |
| Mean judge quality (0/0.5/1 scale): | ||||
| RSM-full ( ) | ||||
| Streaming-Proto | ||||
| Budget-RAG | ||||
| Retention (% of own baseline): | ||||
| RSM-full | ||||
| Method | bt=2048 | bt=4096 | bt=8192 | Seeds |
| RSM-full | ||||
| Online K-Means | ||||
| Oja ( ) | ||||
| Relative std (coefficient of variation, %): | ||||
| RSM-full | ||||
| Online K-Means | ||||
| Mean judge quality: | |||
| RSM-full ( ) | |||
| Streaming-Proto | |||
| Budget-RAG | |||
| Retention (% of own baseline): | |||
| RSM-full | |||
| RSM-full atoms | RSM-cent.-merge atoms | Atom (paired , ) | Quality (pp) | ||
| k | ( , ) | ( NS) | |||
| k | ( , ) | ( NS) | |||
| Pooled | — | — | — | ( NS) |
LLM Agent Memory
Large language model agent memory lets agents retain, organize, retrieve, and update information across interactions and long-running tasks.
See all 357 papers