Manuscript Offprint

arXiv:2610.24955

MemPrice: Online Memory Allocation via Adaptive Pricing for Long-Horizon Agents

Yiming Zong, Shiyuan Piao, Jiashuo Jiang, Fugee Tsung

ABSTRACT

Long-horizon LLM agents face a fundamental allocation problem as interaction histories grow: which information to retain, how much context to devote to it, and at what granularity. Existing memory mechanisms largely focus on relevance, retrieval, or compression, leaving this allocation trade-off implicit. We introduce MEMPRICE, which treats active context as a shared resource and dynamically allocates it across memories and representation levels. MEMPRICE turns accumulated memory pressure into an adaptive price on context, encouraging detail only when its estimated retention value justifies the additional footprint. This pressure persists across memory refreshes, allowing the contents of memory to evolve while preserving long-run control over context usage. We show that irreversible compression can force linear worst-case regret against hindsight following its own memory trajectory, and introduce a same-state benchmark to evaluate allocation on MEMPRICE's realized memory states. MEMPRICE enforces the hard context budget at every round and regulates long-run occupancy through adaptive pricing, without prior knowledge of the interaction horizon. Under priced-frontier regularity, its average allocation-regret bound against this benchmark vanishes when accumulated estimation error is sublinear. We evaluate the framework under matched memory budgets on LongMemEval, LoCoMo, AppWorld, and WebShop across three foundation models, spanning both query-blind memory construction and goal-directed agent context management. The complete experimental code and reproduction scripts are available in our anonymous repository at https://anonymous.4open.science/r/ICLR2027-MemPrice.

1 INTRODUCTION

Foundation models are increasingly deployed as long-horizon agents that reason, act, and interact over extended trajectories (Yao et al., 2023; Shinn et al., 2023). As these interactions grow, the accumulated history can quickly exceed the active context available to the model, making memory management a central component of agent design. Existing systems address this challenge through persistent memory, hierarchical storage, retrieval, summarization, and adaptive context construction (Park et al., 2023; Packer et al., 2023; Xu et al., 2025). More recent methods further predict which past information will matter for upcoming decisions or dynamically compress interaction trajectories to control context growth (Wei et al., 2026; Ye et al., 2026). Together, these advances substantially improve an agent's ability to operate beyond a fixed context window.

However, most existing approaches formulate memory management primarily as a problem of retrieval, relevance estimation, or compression, leaving the underlying allocation of context capacity largely implicit. Knowing that a memory is relevant does not determine whether it is worth the space it consumes: a detailed record may provide only slightly more value than a compact summary while occupying substantially more context, and retaining one item necessarily reduces the capacity available to others. Similarity, importance, or predicted relevance scores therefore do not directly capture the opportunity cost of memory occupancy. Moreover, this trade-off changes over time as new information arrives and the user's informational needs evolve. Once information has

∗^{*}Equal contribution.

†^{\dagger}Corresponding author.

been compressed or discarded, early allocation mistakes may also be irreversible until the memory is refreshed. We argue that these effects are better understood by treating active context explicitly as a limited resource: rather than only asking what information is relevant, an agent must decide which information deserves memory, at what granularity, and at what cost.

To this end, we introduce MEMPRICE, a memory-allocation framework that makes the opportunity cost of active context explicit. Each memory can be retained at multiple levels of detail, while a persistent virtual queue turns accumulated occupancy pressure into a shared price on context. MEMPRICE then jointly chooses representations under the hard context budget, retaining finer detail only when its estimated retention value warrants the additional footprint. Crucially, the queue persists across memory refreshes, so retrieval can change what is brought back into context without erasing the resource pressure accumulated over the interaction. Irreversible compression changes which representations remain available, so hindsight may benefit from having preserved different information, not just from better allocation. We therefore evaluate allocation on MEMPRICE's realized memory-state trajectory, while still allowing hindsight to redistribute occupancy across time. MEMPRICE always satisfies hard capacity and, under bounded utilities and estimation error, drives excess average occupancy to zero without knowing the interaction horizon. Under priced-frontier regularity, its average-regret bound against this same-state benchmark also vanishes when estimation error accumulates sublinearly. We evaluate the framework under two complementary regimes: Query-Blind Memory, where the eventual question is revealed only after a long interaction, and Goal-Observable Memory, where the target is known from the outset and relevant evidence must be accumulated over time. Our main contributions are:

• We formulate long-horizon agent memory management as an explicit online resource-allocation problem, and propose MEMPRICE, which combines capacity-feasible representation selection with persistent memory pricing to adapt allocation over time while decoupling semantic refresh from resource accounting.

• We prove a linear worst-case regret lower bound against independent-state hindsight and introduce a same-state benchmark. Under stated assumptions, MEMPRICE admits regret bounds with explicit estimation-error and priced-frontier terms, and O(T)O(\sqrt{T}) cumulative occupancy violation.

• We evaluate memory allocation under two complementary settings: Query-Blind, where future information needs are unknown during memory construction, and Goal-Observable, where the task goal is known from the outset and can guide evidence accumulation. Our method achieves strong results in both settings.

Relation to prior work. Long-horizon agents often rely on persistent memory to preserve and recover useful information over time (Shinn et al., 2023; Park et al., 2023; Packer et al., 2023; Chhikara et al., 2025; Xu et al., 2025). Recent work further adapts the contents and granularity of working context through trajectory folding and relevance-aware context construction (Sun et al., 2025; Ye et al., 2026; Wei et al., 2026). We view active context as a shared resource and formulate memory management as an online allocation problem across competing memories and representation levels, connecting agent memory to online resource allocation and long-term constrained optimization (Devanur & Jain, 2012; Agrawal et al., 2014; Jenatton et al., 2016; Yu et al., 2017; Zong & Jiang, 2026). MemPrice realizes this view through adaptive pricing and persistent resource accounting across memory refreshes. A detailed discussion of related work is provided in Appendix A.

References (43)