MESA:Task-Adaptive Multi-Structure Evidence Selection for Long-Horizon Agent Memory
MESA selects complementary memory structures per query, reaching 65.1% on AMA-Bench with 41% fewer evidence tokens.
Key Findings
Methodology
MESA builds five views of each trajectory: text summary, temporal store, knowledge graph, vector database, and raw episodic trace. A selector Sρ(q,c) outputs one of 31 non-empty binary subsets z∈{0,1}5; selected interfaces Γk retrieve evidence, Compose fuses it, and a frozen answer model F responds. Without subset labels, MESA learns from answer-level feedback through prior-guided harness optimization and UCB scheduling.
Key Results
- On 2,496 AMA-Bench questions with Qwen3-32B, MESA achieves 65.1±0.8% accuracy, exceeding AMA-Agent at 56.6% by 8.5 percentage points and long-context reading at 52.6% by 12.5 points.
- MESA reaches 69.2% on Recall, 65.8% on State Updating, and 57.8% on State Abstraction. Its 63.6% on Causal Inference is 1.4 points below AMA-Agent's 65.0%, showing uneven gains.
- Evidence falls from about 18.7k tokens for all-structure fusion to 11.0k for MESA, a 41% reduction, while accuracy rises from 63.7% to 65.1%. Gemma-4-31B yields 69.4%; LoCoMo reaches 49.0 F1.
Significance
The paper reframes memory reading from “retrieve everything” or “route to one source” as query-adaptive composition. This addresses buried evidence, heterogeneous information, context distraction, and inference cost in long-horizon agents. Academically, it defines structure-level dynamic selection as a distinct research problem. Practically, it shows that a frozen answer model can gain accuracy and efficiency when the system learns which memory views to combine.
Technical Contribution
MESA treats a representation and its access interface as one memory structure, then searches the 31-subset action space. Its objective is J_D(ρ)−λC_D(ρ), explicitly trading answer quality against evidence tokens. Starting from the all-structure policy ρall, an LLM proposer creates exploitation, exploration, and failure-repair candidates. UCB(a)=Ĵval(a)+β√(log(N+2)/(na+1)) schedules prior directions, enabling executable policy search under sparse answer-level supervision.
Novelty
Unlike Hindsight's fixed parallel fusion, StructRAG and Learning-to-Route's single-source routing, and S3Mem's within-schema evidence selection, MESA preserves heterogeneous structures and their access patterns while learning a complementary query-specific subset. Its fundamental novelty is optimizing the discrete composition of memory structures from end-to-end answer feedback, rather than merely adding multiple indexes or selecting individual memory items.
Limitations
- The selector depends on hand-designed prior directions, an LLM proposer, and 30 search iterations; sparse answer-level rewards make it difficult to identify the marginal contribution of each structure.
- Experiments focus on AMA-Bench's real-world subset and LoCoMo, with builders, retrievers, composers, and answer models largely fixed; online, multilingual, and cross-model generalization remain uncertain.
- Exact λ, β, prompts, and schema details are relegated to the appendix, so reproducibility and cost may be sensitive to implementation choices.
Future Work
Future work should explore differentiable or counterfactual credit assignment, online incremental memory, uncertainty-aware routing, and joint control of retrieval depth, ranking, and fusion. Evaluation should expand across environments, languages, and open models, while reporting latency, GPU cost, privacy, and memory contamination. These tests would determine whether MESA remains reliable under distribution shift and production constraints.
AI Executive Summary
Long-horizon agents accumulate hundreds of interleaved reasoning, action, observation, and tool-use steps. A later question may depend on a detail buried far back in the trace. Reading the entire trajectory is expensive and noisy; compression can delete decisive facts. Existing hybrid systems usually read a fixed collection of memories, while routing systems often select only one, sacrificing complementary evidence.
MESA—Multi-structure Evidence Selection for long-horizon Agent—builds five views of every trajectory: summary, temporal store, knowledge graph, vector database, and raw episodic trace. Its selector maps each query to one of 31 non-empty subsets, retrieves through the corresponding interfaces, and composes the evidence for a frozen answer model. Prior-guided harness optimization proposes executable policies, while UCB scheduling balances promising directions against underexplored ones. A validation objective combines accuracy and token cost.
On 2,496 AMA-Bench questions, MESA reaches 65.1% with Qwen3-32B, versus 56.6% for AMA-Agent and 52.6% for long-context reading. It uses about 11.0k evidence tokens rather than 18.7k for all-structure fusion, reducing evidence by 41% while improving accuracy from 63.7% to 65.1%. Gemma-4-31B gives 69.4%, and LoCoMo gives 49.0 F1. The central lesson is that the best memory is usually a task-dependent combination—not one structure and not everything. Weak supervision, fixed components, and limited benchmarks remain important caveats.
Deep Analysis
Background
MemGPT pages information in and out of working context; Generative Agents and Reflexion use reflection; HippoRAG2 and Hindsight exploit graph, vector, or multi-network memory. Agent trajectories, however, interleave reasoning, actions, observations, and tools with temporal and causal dependencies. Summaries preserve global context but lose steps; vector retrieval may find semantically similar but irrelevant fragments; graphs lack step ordering; raw traces preserve detail but create noise.
Core Problem
Given trajectory τ, query q, and observable context c, the system must select a non-empty subset of five structures rather than always reading all or routing to one. The action space has 2^5−1=31 choices. Complementary views improve coverage, whereas redundant or mismatched views increase distraction and token cost. No gold subset or per-structure utility label exists, so learning must rely on sparse end-to-end answer feedback.
Innovation
MESA contributes four ideas: a formal structure-level selection problem; preservation of heterogeneous representations and dedicated access mechanisms; answer-level optimization of an executable selector; and a cost-regularized objective J−λC. Prior directions bias the search toward meaningful routing mechanisms, while UCB scheduling allocates trials between exploitation and exploration. This differs from fixed fusion, single-source routing, and selection inside one unified schema.
Methodology
- �� Build: apply builders Bk to τi, producing Summary, Temporal, Graph, Vector, and Raw memories.
- �� Select: compute z=Sρ(qi,ci), where z∈{0,1}5 and ||z||0≥1.
- �� Retrieve: invoke Γk only for selected structures and compose Ei(z).
- �� Answer: use frozen F to produce ŷ=F(q,E).
- �� Optimize: initialize with ρall; an LLM proposer generates exploitation, exploration, and failure-repair candidates, fits them on training traces, and scores validation.
- �� Schedule: use UCB(a)=Ĵval(a)+β√[log(N+2)/(na+1)]; return the archive policy maximizing validation accuracy minus λ times token cost.
Experiments
AMA-Bench contains 208 real-world episodes and 2,496 questions across Web, Open-World QA, Text2SQL, Software, Gaming, and Embodied AI, plus four memory capabilities. LoCoMo contributes 1,540 non-adversarial questions. Baselines include Long-context, BM25, Qwen3-Emb-4B, MemGPT, HippoRAG2, Mem0, MemoRAG, A-Mem, EMem, Hindsight, and AMA-Agent. AMA uses LLM-judged accuracy; LoCoMo uses F1. AMA splits episodes 2:2:6, repeats five times, and runs 30 optimization iterations.
Results
With Qwen3-32B, MESA scores 65.1%, compared with AMA-Agent's 56.6% and long-context's 52.6%. It leads on Recall (69.2%), State Updating (65.8%), and State Abstraction (57.8%), while Causal Inference reaches 63.6% versus AMA-Agent's 65.0%. With Gemma-4-31B, MESA reaches 69.4% versus 63.0%. Domain gains over the strongest baseline include 15.5 points in Software and 8.9 in Text2SQL. LoCoMo F1 is 49.0, above MemGPT's 46.8 and EMem's 47.2.
Applications
The method suits debugging agents, Text2SQL systems, web automation, tool-using question answering, and embodied agents. Before deployment, teams must build the five indexes, expose stable retrieval interfaces, and optimize the selector on representative trajectories. The immediate benefit is lower context length, latency, and inference cost, while reducing irrelevant evidence that can mislead the answer model.
Limitations & Outlook
The approach assumes that five useful structures and their access mechanisms are known in advance; it cannot automatically invent new views. LLM proposal and UCB search require repeated validation and GPU resources. Causal Inference still trails AMA-Agent, suggesting that selection alone does not guarantee long causal-chain reconstruction. The paper gives limited analysis of latency, construction cost, λ/β sensitivity, privacy, and memory contamination. Online learning, attribution, adaptive budgets, and broader environments are natural next steps.
Plain Language Accessible to non-experts
Imagine an investigator with five filing cabinets for the same case. One contains a summary, one sorts events by date, one connects people and objects, one finds similar notes, and one stores every original action. Looking in only one cabinet can miss the clue; opening all five creates piles of repeated paperwork.
MESA is a smart records clerk. When asked, “Which step first showed that the bug could not be reproduced?”, it may open the timeline and the original log. When asked who was connected to the bug, it may add the relationship cabinet. The clerk learns from whether previous answers were right, gradually discovering which cabinets work well together for each kind of question.
In AMA-Bench, it answered correctly 65.1% of the time, compared with 56.6% for AMA-Agent, while using 41% fewer evidence tokens than reading every cabinet. The lesson is simple: carefully chosen information can beat an overwhelming information dump.
ELI14 Explained like you're 14
Imagine you played a game for hundreds of moves, then someone asks, “When did you first notice that the Bug could not be reproduced?” The answer might be hidden twenty minutes ago. Rewatching everything is slow and confusing; watching only the ending misses the important clue.
MESA gives the agent five memory tools: a story recap, a timeline, a connection map, a search box for similar moments, and the complete action log. It does not always open every tool, and it does not permanently trust one tool. It looks at the question and picks a useful team of tools.
Then it learns like a student checking homework. If a team helps produce a correct answer, it tries similar teams more often; if the answer fails, it repairs the strategy. UCB helps it balance “use what worked” with “try something new!”
On AMA-Bench, MESA scored 65.1%, while AMA-Agent scored 56.6%, and it used 41% fewer evidence tokens. Pretty cool—but tricky cause-and-effect questions can still fool it, and training the selector takes many tests.
Glossary
Long-horizon agent memory
Persistent information that lets an agent use evidence from many earlier interaction steps. Technically, it organizes trajectories beyond the active context window.
The paper studies efficient access to such memory.
Memory structure
A representation together with its dedicated access mechanism. Different structures retain different aspects of the same history.
MESA uses Summary, Temporal, Graph, Vector, and Raw structures.
Structure-level selection
Choosing one or more memory structures for a query instead of selecting only individual records. With five structures, MESA has 31 non-empty actions.
This is the paper's formal problem.
Harness optimization
Searching over executable system policies rather than merely rewriting a prompt. It can modify routing logic while leaving retrieval and answering components fixed.
MESA uses an LLM proposer to generate selector policies.
Upper Confidence Bound (UCB)
A bandit rule that rewards both strong historical performance and limited exploration. It prevents search from prematurely committing to one direction.
UCB schedules prior-guided policy-generation directions.
AMA-Bench
A benchmark of long agent-environment trajectories and expert-curated questions. The reported real-world subset has 208 episodes and 2,496 questions.
It is MESA's main evaluation dataset.
Open Questions Unanswered questions from this research
- 1 How can answer-level rewards reveal the causal, marginal value of each structure? Counterfactual retrieval and finer-grained credit assignment are needed.
- 2 It remains unclear whether the five structures transfer across languages, models, and online environments under distribution shift.
- 3 Accuracy and token cost are reported, but latency, GPU energy, privacy, and memory contamination need systematic measurement.
Applications
Immediate Applications
Software engineering agents
Build separate summary, timeline, graph, vector, and raw-log indexes for debugging traces. Route first-reproduction questions toward temporal and raw evidence, and dependency questions toward graph evidence, reducing context noise and improving fault localization.
Enterprise tool and knowledge assistants
Store audit logs, entity relations, time-stamped events, and semantic passages separately. MESA can select structures for compliance, state-update, or workflow questions, lowering retrieval noise and language-model input costs.
Long-term Vision
An adaptive memory operating system
Future agents could learn online how to store, retrieve, rank, and fuse memories while allocating a query-specific budget. Major obstacles include safety, privacy, stability, transfer across tasks, and protection against corrupted long-term memory.
Abstract
Long-horizon agents accumulate trajectories spanning hundreds of interleaved reasoning, action, and observation steps, where answering a query may depend on evidence buried far back in the history. External memory stores such trajectories as structured representations, yet each structure provides a distinct and incomplete view. Existing multi-memory systems either read a fixed set of structures for every query, inflating context and introducing noise, or route each query to a single structure, preventing the composition of complementary evidence. A controlled analysis on AMA-Bench shows that the optimal memory configuration is typically neither a single structure nor the full union, but a tailored composition of multiple structural memories that varies with query and task demands. Motivated by these findings, we formulate structure-level dynamic selection: selecting and fusing a query-adaptive subset from a library of specialized memory structures. We propose MESA (a Multi-structure Evidence Selection framework for long-horizon Agent), which builds five complementary structure views of each trajectory and learns from end-to-end answer-level feedback to select and fuse a query-specific subset for a frozen answer model. To learn under this weak supervision, MESA employs harness optimization with prior-guided search and UCB-guided scheduling to balance exploration and exploitation. On AMA-Bench, MESA outperforms the strongest baseline by 8.5% while using 41% fewer evidence tokens than the all-structure alternative.