betaFeedback

WorksComputer Science

Many Steps into One: Reasoning Contraction and the Limits of Safe Memory Reuse for LLM Agents

Abstract

Thought templates, skill libraries, agent memories and caches turn many reasoning steps into one. We call this reasoning contraction. A contracted memory saves reasoning steps and errors until its facts change, then quietly answers wrong. Most systems trust memories by counting successes and failures. We prove that such counters are badly tuned change detectors: a symmetric counter notices a partial change only after a power of its false-alarm horizon, and an unclipped one may never notice it. On five LLMs answering multi-hop questions over edited facts, ExpeL- and ACE-style counters serve 7.0-13.5x more stale answers than certified memories given the same information, and on code tasks with an exact verifier 35-73x more. Safety also has a price. When facts change and each memory is judged only by its own verified outcomes, one number, the certification load, sets how much reasoning any safe memory can skip, and under Zipf demand it yields a scaling law. Our recipe weighs each memory's failures by its own likelihood ratio, certifies its utility against live reasoning, and restarts the certificate when facts change, with the likelihood-ratio detector as the safety net for unannounced changes; for large edits it also invalidates the memory.

Introduction

Everyone builds reasoning memories. Thought templates (Yang et al., 2024a), reasoning and workflow memories (Ouyang et al., 2026; Wang et al., 2025b; Suzgun et al., 2026), behavior handbooks (Didolkar et al., 2025), skill libraries (Wang et al., 2024a, 2025a), answer caches (Bang, 2023; Schroeder et al., 2026), and the memories that agents share (Zhang et al., 2025a) or rewrite themselves from (Zhang et al., 2026a) all do one thing: they compile a derivation of m≥2m \ge2 steps into a one-step contracted memory for later instances of the problem. We call this reasoning contraction. Trusting such a memory is a sequential test, bound by the limits of change detection and certification.

Live reasoning is costly and fragile. LLM reasoners buy accuracy with computation: voting over sampled chains (Wang et al., 2023), tree search (Yao et al., 2023a), tool calls (Yao et al., 2023b) and self-critique (Shinn et al., 2023; Madaan et al., 2023). Every step is another chance to err. On the unedited facts of our multi-hop benchmark, Qwen3-8B’s live accuracy falls from 0.63 at two hops to 0.31 at three and 0.19 at four (Appendix D). A verified contracted memory answers in one step; on our edited streams it raises Qwen3-8B’s accuracy from 0.379 to 0.648 with fewer calls (Table 3). The price is a new failure mode shared by all these systems: when the facts behind a memory change, it keeps answering, wrongly. This is the utility problem of macro learning (Minton, 1990), now for LLM memories over changing facts.

Memories are trusted by counters, which are badly tuned change detectors. ExpeL and ACE vote memories up and down (Zhao et al., 2024; Zhang et al., 2026b), and validation-gated memories clip a Hebbian strength (Singh and Yu, 2025). Every clipped counter is a cumulative-sum (CUSUM) change detector in disguise, testing an implied change that nobody chose (Section 3). A symmetric counter assumes that a stale memory is as often wrong as a fresh one was right, so counting votes equally is provably the wrong detector for partial staleness: when an edit leaves a memory failing less than half the time, the counter’s evidence drifts the wrong way, and its delay grows as a power of its false-alarm horizon, not its logarithm (Theorem 1, Figure 1b). Unclipped counters are worse: credit banked while the memory was healthy must be spent before retirement. On KQA-STREAM, multi-hop questions over controlled knowledge-base edits, ExpeL- and ACE-style counters leave about half of the same 156 stale memories in service at stream end, against 2% for a likelihood-ratio rule, and need about 60×\times more uses to retire them (restricted mean; Figure 2). On five open LLMs they serve 7.0–13.5×\times more stale answers than our certificate given the same information (no notices; Table 2); on code, larger still (§ 6).

Figure 2. Counters leave half the stale memories in service at stream end; likelihood ratios retire them about 60× sooner (restricted mean). Kaplan–Meier share of the 156 stale memories not yet retired (same audits for all rules; counters start at the fold without credit). Legend: share still in service when the stream ends (open episodes, so it differs from the curve’s tail at 10410^4 uses) / restricted mean delay (≤104\leq10^4 uses). Bands: 95% template bootstrap.

Safety has a price. Can a memory be safe and still skip most reasoning? One number decides: the certification load Θ=νln⁡(1/δ)/(pKL)\Theta= \nu\ln(1/\delta)/(p\mathrm{KL}), which combines the rate of change (ν\nu), the risk tolerated (δ\delta), the audit rate (pp) and how much one verified outcome reveals (KL\mathrm{KL}). Whatever its algorithm, every safe memory must, in the worst case and as δ→0\delta\to0, leave a share Fπ(Θ)F_{\pi}(\Theta) of queries to multi-step reasoning, and a restarted test achieves it (Theorem 3, Figure 1c). Under Zipf demand it scales as κsΘ1−1/s\kappa_s\Theta^{1-1/s} (Corollary 4): popular problems can be contracted; rare ones change before they can be trusted.

Figure 1. Trusting a contracted memory is a sequential test. (a) Top: the lifecycle of a contracted memory (a macro). In shadow mode a betting certificate scores the macro’s verified answers and folds it (one-step answers) once its wealth reaches 1/δ1/\delta; a likelihood-ratio CUSUM (LR-CUSUM) alarm or an edit notice retires it, and the next candidate restarts the test. Middle: both tests on one real macro (Qwen3-8B, KQA-STREAM; per candidate, no notices). Its log-wealth reaches ln⁡20\ln20 (δ=0.05\delta= 0.05) after 33 labels; an edit then drops its reliability from 1.00 to 0.37, below break-even (r⋆=0.49r^\star= 0.49), and the LR-CUSUM crosses h=7h = 7 on the fourth label. Bottom: its timeline (hatched: certification); ExpeL- and ACE-style counters have not retired it by stream end (2,427 stale answers, against 29). (b) Exact detection delay DD against uses to a false retirement AA for three clipped counters (score per failure/success), failure rate 0.05 →\to 0.25: the symmetric ±1\pm1 rule is slow by a power of AA; likelihood-ratio weights (+7/−1+7/-1) track the optimum. q~\tilde{q}: the failure rate a rule implicitly tests (Remark 1). (c) The exact coverage gap MM (share not answered in one step) of a restarted test for 2,520 settings (dots) lies on the limit Fπ(Θ)F_{\pi}(\Theta) (lines).

The recipe. Three changes turn a counter into a certificate, a rule that lets a memory answer in one step only while the risk of trusting a bad one stays below δ\delta (§ 5). (i) Weigh each memory’s failures against its successes by its own likelihood ratio, set by its healthy and stale fail-ure rates; on KQA-STREAM this detects staleness in 1.3–5.9×\times fewer uses than the best tested fixed weighting. (ii) Certify utility, not accuracy, by betting on the paired difference with live reasoning on the same query, with no estimate of live accuracy. (iii) Restart a memory’s certificate whenever its answers or the live reasoning it competes with change, so every trust decision rests on current evidence. Where edits are substantial, our deployment also invalidates memories an edit announces, and the likelihood-ratio detector is the safety net for unannounced edits; it cuts stale answers 9–12×\times against invalidation alone. On five models it trusts under one below-break-even memory per stream (with notices; counters: 111–595) and, scoring answers alone, makes no false certification at δ≤0.1\delta\le0.1.

Agent memories and skill libraries with a verifier should therefore adopt these changes, and memory benchmarks should edit facts.

Contributions and what is new. Our results apply when facts can change and each memory can be judged only by its own verified outcomes. (1) A concept: reasoning contraction, one lens on templates, skills, memories and caches, whose two risky decisions, trust and retirement, are sequential tests bound by the limits of change detection and certification (Figure 1a); done safely, KQA-STREAM’s symbolic macros add 14–33 points over live reasoning. (2) Two theorems: the phase diagram of counter maintenance (equal votes: delay ≍A0.373\asymp A^{0.373}, not ln⁡A\ln A, at failure rate 0.05 →\to 0.25), with the learning rates that fix it (Theorem 1 and Corollary 2), and the certification-load limit with its scaling law κsΘ1−1/s\kappa_s\Theta^{1-1/s}, matched within 0.945–1.025× by a restarted test (Theorem 3 and Corollary 4). (3) A certificate: a per-template certify–retire–restart lifecycle from standard anytime-valid tools (Yu et al., 2026b), tested on KQA-STREAM (with invalidation, no stale answers under notices; 7.0–13.5× fewer than counters without), natural Wikidata edits and code. Where memory systems vote and anytime-valid routing certifies one global threshold, we test each memory’s trust over its lifecycle: memory systems with a verifier should give each memory its own weight and certificate, and price skipped reasoning by Θ\Theta.

Contraction as a memory lifecycle

Queries, templates, macros. A reasoner serves a stream of queries. Each query instantiates a template ii, a canonical derivation skeleton such as a relation path in a knowledge base, a lemma chain, or a tool-call sequence. Template ii is drawn with probability πi\pi_i and has a live derivation of mi≥2m_i \ge2 steps (LLM calls). A macro for template ii is a one-step operator formed from a verified derivation: a materialized composed relation, a stored lemma, or a distilled direct-answer note. Its reliability rr is the probability that it answers a random instance of ii correctly. On each query the system answers live (cost mm, correct with probability aa), folded (cost 1, answer from the trusted macro), or in shadow mode (live answer, macro evaluated alongside). A verifier (exact match, execution, or a unit test) labels the macro’s answer on audited queries, a fraction p∈(0,1]p \in(0, 1] of the template’s shadow or folded queries. With error price LL (in steps), a folded query costs 1+L(1−r)1 + L(1-r) and a live one m+L(1−a)m + L(1-a), so folding pays if and only if

r>r⋆:=a−(m−1)/L.(1)r > r^\star:= a - (m-1)/L. \tag*{(1)}

The lifecycle. Contraction is a memory lifecycle (Figure 1a): form a candidate from a verified trace, certify it in shadow mode, fold it, monitor it, retire it when it goes stale, and re-form. Two decisions carry all the risk: when may a candidate be trusted (certification) and when has a trusted macro gone stale (retirement). Verifier outcomes Y∈{0,1}Y \in\{0,1\} of a macro are conditionally Bernoulli given the past, with mean equal to its current reliability; this allows adaptive usage and drift. A macro is stale once an edit has raised its failure rate: healthy macros fail with probability q0q_0, stale ones with q1>q0q_1 > q_0.

Maintenance rules in current systems. Expel gives a new insight importance 2, adds 1 per up-vote or edit, subtracts 1 per down-vote and deletes it at 0 (Zhao et al., 2024). ACE keeps unbounded helpful/harmful counts, and its released code flags a bullet when harmful ≥\ge helpful and harmful >0> 0 (Zhang et al., 2026b); our ACE-style baseline treats a flag as retirement. We idealize their LLM-issued votes as one vote per verified use. Validation-gated Hebbian memories clip a strength to [0,1][0,1] with time decay (Singh and Yu, 2025); we analyze the symmetric variant c←min⁡{1,c+η+}c \leftarrow\min\{1,c+\eta_+\} on success and c←c−η−c \leftarrow c-\eta_- on failure, retiring below τ\tau.

Memory counters are change detectors

A score rule assigns a bounded score f(Y)f(Y) to each verifier outcome, keeps

Sn=max⁡{0,Sn−1+f(Yn)},(2)S_n = \max\{0, S_{n-1} + f(Y_n)\}, \tag*{(2)}

and retires the macro at the first nn with Sn≥hS_n \ge h. Clipped Hebbian confidence has this form. With S=(1−c)/η−S=(1-c)/\eta_- the score is +1+1 on a failure and −ρ-\rho on a success, ρ=η+/η−\rho=\eta_+/\eta_-, and the clip at full confidence is the reflection at 0 (Appendix A). Let P0,P1P_0, P_1 be the outcome laws of a healthy and a stale macro, with E0f<0<P0(f>0)\mathbb{E}_0 f<0<P_0(f>0), and let θj>0\theta_j>0 solve Ejeθjf=1\mathbb{E}_j e^{\theta_j f}=1 (the Cramér–Lundberg adjustment coefficient under PjP_j). We measure a rule by AA, the mean number of healthy uses before it falsely retires a macro, and by DD, its worst-case number of uses to detect a change (Lorden, 1971).

Remark 1 (Implied alternative). Every score rule ((2)) is exactly Page’s CUSUM (Page, 1954) for the change P0→P~0:=eθ0fP0P_0 \to\widetilde{P}_0 := e^{\theta_0 f}P_0 and for no other change, as for quality-control charts (Munford, 1980; Brook and Evans, 1972). The symmetric Hebbian rule (ρ=1\rho= 1) thus tests failure rate q0q_0 against its mirror 1−q01-q_0: it assumes that a stale memory is as wrong as a fresh one was right (reliability 0.95 →\to 0.05), whereas a fact edit may corrupt only part of a template’s instances (reliability 0.95 →\to 0.75).

Theorem 1 (Phase diagram of maintenance rules). Let μ1=E1f\mu_1 = \mathbb{E}_1 f and γ=θ1/θ0\gamma= \theta_1/\theta_0. As A→∞A \to\infty,

μ1>0:D=ln⁡Aθ0μ1+O(1);μ1=0:D=(ln⁡A)2(θ0σ1)2+O(ln⁡A),σ12=Var⁡1f;μ1<0:D≍Aγif P1(f>0)>0,\begin{aligned} \mu_1 > 0 &: \quad D = \frac{\ln A}{\theta_0\mu_1} + O(1);\\ \mu_1 = 0 &: \quad D = \frac{(\ln A)^2}{(\theta_0\sigma_1)^2} + O(\ln A), \quad\sigma_1^2 = \operatorname{Var}_1 f;\\ \mu_1 < 0 &: \quad D \asymp A^\gamma\quad\text{if } P_1(f > 0) > 0, \end{aligned}

where γ<1\gamma< 1 if and only if E1eθ0f>1\mathbb{E}_1 e^{\theta_0 f} > 1, e.g. whenever q1>q0q_1 > q_0 for Bernoulli rules. In the first regime the efficiency relative to the optimal delay ln⁡A/KL⁡(P1∥P0)\ln A/\operatorname{KL}(P_1\Vert P_0) (Lorden, 1971) is

Eff⁡=θ0μ1KL⁡(P1∥P0)=1−KL⁡(P1∥P~0)KL⁡(P1∥P0),(3)\operatorname{Eff} = \frac{\theta_0\mu_1}{\operatorname{KL}(P_1\Vert P_0)} = 1 - \frac{\operatorname{KL}(P_1\Vert\widetilde{P}_0)}{\operatorname{KL}(P_1\Vert P_0)}, \tag*{(3)}

so Eff⁡≤1\operatorname{Eff} \le1, with equality if and only if ff is proportional to the log-likelihood ratio. When it applies: any clipped counter with a bounded score per verified outcome, when outcomes are i.i.d. before and after one change (constants in Appendix A).

References

  1. [1]Pranjal Aggarwal, Aman Madaan, Ankit Anand, Srividya Pranavi Potharaju, Swaroop Mishra, Pei Zhou, Aditya Gupta, Dheeraj Rajagopal, Karthik Kappaganthu, Yiming Yang, Shyam Upadhyay, Manaal Faruqui, and Mausam. 2024. AutoMix: Automatically mixing language models. In Advances in Neural Information Processing Systems (NeurIPS), volume 37.arxiv.org/abs/2310.12963
  2. [2]John R. Anderson, Daniel Bothell, Michael D. Byrne, Scott Douglass, Christian Lebiere, and Yulin Qin. 2004. An integrated theory of the mind. Psychological Review, 111(4):1036–1060.pubmed.ncbi.nlm.nih.gov/15482072
  3. [3]Anastasios N. Angelopoulos, Stephen Bates, Emmanuel J. Candès, Michael J. Jordan, and Lihua Lei. 2025. Learn Then Test: Calibrating predictive algorithms to achieve risk control. The Annals of Applied Statistics, 19(2):1641–1662.arxiv.org/abs/2110.01052
  4. [4]Mohammad Asadollahi, Amir Amini, Samira Talebi, Amirfhard Farhadi, and Azadeh Zamanifar. 2026. Memory reward inflation in self-improving LLM agents. arXiv preprint arXiv:2608.00017.

Paper details

vlnc:W_92rvpaze
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents