Agents that learn from experience without retraining do so by keeping a memory bank of past attempts and looking up similar ones when a new task arrives. This is non-parametric value estimation: instead of compressing experience into network weights, the agent stores raw experiences and estimates how useful an action will be by reading the recorded outcomes of its nearest neighbors. For language-model agents the stored items are whole solution trajectories. These range from a three-line fix to a forty-step household plan, so they differ in size by an order of magnitude or more. Every such system manages its memory as if items were interchangeable slots. Caching research abandoned that uniform-size assumption long ago, because it causes one bulky item to push out dozens of small, useful ones.
We propose to treat a bounded agent memory as a variable-size cache. Each stored trajectory is kept or dropped according to its marginal value per token. That is the expected loss in decision quality if it were removed, divided by its length. For new, unretrieved trajectories, this value is itself estimated non-parametrically from neighboring memories. Admission then follows the multi-victim rule from size-aware web caching: a new item is admitted only if its value beats the summed value of everything that must be evicted to fit it. The claim is that under realistic token budgets this recovers most of the success rate of an unbounded memory at a fraction of its size. We also claim that the gain comes specifically from size heterogeneity and redundancy, not from generic pruning.
Core Claim and What Is New
The closest system is MemRL. It stores intent–experience–utility triples for language-model agents, retrieves by semantic similarity, then re-ranks by a scalar utility learned from Monte Carlo task feedback. It reports an average +3.8% cumulative success rate and +6.2% on ALFWorld. MemRL's utility is a per-item success score. It ignores how many tokens an item costs to store or to place in the prompt, and it does not model eviction under a capacity limit.
Older episodic control methods share the blind spot. Model-Free Episodic Control keeps a nearest-neighbor return table bounded by least-recently-used eviction over unit entries. Continuous Episodic Control replaces entries one-for-one when a nearby experience earns higher return. Semiparametric Reinforcement Learning skips pruning entirely to stay fast. These papers motivate the proposal: each leaves memory management size-oblivious or absent.
The method comes from Lightweight Robust Size Aware Cache Management. That paper's Aggregated Victims rule compares a candidate's request frequency against the sum of frequencies of all items it would displace. Its early pruning aborts the comparison once victims outweigh the candidate, which keeps admission constant-time. The paper reports this rule gives the best object hit ratio across ten production traces. We reuse the rule but replace frequency, which only counts past requests, with a value that reflects downstream task success.
Two things are new here. The first is the definition of an item's worth as its marginal contribution to retrieval-based decisions. A long trajectory that closely duplicates its neighbors is worth little even if its own success score is high. The second is a neighbor-based estimate of that marginal worth for items that have never been retrieved. This is what makes the eviction rule usable online.
Research Program
Let each stored item $i$ have token length $s_i$ and a learned utility $Q_i$, as in MemRL, updated by Monte Carlo averaging rather than the optimistic max. The max update is known to overestimate after lucky outcomes in stochastic settings (Model-Free Episodic Control).
Over a sliding log of recent queries $q$, let $\mathcal{R}_q$ be the retrieved set, and let $j(q,i)$ be the item that would have entered the prompt had $i$ been absent. The marginal value of $i$ is
$$\Delta_i = \sum_{q:\, i \in \mathcal{R}_q} \gamma^{t-t_q}\,\big(Q_i - Q_{j(q,i)}\big)^{+},$$
where $\gamma<1$ discounts old queries so that value tracks drifting task distributions and $(\cdot)^+$ keeps only positive differences. $\Delta_i$ is near zero when a comparable neighbor would have served just as well, which is how redundancy is penalized. It is large when $i$ is the only good match for a family of tasks.
A fresh candidate $c$ has no retrieval log. Its value is therefore estimated from the $k$ nearest stored items in intent-embedding space, as a similarity-weighted average of their $\Delta$, discounted by how much $c$ overlaps them. This is where non-parametric value estimation does real work: it predicts future utility density from neighbors in one step, without training anything.
Admission orders resident items by $\Delta_v/s_v$. It accumulates the lowest-density victims until their total size covers $s_c$, and admits $c$ only if $\Delta_c > \sum_v \Delta_v$, aborting early once that sum exceeds $\Delta_c$.
A second, lighter use of the same quantity applies at retrieval time. The prompt has its own token budget, so the retrieved items are packed into it greedily by marginal value per token rather than taking a fixed top-$k$.
We will build this as a drop-in memory manager on the public MemRL codebase. The analysis has three parts. First, we will measure how skewed trajectory lengths actually are on each benchmark. Second, we will characterize the budget regimes in which size-awareness matters. Third, we will study whether the neighbor-based estimate of $\Delta_c$ correlates with the realized $\Delta$ an item accumulates later.
Baselines
The do-nothing reference is MemRL with an unbounded memory and its default fixed-count retrieval. This gives the ceiling that any budgeted method tries to approach. Its reported +3.8% average CSR gain and +6.2% on ALFWorld over memory-free agents are the only published numbers (MemRL). There is no reported result found on Lacuna for MemRL, or for any episodic memory, under a token-capacity limit, so we will establish all budgeted numbers ourselves.
The naive bounded references are least-recently-used and first-in-first-out eviction over item counts. This is the policy of Model-Free Episodic Control, transplanted to trajectories and capped at the same token total.
The strongest existing competitor is MemRL's own utility used as a size-oblivious eviction score: evict the lowest-$Q$ item until the new one fits. This is the most natural thing a MemRL user would do, and it already uses task-success signals.
A second strong competitor is Greedy Dual Size Frequency, the classic size-aware caching heuristic. It is reviewed in Lightweight Robust Size Aware Cache Management, and we run it with $Q_i$ in place of frequency, ranking by $Q_i/s_i$ with aging. This competitor is already size-aware and value-aware, so beating it is the real test.
We also run Aggregated Victims with raw retrieval frequency as the value. This is the Einziger et al. rule exactly, and it asks whether task-success signals add anything over counts.
Two ablations isolate our ingredients. The first swaps $\Delta_i$ for $Q_i$ inside the aggregated-victims rule, which removes redundancy-awareness. The second swaps the neighbor estimate of $\Delta_c$ for a constant prior, which removes the non-parametric estimate.
All methods share the same base model, embedding model, benchmark task order, and seeds. They also share the same storage token budget and prompt budget, and receive the same small grid over their one or two hyperparameters (aging rate, $\gamma$, $k$), tuned on a held-out task split.
Beating the baselines means two things. The method must show higher CSR than the $Q/s$ Greedy Dual baseline at matched budget, averaged over budgets and seeds with non-overlapping confidence intervals. It must also reach 90% of unbounded-memory CSR at a smaller budget than any baseline.
Why not just…?
Why not just rank by utility divided by size, as Greedy Dual Size Frequency does? This is the most serious threat, and it may capture much of the gain on benchmarks where memories are rarely redundant. It ranks items one at a time, so it cannot see that ten near-duplicate long trajectories jointly deserve one slot. It also has no principled value for a never-retrieved newcomer. The ablation that replaces $\Delta$ with $Q$ inside our rule, together with the redundancy-injection experiment below, will show whether marginal value matters. If it does not, the honest conclusion is that size-weighted utility suffices, and we will report that.
Why not just summarize long trajectories so every memory is roughly the same size? Compression attacks the size heterogeneity directly, and it is a real alternative. It costs a model call per stored item, and it may strip the concrete details that make a retrieved trajectory useful. We will include LLM-summarized memories with MemRL-utility eviction as a baseline, and also combine summarization with our rule. If summarization plus naive eviction matches our method at equal budget, size-awareness is unnecessary on that benchmark.
Why not just partition memory into size buckets, each managed by least-recently-used eviction? Bucketing restores the uniform-size assumption inside each bucket. However, it fixes the split between short and long memories in advance, and static provisioning is known to fail when the popularity mix across size classes shifts (Cost-aware caching). Lifelong Agent Bench, which moves between operating-system and database tasks with different trajectory lengths, is the setting where this should show up. We run a three-bucket variant tuned on held-out tasks.
Why not just keep everything, since storage is cheap? Storage may be cheap, but prompt tokens and retrieval latency are not. Retrieval cost grows with bank size, as the episodic control literature notes (Semiparametric Reinforcement Learning). The unbounded baseline is therefore included, and the budget sweep will show where on the curve bounded memory stops costing success.
Proposed Experiments
The main experiment runs ALFWorld (ALFWorld), BigCodeBench, and Lifelong Agent Bench through the MemRL pipeline. Storage budgets are set at 5%, 10%, 25%, and 50% of the tokens the unbounded memory accumulates, each with a fixed prompt budget. We report cumulative success rate versus budget, the area under that curve, the fraction of retrievals whose item came from a successful episode, and wall-clock admission cost per task. BigCodeBench and ALFWorld were chosen because their trajectory lengths differ most.
The first decisive check is a heterogeneity sweep. We rerun the pipeline after truncating or padding stored trajectories to a common length, then gradually restore the natural length distribution. If our mechanism is right, the gap over MemRL-utility eviction should be near zero at uniform length and grow with the spread of lengths. A gap that stays flat would mean the gain comes from generic value-based pruning, not size-awareness.
The second decisive check injects near-duplicate trajectories, such as paraphrased reruns of solved tasks, into the stream. We expect $\Delta$-based admission to hold CSR steady while $Q/s$ ranking degrades.
The third check tests whether the neighbor-estimated $\Delta_c$ at admission predicts the realized $\Delta$ an item earns over its lifetime, reported as a rank correlation. A near-zero correlation would mean the non-parametric estimate adds nothing and the constant-prior ablation should match the full method.
As an implementation sanity check, we set value equal to request frequency and run the manager on the MSR and CDN traces from Lightweight Robust Size Aware Cache Management. There it should reproduce Aggregated Victims' hit-ratio ordering over LRU and Greedy Dual. That paper gives no per-trace numbers, so we will compare orderings, not values.
References
- MemRL: Self-Evolving Agents via Runtime Reinforcement Learning on Episodic Memory
- Model-Free Episodic Control
- Continuous Episodic Control
- Semiparametric Reinforcement Learning
- Lightweight Robust Size Aware Cache Management
- Cost-aware caching: Optimizing cache provisioning and object placement in ICN
- ALFWorld: Aligning Text and Embodied Environments for Interactive Learning