Manuscript Offprint

arXiv:2610.21170

MemScope: Evolving Agent Memory Architectures through Localized Code Repair

Miao Su, Yucan Guo, Zixuan Li, Long Bai, Zhongni Hou, Xiaolong Jin, Jiafeng Guo

ABSTRACT

Agent memory architectures define how LLM agents store and reuse experience across tasks, but they are typically fixed after deployment, limiting their adaptability across task types. Recent self-evolving approaches instead adapt these memory architectures using execution feedback, typically represented as evaluation scores or compressed summaries. However, such coarse-grained feedback is insufficient for precise failure localization in current agent systems, where long-horizon task execution involves multiple interacting components. Without a precise failure location, existing approaches lack a clear code-level target for modification, leaving the update scope weakly constrained and often leading to large-scale rewrites of an otherwise capable memory architecture. We propose MemScope, a framework for evidence-grounded, localized evolution of an existing memory architecture. Its tool-using Patch Agent jointly inspects raw execution traces, runtime memory state, and current architecture code to identify repair targets and apply bounded, in-place edits under provider-identity and memory-compatibility constraints. On GAIA, the trace-and-memory inspection variant achieves 86.67% accuracy, compared with 70.00% for trace-only and 63.33% for summary-only feedback. Under xBench tasks, the evolved memory architecture improves over its original version from 49 to 55 correct answers with DeepSeek V3.2 and from 50 to 53 with Kimi K2.7 Code. On disjoint ALFWorld unseen tasks, success rises from 50.75% to 71.64%. Across archived architecture-snapshot transitions, the median code-change ratio is 4.4%. These results support fine-grained execution evidence as a basis for localized, in-place memory-architecture evolution.

1 INTRODUCTION

An LLM agent combines a language model with an agent harness that manages tool use, context construction, execution control, and memory (Weng, 2026; Lee et al., 2026; Zhang et al., 2026b; Lin et al., 2026b). Within this harness, the memory architecture implements reusable decisions about what experience to store, how to retrieve it, and how to present it to the agent (Zhong et al., 2024; Chhikara et al., 2025; Wang et al., 2025; Du et al., 2025). Most existing architectures remain fixed after deployment even as agents encounter open-ended tasks with different memory demands. This motivates adapting not only the contents of memory, but also the executable mechanisms that manage them.

Recent approaches use execution outcomes to evolve agent memory, but differ in what they allow to change. Some update the experience retained by the agent while leaving the executable logic for storage, retrieval, and presentation fixed (Shinn et al., 2023; Liu et al., 2025; Fang et al., 2026; Ouyang et al., 2026b; Zhang et al., 2026c;d). Such content-level updates cannot directly correct failures caused by the logic itself. Architecture-level methods instead make the executable memory architecture mutable, allowing evolution to modify the code that determines what is stored, how it

(a) Architecture-Level Evolution

Current Memory Architecture

Figure

(b) MemScope: Localized Update

Current Memory Architecture

Evolved Memory Architecture

Figure 1: Feedback and update granularity in memory-architecture evolution. Prior architecture-level approaches use outcome-level feedback to propose complete executable architectures. MemScope makes the repair target explicit by jointly inspecting execution traces, runtime memory state, and provider code, then applies a localized, in-place edit to the existing provider. In the illustrated update, only the highlighted code region is modified.

is retrieved, and how retrieved information is presented (Zhang et al., 2026a; Xiong et al., 2026a). This shifts the evolution target from memory contents to the mechanisms that operate on them.

We focus on a complementary problem: identifying where an existing memory architecture should change. Evaluation scores and compressed summaries do not directly connect an observed failure to a specific implementation region. In long-horizon execution, this connection is difficult because behavior depends on interactions between stored experience, retrieval decisions, and downstream agent actions. Figure 1 contrasts complete-architecture proposals driven by outcome-level feedback (Xiong et al., 2026a; Zhang et al., 2026a) with evidence-grounded identification of a local repair target.

Consider an agent that fails to receive useful memory guidance. The relevant experience may be absent from memory, excluded by retrieval filtering, or bypassed by an early-return code path. These explanations suggest different interventions; a failure may also arise after suitable guidance has already been delivered and require no provider change. Inspecting raw traces, runtime memory state, and current code can help distinguish these cases. We therefore investigate whether fine-grained execution evidence can support targeted, in-place updates to an existing memory architecture.

To study this question, we introduce MemScope, a framework for evidence-grounded, localized evolution of agent memory architectures. An Agent Executor performs tasks with the active architecture, while a tool-using Patch Agent inspects execution evidence between task segments. Each architecture is packaged as a reusable memory skill with a natural-language SKILL.md file and an executable provider, separate from its runtime memory bank (Anthropic, 2025). When repair is triggered, the Patch Agent examines successful and failed raw traces, stored memories and retrieval decisions, and current provider code to identify a candidate repair region. It then proposes exact old-to-new replacements under a local-update contract that preserves provider identity and requires compatibility with existing memory records. A patch that passes local checks is installed for subsequent execution, retaining the runtime memory bank; insufficient evidence can instead lead to a no-patch decision.

Under DeepSeek V3.2, MemScope + Flash-Searcher reaches 83.64% accuracy on GAIA validation and 78% on complete xBench, compared with 67.88% and 70% for MemEvolve + Flash-Searcher; MemScope's complete xBench score with Kimi K2.7 Code is 74%, and a separate matched-start comparison favors the evolved DynamicCheatsheet over the original with both DeepSeek (55/70 versus 49/70) and Kimi (53/70 versus 50/70). On ALFWorld, unseen-task success after the same online-memory collection is 71.64% for MemScope versus 50.75% for the original DynamicCheatsheet, while the GAIA diagnostic ablation yields 86.67% for trace-and-memory inspection versus 63.33% for summary-only feedback. Across 14 archived provider transitions, the median code-change ratio is 4.4%.

Our contributions are:

• We introduce an evidence-grounded repair interface that jointly exposes raw execution traces, runtime memory state, and provider code, making failure localization an explicit step in the evolution of an existing memory architecture.

• We develop MemScope to turn the resulting diagnosis into bounded, in-place code edits under provider-identity and memory-compatibility constraints. Across 14 archived provider-snapshot transitions, the median code-change ratio is 4.4%.

• In the GAIA diagnostic ablation, trace-and-memory inspection yields 86.67% accuracy versus 63.33% for summary-only feedback. Matched-start xBench comparisons favor the evolved provider under both backbones, and ALFWorld unseen-task success improves from 50.75% to 71.64% after a common memory-collection sequence.

References (66)