Manuscript Offprint

arXiv:2610.33274

FlexA-Mem: Budget-Adaptive Agentic Memory for LLM Agents

Wujiang Xu, Jiaojiao Han, Xi Zhu, Qizheng Zhang, Kaiqu Liang, Yutong Yin, Kai Mei, Dimitris N. Metaxas

Abstract

Large language model (LLM) agents work in scenarios with very different memory needs. A question about past conversations needs the exact facts it names, while a multi-step task needs a trace of the steps already taken together with details that the next step cannot name. Existing memories are each designed and tested for one kind of scenario. Retrieval memories such as A-Mem miss steps that the current query does not express, summaries drop exact strings, and pairing the two fixes the split of the budget in advance. We propose FlexA-Mem, a general memory that writes each unit of history once into an immutable store and renders a fresh memory for every call. The rendered memory is a compact timeline of records plus detail that a fixed rule fits into the remaining room without an LLM call. The detail is either relevant units as raw text or excerpts or the verbatim pieces that best match the query. With one store, FlexA-Mem serves both kinds of scenario. On AppWorld challenge tasks at 4k, it outperforms the second-best method by 11.5%, and on 147 unused tasks with predictions fixed in advance it outperforms A-Mem with a summary by 12.2%. On LongMemEval and LoCoMo, it matches a dedicated keyword retriever that writes no memory, while memories built on text written by an LLM fall far behind at tight budgets. Ablations show that the timeline carries AppWorld completion, whereas recovery mainly saves steps there and decides accuracy on exact facts. Code is available at https://github.com/WujiangXu/Flex-Amem.

1 Introduction

Large language model (LLM) agents now work in many settings. They call the APIs of apps (Trivedi et al., 2024), resolve software issues by editing and testing code (Jimenez et al., 2024; Yang et al., 2024), and answer questions about conversations held over dozens of sessions (Wu et al., 2025a). In each setting the history soon outgrows a single call, and models use the middle of a long context less reliably (Liu et al., 2024). Therefore, each call works under a fixed token budget, and memory decides what fills it.

What should fill the budget depends on the scenario. A question about a past conversation usually names its evidence and depends on a few exact facts, such as a date mentioned weeks before. A multi-step task depends first on an overview of what the agent has done. An AppWorld agent that sends money must log in, list the APIs and read their documentation, and if these steps leave its context it starts them again. It also needs exact details that change from step to step, such as an API argument or an earlier output. Some calls need all of a few past units, and others need a little of every past unit.

Existing memories are each designed for one of these needs and tested on benchmarks of the matching kind. Retrieval memories such as A-Mem (Xu et al., 2025a) return the notes closest to the query, which suits fact recall, but an agent asked to send money has no reason to search for its earlier login. Compaction replaces old observations with placeholders or an LLM summary (Wang et al., 2025c; Lindenbauer et al., 2025), which keeps an overview of a long trajectory but drops the exact strings a fact question asks for. Summary+A-Mem combines the two with a fixed split of the budget, and MemGPT and Sculptor leave hidden details to tools (Packer et al., 2023; Li et al., 2026a) that agents rarely call (Fan et al., 2026; Li et al., 2026b). As a result, each method works well in its own scenario but loses much of its strength in the other.

A memory that generalizes across scenarios is hard to build because the right balance between overview and detail is not known when the history is written (Figure 1). It depends on the scenario, on the step within a task and on the budget of the call. Nor can the query alone settle it. With its task and latest steps as the query, keyword matching finds

Figure

Figure 1: Retrieval suits fact recall but loses the trace of a multi-step task, a summary keeps the trace but loses exact facts, and FlexA-Mem serves both needs within a single token budget.

the details an AppWorld agent needs no better than chance. For this reason, a memory that commits at write time, by summarizing, by evolving notes or by fixing a split, is tuned to one scenario by construction. The decision has to be made at every call, and it must stay cheap, because an agent calls the model at every step.

To this end, we propose FlexA-Mem, a general memory that writes each unit of history once and renders it anew at every call. The store keeps the raw text of every unit, and each rendering shows a timeline of short records that does not depend on the query. It fills the remaining room with recovered detail by a fixed rule, without an LLM call. Our contributions are summarized as follows.

• We introduce a write-once, render-per-call design for agent memory. It stores every unit of history immutably and decides only at read time how much of each unit a call sees. Nothing is discarded before the scenario, the query and the budget are known.

• We propose fit-or-degrade, a budget-aware renderer that needs no LLM call. It gives each relevant unit the highest resolution that fits, raw text, an excerpt or its record, and turns more units into excerpts as the budget shrinks. As a drop-in renderer it raises the AppWorld completion of A-Mem’s own notes by 10.7%.

• We show that one store serves both kinds of scenario. FlexA-Mem outperforms the second-best method by 11.5% on AppWorld challenge tasks and the strongest baseline by 12.2% on 147 unused tasks, and on fact recall it matches a dedicated keyword retriever. In our ablations the timeline carries agent completion, while recovery saves steps there and decides accuracy when the answer is an exact fact.

References (73)