Locally Repairable Agent Memory

Long-running language model agents keep their context usable by summarizing. A helper model runs a tool, condenses the output into a short note, and throws the raw output away. This keeps the planning context clean, but it creates two failure modes that current systems cannot recover from cheaply. The first is that a summary turns out to lack a detail that becomes critical twenty steps later. The second is that a summary has absorbed a misleading web snippet and now states something false. Today the agent either re-runs the whole tool trajectory or carries on with bad state. Distributed storage faced a similar problem decades ago. Its answer was "local repair": when one stored block is lost, rebuild it from a small, pre-arranged group of neighbors by downloading only a small slice of each, instead of reading the whole file.

This note proposes building agent memory so that any single faulty memory entry can be rebuilt locally. Each distilled entry is written together with a small, fixed "repair group" of provenance fragments, meaning the raw evidence it came from and any independent sources that confirm it. Repair then works by asking those few fragments narrow questions and returning short answers, rather than re-reading archives or re-executing tools. The coding-theory lens also supplies a distinction that agent work lacks. A missing detail is an erasure: the agent knows where the gap is, and one helper suffices. A planted falsehood is an error: its location is unknown, and detecting or correcting it requires redundancy across independent sources. We expect the cost difference between the two to be measurable.

Core Claim

Hierarchical agent memory fails in two ways: over-compression, where a needed detail was dropped, and contamination, where a misleading claim was kept. Repairing either at the level of a single entry, from a write-time repair group of at most $r$ fragments, recovers most of the accuracy lost to these failures. It does so at a small fraction of the tokens spent by re-execution or by retrieving over the full raw log. Under injected misleading evidence, the number of independent supporting sources an entry needs should follow the coding pattern. One source suffices to fill an erasure. Two are needed to detect a contradiction. Three are needed to correct it by majority. This mirrors the fact that a code of minimum distance $d$ fills $d-1$ erasures but corrects only $\lfloor (d-1)/2 \rfloor$ errors.

We are not proposing to put finite-field erasure codes into agent memory. Storage loss is not the agent's problem, since raw logs are cheap to keep on disk. What transfers from coding theory is the accounting. Locality means how many sources a repair touches. Repair bandwidth means how much data the repair moves. Write-time design means arranging redundancy so that later repairs stay local.

Background and Positioning

The storage literature supplies the concepts. On Locality in Distributed Storage Systems and On locality in distributed storage systems. show how to arrange redundancy so a lost symbol is rebuilt from a few neighbors. Repairing Reed-Solomon Codes via Subspace Polynomials shows that helpers can return a projection of their content rather than the whole symbol. This reaches minimal repair bandwidth $(n-1)(\ell-m)\log_2 q$ bits for full-length codes. Its companion version, Repairing Reed-Solomon Codes via Subspace Polynomials, extends this to collaborative repair of two failures. We borrow three ideas from this work: fixed repair groups, narrow projections from helpers in place of full downloads, and the erasure/error distinction. We do not borrow the algebra itself, because these constructions work over static symbols and do not handle meaning-level corruption.

Hierarchical agent memory motivates the problem. HyMem splits an agent into three parts: a planner that sees only distilled notes, an executor that runs tools in a throwaway context, and a separate reasoning module. It folds history into structured Episode, Working, and Tool memories every fixed number of turns. HyMem itself acknowledges that distillation can drop details that later matter and that it degrades on smaller backbones such as Qwen3-32B. AgentFold folds web histories into compact episodic states before the context fills up. Bi-Mem builds hierarchical memory bidirectionally for personalization. None of these three keeps a recovery path from a summary back to its evidence. That missing recovery path is what we add, and we use HyMem as the host architecture. MemSecBench tracks memory poisoning from persistence to consequence and repair. It is the closest existing work, but it is a benchmark rather than a repair mechanism, and we plan to use it as an additional evaluation if its protocol permits.

The noise literature constrains the design. Thinking in a Crowd shows that explicit reasoning rationalizes misleading context rather than rejecting it. On SciAux, Qwen3-8B falls from 96.22% with no context to 77.03% with two misleading snippets in thinking mode. This rules out "let the planner reflect" as the error-correction step, so our contamination check compares independent sources instead of relying on the planner's own reasoning. Superposition Prompting processes documents in isolated parallel paths and prunes the less relevant ones. CompAct compresses documents in chunks and stops early when it emits [COMPLETE]. DAS adds an explicit "unanswerable" option and reweights answers by query likelihood. Each of these methods makes a one-shot, irreversible filtering decision. Our repair step reuses their isolation idea, since each helper fragment is queried in its own path, but makes the decision revisable.

Research Program

Every distilled memory entry $m_i$ is stored with a repair group $R_i$ of at most $r$ fragments. A fragment is a pointer to a raw tool-output span in an on-disk archive, or a separately retrieved confirming source. The group is chosen at write time by the executor while the raw evidence is still in its context. Repair is triggered in two ways. In an erasure trigger, the planner asks a sub-question that the entry cannot answer. The planner is prompted to emit a typed "missing-detail" request rather than guess, in the spirit of DAS's abstention option. In an error trigger, a new observation conflicts with an entry, or an entry with fewer than two independent supports is about to drive an irreversible action.

When repair fires, each helper fragment $j \in R_i$ is read by a small model in an isolated context with only the targeted question. It returns a short answer $a_j$, which plays the role of the "projection" a storage helper sends. We define the repair bandwidth as the number of planner-visible tokens the repair adds,

$$\gamma_i = \sum_{j \in R_i} |a_j|,$$

where $|a_j|$ is the token length of helper $j$'s answer. We report both $\gamma_i$ and the total tokens spent by helper calls. For errors, the patched entry is accepted only when the support count $s_i$ reaches the target. Here $s_i$ is the number of independent fragments in agreement, where "independent" means they come from distinct domains or distinct tool calls. A target of $s_i \ge 2$ triggers flagging, and $s_i \ge 3$ allows majority overwrite. If the existing group cannot reach the target, the repair widens the group by one retrieval and charges it to $\gamma$.

The work has three parts. First, a failure-attribution study of HyMem trajectories on GAIA and Browsecomp-plus. It labels each failed task as over-compression, contamination, or other, which tells us how much accuracy repair could possibly recover. Second, the memory system itself, built on HyMem. Third, a controlled noise-injection protocol. Misleading snippets, drawn in the style of SciAux's misleading category, are inserted into tool outputs at fixed rates. This lets us measure contamination repair directly, together with the predicted 1/2/3 support threshold.

Baselines

The naive reference point is HyMem without repair. Its folds and distillations are final, so a missing detail forces re-execution or a guess. On the 165 text-only GAIA tasks with DeepSeek-V4, HyMem reports 66.7% Pass@1. On its 150-task Browsecomp-plus subset it reports 61.3% overall and 30.0% on hard tasks. ReSum, the strongest summarization baseline on GAIA, reaches 60.6%, and ReAct reaches 56.6% overall and 14.0% on hard Browsecomp-plus tasks. HyMem is the strongest existing method in the file for long-horizon context management, and it is the system our mechanism modifies, so it is the main bar. We will rerun HyMem ourselves with the same backbone, tool set, and benchmark subsets instead of relying on the reported figures. Beating it means a statistically significant Pass@1 gain on both benchmarks at matched total token spend. Matched spend counts every auxiliary call, so a gain that comes only from spending more tokens does not count.

The second baseline is global repair: on any trigger, retrieve over the full raw-log archive with dense retrieval and hand the top passages to the planner. A third, re-execution, simply re-runs the relevant tool calls. A fourth plugs CompAct-style active compression into the executor's distillation step. That tests whether a better one-shot compressor removes the need for repair.

Three ablations isolate the key ingredients. The first keeps write-time repair groups but returns whole fragments rather than targeted answers, which isolates the bandwidth saving. The second asks targeted questions but chooses fragments by retrieval at repair time rather than fixing them at write time, which isolates locality. The third uses a single support source rather than an independent-support threshold, which isolates error correction.

All systems get the same tuning budget for prompts and thresholds, set on a held-out slice. We will run on DeepSeek-V4 and on Qwen3-32B, because HyMem reports degradation on the smaller model and repair may matter more there.

Why not just…?

Why not just keep the raw logs and run retrieval over them when something is missing? This is the real threat, and it is the global-repair baseline. Retrieval at repair time searches the whole trajectory, including every misleading or near-duplicate snippet the agent ever saw. The distraction results in DAS suggest that more candidate documents make the reader worse. Write-time groups avoid this because they point only at the evidence the entry actually came from. If global retrieval matches local repair in accuracy and tokens, particularly under noise injection, then locality buys nothing and we would scale the proposal back to "keep provenance pointers."

Why not just stop compressing and use a long context window? HyMem's own comparison answers much of this: flat-context ReAct reaches 14.0% on hard Browsecomp-plus tasks against 30.0% with isolation. Superposition Prompting reports that isolating documents rather than concatenating them gave a 43% accuracy gain on NaturalQuestions-Open. We include a full-context ReAct run for completeness but expect it to lose.

Why not just let a reasoning model check its own memory before acting? Thinking in a Crowd shows that reasoning mode amplifies misleading context instead of filtering it. That is why our error check counts independent sources rather than asking the planner to reflect. We test this directly with a "reflect-then-act" baseline on the noise-injected runs. If reflection matches multi-source support there, the coding-style redundancy is unnecessary.

Why not just use a better compressor so nothing important gets dropped? No compressor can know which detail a future step will need, and CompAct's early stop is irreversible by design. The CompAct-executor baseline measures how much of the over-compression failure a better compressor removes. Repair is justified only for the remainder.

Proposed Experiments and Decisive Checks

The first check comes before any building. If the failure attribution shows that over-compression and contamination together explain only a small fraction of HyMem's failures on GAIA and Browsecomp-plus, the upper bound on gains is low and we stop.

The main experiment compares all systems at matched total tokens on GAIA text tasks and the Browsecomp-plus subset. We report Pass@1, planner-context tokens, $\gamma$ per repair, re-execution count, and latency, on both backbones. The noise experiment sweeps the misleading-injection rate. It plots accuracy against the support threshold (1, 2, or 3 independent sources) separately for injected-erasure tasks, where a gold detail is removed from the summary, and injected-error tasks, where a false claim is planted. The coding analogy predicts that erasure accuracy saturates at one helper while error accuracy needs three. A flat curve would falsify the erasure/error distinction.

To isolate the error-correction component without agent dynamics, we run SciAux (billhdzhao/SciAux) with each snippet treated as a memory entry. The reference points are Qwen3-8B's reported 77.03% (thinking on) and 74.87% (thinking off) with two misleading snippets, against 96.22% with no context. Success means closing most of that gap with independent-support checking.

A secondary test moves to the multimodal setting, where the critical memory entry is the visual entity's identity. On INFOSEEK-Human, the INFOSEEK study reports CLIP+FiD at 18.2% and oracle entity identification at 45.6%. EntRAG reports 44.5 on a 100k-entity InfoSeek subset and 46.1 on Encyclopedic VQA. Here the repair group for the entity entry consists of independent recognition routes: image-to-entity matching, caption-derived candidates, and text from the question. We test whether flagging low-support identities and repairing them before retrieval moves a pipeline toward the oracle number. Because those figures use different splits and knowledge bases, we will rerun EntRAG on whatever split we use rather than compare across splits.