betaFeedback

WorksComputer Science

CoReMem: Cost-Internalizing Memory for Successive Coding Tasks with Prospective Valuation

Abstract

Coding agents tackle successive tasks on an evolving repository, carrying forward edits and writing memory before the next task is known. Selecting memory for unknown next tasks requires balancing future usefulness against the costs of writing and reading it. The actor must also decide when acting on available memory saves effort as the task unfolds. We introduce Coding-Repository Memory (CoReMem), a cost-internalizing framework that guides memory design and actor adaptation through measured memory value on the next task. Prospective segment valuation compares runs of the next task with and without individual trajectory segments from the same inherited repository state, guiding a compact memory built around anchors: repository locations and executable checks. Actor adaptation estimates on-policy memory value within rollout groups with and without memory, using a reward that prioritizes resolution and penalizes step count in successful runs. Provenance-gated value credit assigns the additional value term to steps identified as using memory-supplied anchors, while every step retains outcome credit. On ChainSWE, CoReMem raises the 27B actor's resolve rate from 21.0% to 25.7%, with 17% fewer steps and 11% fewer total cache-aware tokens, including memory-module calls, relative to the untrained actor model without memory.

Introduction

In real-world software development, coding agents are expected to handle successive tasks on an evolving repository. While prior research has primarily studied repository issues independently (Jimenez et al., 2024), recent work considers sequences of tasks on a shared, evolving repository (Jin et al., 2026). We study this successive-task setting, in which tasks arrive sequentially, each inherits the repository state left by earlier tasks, and future tasks are unknown in advance. Since this state

carries over, suitable memory can let agents reuse information acquired during earlier exploration and avoid rediscovering it on unseen future tasks (Figure 1). We therefore consider both what a memory is worth and how an agent can use it to reduce the cost of solving unseen future tasks.

Figure 1. Memory on the next task. A memory written at the end of one flake8-simplify task hands two anchors, a location (WHERE) and a check (VERIFY), to the next task on the same repository; the post-trained actor model acts on them at steps 1 and 6 and skips the exploration it would otherwise start with (step counts illustrative).

Existing memory methods for coding agents are not specifically designed for the above successive-task setting and do not reliably save effort (steps and tokens) on unseen future tasks (Figure 3). As illustrated in Figure 2, within-task methods learn to compact context for the current task, whose goal is already known (Gao et al., 2026; Li et al., 2026c). Most cross-task methods distill and transfer general experience and insights across independent tasks and repositories [7] (Ouyang et al. 2026). MemOp instead accumulates memory across tasks within the same repository, but since the repository state is reset between tasks in its setting, it optimizes its memory design based on gains measured on the task that produced the memory (Guo et al., 2026), rather than on its value to an unseen future task that inherits the changed repository. Given these mismatches in setting and objective, Challenge 1 is to determine, before the future task is known, what information is worth carrying across the task boundary.

Figure 2. What crosses coding-task boundaries and where memory is valued and optimized. Existing settings keep memory within one task, transfer general experience across independent tasks, or carry memory while resetting the repository. Our setting carries both repository state and memory to unseen future tasks. The ↺\circlearrowleft and ↓\downarrow symbols indicate whether memory is valued and optimized on its source task or on future tasks.

Figure 3. Steps and tokens of each memory form against no memory. Hollow marks count only the acting model’s tokens, and the arrows add the tokens of the memory module. Parentheses give the relative change in resolve rate. The star is CoReMem w/o training (§ 3.1), the one form near the shaded quadrant where steps and total tokens both fall.

Memory’s value is realized only when the actor model uses it appropriately during execution. Existing coding memory methods mainly optimize what is stored or retrieved, while typically leaving the model that reads it unchanged [9] (Ouyang et al. 2026; Guo et al. 2026). Yet an agent’s information needs evolve as a task unfolds (Zhang et al., 2023; Shen et al., 2026), making task-start retrieval insufficient to determine how memory should be used during execution. Challenge 2 is therefore how to use memory efficiently during execution to reduce the cost of solving unseen future tasks on the inherited repository.

To address these challenges, we introduce Coding-Repository Memory (CoReMem), a cost-internalizing memory framework for successive coding tasks. Specifically, prospective segment valuation of memory addresses Challenge 1 by first formulating the prospective value of a memory at a task boundary, then valuing each part of the current task’s trajectory by what it saves on the next task, and from these values inducing, through a systematic procedure, a value-guided memory design for successive coding tasks. As a result, the value concentrates in anchors, references to repository locations and to executable checks, which later also mark the steps that act on the memory. To address Challenge 2, we propose on-policy adaptation for memory use with provenance-gated value credit, which adapts the actor model itself to act on the memory where that saves effort, in two steps. Cost-internalizing on-policy valuation trains the actor model in groups of rollouts with the memory, without it and with a misplaced memory, under a reward that charges steps inside success, so that the average gap between the rollouts with the memory and those without it exposes the memory’s value to the current actor model. For the rollouts that run with the memory, step-level provenance-gated value credit then pays the memory value to the steps whose anchors came from the memory, so that memory use is pushed by its measured value while every step keeps its outcome credit, and we show analytically that this push vanishes when the same value is paid to every step.

Our contributions are summarized as follows.

  • We propose prospective segment valuation of memory, a systematic procedure that values each part of a trajectory by what it saves on the next task and induces a value-guided memory design for successive coding tasks.

  • We propose on-policy adaptation for memory use with provenance-gated value credit, which measures the memory value on-policy within each group of rollouts and passes the memory’s value directly to the steps that act on it.

  • On ChainSWE, a benchmark of successive tasks, CoReMem raises resolve per token over no memory by 41% on average across three different actor models.1

Preliminaries

In this paper, we consider a repository worked on by a chain of tasks T1,…,TKT_1,\ldots,T_K, carried out one after another in a single persistent workspace (Jin et al., 2026). Each task runs as its own session of an actor, the model that acts in the repository, which leaves the repository state SkS_k its edits produced and the trajectory τk\tau_k of its actions and observations. At the boundary bk=(Sk,τk,Tk+1)b_k=(S_k,\tau_k,T_{k+1}) the state persists, since the next task opens the tree this one closed, while the trajectory is lost, and a memory m=πwrite(τk)m=\pi_{\mathrm{write}}(\tau_k), written once at the end of task kk and before Tk+1T_{k+1} is issued, is the only text that crosses. Unlike cross-episode memory that resets each task to a base commit [14] (Guo et al. 2026), the state here is inherited (Figure 2), so a memory cannot be checked on its own task, whose answer the repository holds.

Does existing memory save effort? We run the existing forms of cross-task memory, the full history of the earlier tasks (App. § 8), Mem0’s facts [9], MemOp’s guidebook (Guo et al., 2026) and ReasoningBank’s strategies (Ouyang et al., 2026), on the ChainSWE test set and count, for every form, the tokens of the acting model and of its memory module. Figure 3 places each by its change in steps and tokens against no memory, first with the acting model’s tokens alone and then adding the tokens of the memory module (Table 1 and Table 3 have every number). Memory on successive tasks should lower the next task’s effort, its steps and the tokens they cost, yet no existing form reaches the quadrant where steps and total tokens both fall. Some buy resolution rather than effort, and each spends more tokens on its memory than it saves. Our aim is therefore a memory that lowers the effort of unseen future tasks without harming resolution, with what it keeps derived by valuing each part of a finished session by the effort it saves on these tasks and keeping what pays (§ 3.1, the star in Figure 3).

Memory layerLinked Res. (%) ↑Linked Steps ↓Unlinked Res. (%) ↑Unlinked Steps ↓Overall Res. (%) ↑Overall Steps ↓Tokens per session (K) Actor ↓Tokens per session (K) WriterTokens per session (K) Total ↓Res. per K tokens Actor ↑Res. per K tokens Total ↑
Qwen3.5-9B
No memory9.798.4 (91.1)19.498.1 (91.2)14.098.2 (91.2)98.3 (98.9)–98.3 (98.9)0.1520.152
Full history11.470.0 (60.5)17.976.4 (68.5)14.2 +2%72.8 (65.1) −26%85.9 (79.9)–85.9 (79.9) −13%0.1560.156 +3%
Mem012.294.3 (86.0)21.893.1 (85.2)16.4 +17%93.8 (86.0) −5%96.5 (94.8)14.9 (14.4)111.4 (109.1) +13%0.1750.151 0%
MemOp11.993.5 (85.8)19.096.8 (86.3)15.0 +7%94.9 (86.1) −3%99.3 (96.4)32.4 (33.1)131.7 (131.4) +34%0.1470.111 −27%
ReasoningBank12.092.3 (83.6)17.996.7 (90.3)14.6 +4%94.3 (85.2) −4%102.3 (94.0)63.7 (65.8)166.1 (163.1) +69%0.1430.088 −42%
CoReMem w/o training12.595.6 (87.2)19.294.6 (88.6)15.5 +11%95.1 (87.2) −3%101.7 (104.6)10.0 (7.5)111.7 (116.5) +14%0.1400.128 −16%
CoReMem14.270.2 (64.2)22.275.4 (69.3)17.7 +27%72.4 (65.1) −26%75.0 (65.4)5.0 (2.0)79.9 (70.8) −19%0.2360.222 +46%
Qwen3.8-27B-FP8
No memory19.130.9 (22.8)23.440.5 (30.4)21.035.1 (26.0)32.2 (24.7)–32.2 (24.7)0.6530.653
Full history20.727.0 (21.3)24.639.8 (33.5)22.4 +7%32.6 (23.8) −7%39.0 (29.5)–39.0 (29.5) +21%0.5740.574 −12%
Mem020.132.5 (26.6)23.440.3 (30.0)21.5 +2%35.9 (28.2) +2%34.2 (25.4)34.5 (28.4)68.7 (53.4) +113%0.6320.314 −52%
MemOp22.529.4 (22.2)24.638.9 (36.8)23.4 +12%33.5 (24.8) −4%32.3 (23.8)18.2 (14.7)50.4 (38.0) +57%0.7270.465 −29%
ReasoningBank23.830.1 (24.6)27.039.8 (31.8)25.2 +20%34.3 (27.7) −2%32.5 (26.2)35.0 (28.7)67.5 (54.7) +110%0.7780.375 −43%
CoReMem w/o training22.526.9 (21.2)24.538.0 (32.9)23.4 +11%31.8 (22.4) −10%30.4 (23.0)2.0 (1.7)32.4 (24.7) 0%0.7720.724 +11%
CoReMem25.126.2 (18.0)26.533.4 (25.0)25.7 +22%29.2 (20.0) −17%26.6 ( …
Gemma-4-31B
No memory4.330.4 (23.8)20.629.3 (21.7)11.529.9 (23.2)32.4 (23.9)–32.4 (23.9)0.3530.353
Full history7.425.7 (18.5)17.529.1 (19.9)11.8 +3%27.2 (19.2) −9%31.8 (25.8)–31.8 (25.8) −2%0.3710.371 +5%
Mem04.928.7 (24.3)18.327.4 (21.7)10.8 −6%28.1 (23.0) −6%34.0 (26.4)13.2 (13.3)47.2 (39.2) +46%0.3220.230 −35%
MemOp4.926.8 (20.0)23.031.3 (22.5)12.8 +12%28.8 (20.5) −4%34.6 (26.2)14.9 (13.5)49.6 (36.5) +53%0.3710.259 −27%
ReasoningBank7.430.6 (23.3)20.630.3 (22.2)13.2 +15%30.4 (23.2) +2%33.0 (26.0)32.3 (28.9)65.3 (54.9) +102%0.3990.202 −43%
CoReMem w/o training6.828.2 (21.3)19.828.5 (23.3)12.5 +9%28.3 (22.0) −5%31.0 (23.8)2.9 (1.3)33.9 (26.5) +5%0.4050.371 +5%
CoReMem8.628.0 (21.8)21.429.1 (22.3)14.2 +24%28.5 (21.8) −5%27.2 (21.7)2.2 (1.2)29.3 (23.9) −9%0.5270.486 +38%

Table 1. Cost and outcome of each memory layer for the open-weight actor models on the test set. Resolve rate and steps on linked and unlinked boundaries (App. § 8) and overall, cache-aware tokens per session of the actor model and of the memory module (Writer), and resolve per thousand actor or total tokens. Tags give the change against the no-memory row of the same actor model. Gray values in parentheses are medians over sessions. CoReMem w/o training is our memory on the frozen actor model and CoReMem the post-trained actor model with it; replay counts and tests are in App. § 8, with the definition of every column.

Memory layerRes. (%) ↑Outcome Steps ↓Outcome Actor ↓Tokens per session (K) WriterTokens per session (K) Total ↓Res. per K tokens Actor ↑Res. per K tokens Total ↑USD ↓List price Res. per USD ↑
No memory38.512.6 (12.0)21.5 (15.7)–21.5 (15.7)1.7911.7910.2370162
Full history40.6 +5%10.4 (9.0) −17%27.0 (23.5)–27.0 (23.5) +25%1.5051.505 −16%0.2384 +1%170 +5%
Mem039.6 +3%13.0 (12.0) +3%18.7 (16.2)16.6 (17.8)35.4 (34.8) +64%2.1121.119 −37%0.2893 +22%137 −16%
MemOp39.6 +3%17.8 (12.5) +41%21.7 (16.0)14.4 (12.1)36.1 (28.2) +68%1.8211.096 −39%0.3630 +53%109 −33%
ReasoningBank40.6 +5%14.2 (12.0) +13%20.9 (16.8)27.9 (24.6)48.8 (41.3) +127%1.9390.832 −54%0.4028 +70%101 −38%
CoReMem w/o training38.5 0%11.8 (10.0) −6%18.1 (13.7)2.0 (2.0)20.1 (15.7) −7%2.1341.919 +7%0.2048 −14%188 +16%
No memory23.617.9 (16.7)51.7 (43.7)–51.7 (43.7)0.4610.4610.01761349
Full history24.0 +1%18.6 (15.3) +4%79.8 (66.7)–79.8 (66.7) +54%0.3060.306 −34%0.0263 +50%918 −32%
Mem022.6 −4%17.5 (15.3) −2%49.8 (40.4)13.0 (12.9)62.7 (53.0) +21%0.4560.361 −22%0.0199 +13%1134 −16%
MemOp22.9 −3%17.5 (15.8) −2%49.7 (38.3)14.0 (12.6)63.8 (49.7) +23%0.4700.363 −21%0.0204 +16%1121 −17%
ReasoningBank23.3 −1%17.9 (15.5) 0%55.6 (44.8)29.6 (26.2)85.3 (72.0) +65%0.4190.273 −41%0.0258 +47%902 −33%
CoReMem w/o training25.7 +9%16.3 (14.7) −9%48.9 (39.6)3.6 (2.5)52.5 (44.2) +2%0.5260.491 +7%0.0181 +3%1421 +5%
No memory21.990.0 (87.3)84.4 (70.6)–84.4 (70.6)0.2620.2620.0363605
Full history22.4 +2%76.6 (72.4) −15%75.8 (66.0)–75.8 (66.0) −10%0.2970.297 +14%0.0319 −12%705 +16%
Mem021.9 0%94.2 (91.9) +5%87.5 (76.2)12.5 (12.5)100.0 (88.1) +18%0.2520.220 −16%0.0393 +8%558 −8%
MemOp21.4 −2%87.5 (85.6) −3%81.7 (68.0)28.8 (30.4)110.5 (99.4) +31%0.2630.194 −26%0.0396 +9%542 −10%
ReasoningBank23.1 +6%97.2 (96.2) +8%91.8 (78.4)58.9 (62.5)150.7 (145.3) +78%0.2560.155 −41%0.0468 +29%497 −18%
CoReMem w/o training23.6 +8%78.2 (77.1) −13%75.9 (57.6)6.4 (1.5)82.3 (61.6) −3%0.3130.289 +10%0.0330 −9%717 +18%

Table 3. Cost and outcome of each memory layer for the API-served models on the test set. Overall columns as in Table 1, with the list-price cost per session and resolve per dollar.

Learning objective. A memory can only point at what the next task should reuse, and effort is saved only when the actor acts on it. An actor is trained to solve a task from scratch rather than to read what an earlier task left, so it may pass over a memory that would spare it work or follow one that does not apply (Liu et al., 2024; Shi et al., 2023), and whether a memory applies becomes clear only as the actor works through the task. We therefore also adapt the actor’s parameters from θ0\theta_0 to θ=θ0+Δθ\theta=\theta_0+\Delta\theta. The next task’s session is then τ∼πθ(⋅∣Sk,Tk+1,m)\tau\sim\pi_\theta(\cdot\mid S_k,T_{k+1},m). With the memory’s form fixed (§ 3.1), we learn Δθ\Delta\theta so that on training boundaries B\mathcal{B} the next task takes fewer steps n(τ)n(\tau) without resolving less often than the base actor, with Eθ\mathbb{E}_\theta over bk∈Bb_k\in\mathcal{B} and τ∼πθ\tau\sim\pi_\theta,

min⁡ΔθEθ[n(τ)]s.t.Eθ[res⁡(τ)]≥Eθ0[res⁡(τ)],(1)\begin{aligned} \min_{\Delta\theta}\quad&\mathbb{E}_\theta[n(\tau)]\\ \text{s.t.}\quad&\mathbb{E}_\theta[\operatorname{res}(\tau)]\ge\mathbb{E}_{\theta_0}[\operatorname{res}(\tau)], \tag*{(1)} \end{aligned}

with res⁡(τ)∈{0,1}\operatorname{res}(\tau)\in\{0,1\} whether τ\tau resolves Tk+1T_{k+1}.

Cost-Internalizing Memory

CoReMem is cost-internalizing in the sense of Eq. (1). The effort a memory changes on the next task is measured, and that measurement enters both what the memory keeps and how the actor model is adapted to use it, in two parts (Figure 4). § 3.1 defines the value of a memory on unseen future tasks and lets it guide what the memory keeps, which turns out to be anchors. § 3.2 adapts the actor model to use that memory during execution, measuring the value again on-policy and paying it, through the anchors, to the steps that use the memory, on top of the outcome credit.

Figure 4. Overview of CoReMem. (a) Prospective segment valuation of memory. A memory mm written from the trajectory τk\tau_k is valued by the change Δy(m∣bk)\Delta_y(m \mid b_k) it causes on task k+1k+1, run from the inherited tree SkS_k with and without mm. Removing each of the seven segments of τk\tau_k gives its value νc\nu_c, and the segments that pay are kept as anchors A(m)A(m). (b) Cost-internalizing on-policy valuation. A group of GG sessions mixes sessions with their own memory (mm), no memory (∅\varnothing) and a misplaced memory (m~\widetilde{m}) under the reward RiR_i, and V^b=R‾m−R‾∅\widehat{V}_b = \overline{R}_m - \overline{R}_{\varnothing} is the memory’s value on-policy. (c) Step-level provenance-gated value credit. Only the steps that the gate ωt\omega_t marks as acting on an anchor from the memory receive the value credit.

Prospective segment valuation of memory

To decide, before the next task is known, what to carry across a task boundary, we provide a systematic procedure for inducing a memory design. We first define a memory’s prospective value on the next task, and use it to find which parts of a session’s history are worth carrying because they save effort on the next task.

Prospective value of memory. In real-world deployment, a memory is usually written for a task not yet issued, so we value it, and train the actor to use it, on the unseen task that follows rather than on the task that produced it. Let y(m)y(m) be an outcome of the next task’s session, which runs Tk+1T_{k+1} from the repository state SkS_k that task kk left, with memory mm in its context, namely whether it resolves, its steps or its actor tokens. The prospective value of a memory mm at boundary bkb_k is the change it causes,

Δy(m∣bk)=E[y(m)]−E[y(∅)].(2)\Delta_y(m \mid b_k) = \mathbb{E}\left[y(m)\right] - \mathbb{E}\left[y(\varnothing)\right]. \tag*{(2)}

where m=∅m = \varnothing stands for running with no memory and the expectation is over the actor’s sampling. We estimate it as Δ^y(m∣bk)=yˉ(m)−yˉ(∅)\widehat{\Delta}_y(m \mid b_k) = \bar{y}(m) - \bar{y}(\varnothing) from the mean outcomes of the runs, and the nn candidates at a boundary share one no-memory arm, n+1n+1 arms instead of 2n2n. We use this value both to attribute value across a session’s trajectory (below) and in on-policy actor training (§ 3.2).

Segment-by-segment valuation. We measure which parts of a trajectory are worth carrying and let the measurements guide the form (App. § 16).

(a) Cutting the trajectory into segments. We split a trajectory into the seven segments of Figure 5, a segment being every part of the trajectory that plays one role, such as the actor’s reasoning text, its commands or the test output (Figure 9 in App. § 14 shows a real excerpt labeled by segment). The split involves no prior knowledge about what matters, since the record of any coding agent already comes in these parts, the actor’s own text and commands, the observations the environment returns, the diff it leaves and the outcome (each described in App. § 14), and how much of each is worth keeping is left to the valuation in (b) and (c).

Figure 5. From segment values to the memory design. The median change in steps (νc\nu_c) and in thousand actor tokens (κc\kappa_c) when one segment is removed from the current task’s trajectory (Eq. (3); 27B actor model). Blue bars mark segments whose removal adds steps. The right columns give the field each segment becomes in the memory design, kept as a main field (blue), in reduced form (light blue) or dropped (gray), and what the next task gets from each of them.

A real trajectory split into segments

Figure 9. A real trajectory split into segments (flake8-simplify, training split, frozen 27B actor). Verbatim except [...] cuts and the omitted command fences; segment labels and step numbers are ours.

(b) Valuing each segment. Let M=τkM = \tau_k be the current task’s trajectory injected whole as a memory and McM_c its segment cc. With the prospective value of Eq. (2) at each boundary bb, in steps (s) and in actor tokens (t), removing cc from MM changes

νc=med⁡b[Δ^s(M∖Mc)−Δ^s(M)],κc=med⁡b[Δ^t(M∖Mc)−Δ^t(M)].(3)\nu_c = \operatorname{med}_b\left[\widehat{\Delta}_s(M \setminus M_c) - \widehat{\Delta}_s(M)\right], \qquad \kappa_c = \operatorname{med}_b\left[\widehat{\Delta}_t(M \setminus M_c) - \widehat{\Delta}_t(M)\right]. \tag*{(3)}

In words, νc\nu_c and κc\kappa_c are the median changes in steps and in tokens when cc is removed, which shows how much of the effect of MM on the next task, a saving or a cost, depends on each segment.

(c) From values to design. We keep a segment if removing it adds steps on the next task, counting νc\nu_c as positive when it survives a permutation test corrected across segments, and drop one that only adds tokens, unless a shorter form of it saves as many steps, in which case we keep that form. Each νc\nu_c is conditional on the other segments being present (Table 8 gives each), so we then check the assembled memory against MM as a whole, on steps here and on resolution in deployment (§ 4).

SegmentMeasurement on linked boundariesDecisionLine of the memory
C1 reasoningDeleting it costs no step (34 helped, 45 hurt) and saves 1.14K tokens (p=.023p=.023)Step 3 kept a reason field; Step 4 dropped itNone; the instruction forbids reasons and summaries
C2 commandsDeleting it costs a median 2 steps (56/27, BH p∗=.0070p^{*}=.0070); alone it carries the whole saving; the failing commands alone carry halfKept; failed checks stay in it with their exit codeVERIFY exact command [exit N] | COVERS paths
C3 repository contentDeleting it costs a median step (52/34, BH p∗=.0302p^{*}=.0302) and saves 0.63K tokensKept as located factsCONTEXT fact | WHERE path:lines, in the repository block
C4 test feedbackTest commands with exit codes beat the full test output by a median step (53/30, BH $p^{*}=.045) | A test result is the exit code of its command | TESTS last full test command [last exit N]; no pasted output
C5 changeDeleting the diff body costs no step (47/44) and saves 0.94K tokens (p=.021p=.021); the file list matches the full diff (p=.097p=.097)Anchors only, body bannedDID one clause | WHERE path:lines (symbols); the change is committed and is not restated
C6 outcomeNo effect overall (45/33); helps when the current task resolved (24/11)Observable part kept, hidden-test verdict banned; Step 4 places it in the task blockSTATUS submitted, stopped or no change, inside the task block
C7 scratch38% of the paths a session writes sit under /tmp and are gone by the next command; the manifest carries no step value (36/48)No line; a validity rule on VERIFYVERIFY runs unchanged from the repository root, with no /tmp and no cd

Table 8. From segments to lines. Results of the segment study (App. I). Counts are boundaries where the segment helped and hurt the next task. BH marks the multiplicity correction across segments.

Value-guided memory design. Removing the commands or the repository content read adds steps on the next task, while removing the reasoning text or the diff body adds no steps and saves tokens (Figure 5). Shorter forms also work, as test commands with their exit codes save more steps than the full test output and the diff’s file list comes close to the full diff (App. § 16). What saves the next task effort is where to look and what to run, not the narrative, so we build the memory from the references that carry it and define them below as anchors.

Definition 1 (Anchor). An anchor is a reference, taken from a trajectory, to a specific place in the repository, a location, or to a specific command that runs or tests the code, a check, which the next task can act on as it stands. A(x)A(x) denotes the anchors that a text xx contains.

Locations are file paths with their lines and code names, such as rules/ast_if.py:34-58, and checks are commands that run or test the code and test identifiers, such as python -m pytest tests/ -k sim102 (App. § 17).

Following (c), the template keeps each segment in the form Figure 5 lists, the commands and the repository content as main fields, the test output, the final diff and the outcome in reduced form, and it drops the reasoning text and the scratch files (App. § 18). Its main components are the checks and the locations of Definition 1, which potentially help the next task save the effort of finding what to run and where to look, and they mirror the validation and localization phases of Agentless ((Xia et al., 2024)), which resolves issues cheaply without open-ended exploration. We further organize these components into two blocks. The task block holds what concerns the current task, what it changed and checked, and the repository block holds general context, how the repository is laid out and tested. The memory keeps the whole median step saving of MM with 6% of its bytes. The procedure needs only paired runs on the next task and a split of the trajectory by role, so it applies wherever tasks follow one another on shared state, and the segments and anchors above are what it yields for coding. Anchors also make the memory traceable, since they mark the steps of a later session that use it, which § 3.2 builds on.

On-policy adaptation for memory use with provenance-gated value credit

To use memory efficiently during execution, at steps that are not known in advance but emerge as the task unfolds (App. § 13), we adapt the actor model itself, so that it acts on the memory in its context where that saves effort, as Eq. (1) asks. To separate what the memory contributes from how a session went, each training group mixes sessions with and without the memory, so the memory’s value to the current actor model is measured on-policy, and that value is credited to the steps that acted on the memory.

Cost-internalizing on-policy valuation

Cost-internalizing reward. At a training boundary b=bkb = b_k the current policy πθ\pi_\theta rolls out a group of GG sessions from the state Sb=SkS_b = S_k, with and without memory. A session is scored on whether it resolves the task and on how many steps it took,

Ri={W−niif session i resolves Tk+1,αfiotherwise,W>nmax⁡+α,(4)R_i = \begin{cases} W - n_i & \text{if session } i \text{ resolves } T_{k+1},\\ \alpha f_i & \text{otherwise,} \end{cases} \qquad W > n_{\max} + \alpha, \tag*{(4)}

with nin_i its step count, nmax⁡n_{\max} the step limit, fi∈[0,1]f_i \in[0,1] the fraction of the next task’s fail-to-pass tests that pass after the session, α\alpha the weight of that partial progress, and WW a payoff for resolving that exceeds any step count plus α\alpha. Every resolved session outranks every unresolved one and effort is charged only inside success, so within a group no saving of steps outweighs a resolution, which also removes the incentive to give up early. The reward thus works toward the constraint of Eq. (1). Sessions with and without memory are scored on this same scale, so a memory is charged for the steps it adds and credited for the steps it saves and the resolutions it wins, which is what cost-internalizing means for the reward.

Paired on-policy valuation. The group mixes three kinds of sessions, named by the memory they carry. Memory-free sessions (∅\varnothing) run with no memory, own-memory sessions (mm) each carry a memory of bb drawn from the memories qbq_b the frozen base actor writes for it, and one misplaced-memory session (m~\tilde{m}) carries a real memory written for another repository, right in form and wrong in content. A policy that follows its memory blindly loses on m~\tilde{m}, and one that ignores memory forgoes what mm is worth. Every session receives the ordinary group-relative advantage against the memory-free sessions of its group,

Ai∅,m,m~={Ri−Rˉ∅s,∅,Ri−Rˉms+V^bs,m,Ri−Rˉ∅s,m~,(5)A_i^{\varnothing,m,\tilde{m}} = \begin{cases} \dfrac{R_i-\bar{R}_{\varnothing}}{s}, & \varnothing,\\[6pt] \dfrac{R_i-\bar{R}_m}{s}+\dfrac{\widehat{V}_b}{s}, & m,\\[6pt] \dfrac{R_i-\bar{R}_{\varnothing}}{s}, & \tilde{m}, \end{cases} \tag*{(5)}

with Rˉ∅\bar{R}_{\varnothing} and Rˉm\bar{R}_m the mean rewards of the ∅\varnothing and mm sessions and ss a fixed scale (App. A). For ∅\varnothing and m~\tilde{m} the ordinary advantage is the whole credit, paid to every step, so acting on the misplaced memory is penalized through the outcome it leads to. For mm the whole credit further splits into two parts. The first is the session’s outcome credit, the advantage of the session against the sessions that carry a memory of bb. It reflects how the session itself dealt with the task and, as in ordinary GRPO, every step receives it, which trains the session to resolve the task in fewer steps. The second is the memory’s value credit, which carries the contribution of the memory itself, what a memory of bb is worth to the actor, since V^b=Rˉm−Rˉ∅\widehat{V}_b=\bar{R}_m-\bar{R}_{\varnothing} estimates Em∼qb[ΔR(m∣b)]\mathbb{E}_{m\sim q_b}[\Delta R(m\mid b)], the prospective value of Eq. (2) with the reward as the outcome yy averaged over the memories of bb, measured on-policy at every visit at no extra run. The value credit goes to the few memory-driven steps, as set out next.

Step-level provenance-gated value credit

Provenance gate. To give the memory’s contribution directly to the few steps that act on the memory, where it can change what the actor does, we identify those steps by a per-step signal of provenance, whether what a step acts on came from the memory. A step tt is one assistant message xtx_t and the output it receives. A step of an own-memory session (mm) is memory-driven, ωt=1\omega_t=1, when xtx_t contains an anchor aa (Definition 1) that comes from the memory, was not seen before in the current session, and is not found without memory,

ωt=1[∃ a∈A(xt):a∈A(m),a∉A(ht),a∉Ub],(6)\omega_t=\mathbf{1}\left[\exists\,a\in\mathcal{A}(x_t):a\in\mathcal{A}(m),\quad a\notin\mathcal{A}(h_t),\quad a\notin\mathcal{U}_b\right], \tag*{(6)}

with hth_t the task and every message and observation before step tt, the injected memory excluded, and Ub\mathcal{U}_b the anchors that the memory-free sessions (∅\varnothing) of the same group reach within their first few steps (calibration of the gate in App. G). The gate marks traceable use of the memory, not the step’s own effect on the outcome, which stays with the outcome credit of every step.

Step-level value credit. With this gate, each step tt of an own-memory session ii is credited

Ai,t=Ri−Rˉms+ωtV^bs,(7)A_{i,t}=\frac{R_i-\bar{R}_m}{s}+\omega_t\frac{\widehat{V}_b}{s}, \tag*{(7)}

and each step’s tokens are trained with that step’s credit (App. A). Setting every ωt=1\omega_t=1 recovers the paired whole-trajectory credit of Eq. (5).

Proposition 1 (Value credit as a push on memory use). Let JbmemJ_b^{\mathrm{mem}} be the expected reward of a session with a memory mm of boundary bb and VbV_b the memory’s value under the current actor. Under the population form of Eq. (7), the expected policy gradient on such sessions is

gm=1s∇θJbmem+Vbs∑tE[∇θpt],(8)g_m=\frac{1}{s}\nabla_\theta J_b^{\mathrm{mem}}+\frac{V_b}{s}\sum_t\mathbb{E}\left[\nabla_\theta p_t\right], \tag*{(8)}

with pt=Pθ(ωt=1∣ht,m)p_t=P_\theta(\omega_t=1\mid h_t,m) the probability that step tt is memory-driven, and its second term vanishes when every ωt=1\omega_t=1.

The first term is the outcome learning of Eq. (4), and the second moves how often the actor acts on the memory, up where the memory pays and down where it does not; App. F derives this.

Experiments

Experimental setup

We run ChainSWE (Jin et al., 2026) in mini-swe-agent, with its 100 task chains split into a training and a test half over disjoint repositories. We compare our memory with running without memory, with the full history of earlier tasks and with three memory layers, Mem0 (Chhikara et al., [9]), MemOp (Guo et al., 2026) and ReasoningBank (Ouyang et al., 2026), and report the resolve rate, steps per task, tokens per session and resolve rate per token. The detailed experimental setup, including the ledger, is in App. § 8, and results on SWE-bench Verified, external task chains and OpenHands are in App. § 11.

Main results

Our memory lowers effort while keeping resolution. With the actor model frozen, our memory lowers steps on all six actor models, the open-weight ones in Table 1 and the API-served ones in Figure 6, significantly on three by 9% to 13%, without lowering resolution, which rises on five of them and is unchanged on Opus, and at total tokens within −7% and +5% of running without memory on five of the six actor models (tests in App. § 8). Mem0, MemOp and ReasoningBank cost more tokens than our memory on five of the six actor models they run on.

Figure 6. Steps, resolve per token and resolve per dollar against no memory for the API-served models. Top, each point is one memory layer on one model, and the shaded quadrant is where a memory lowers steps and raises resolve per thousand total tokens, which CoReMem w/o training reaches on all three models. Bottom, the change in resolve per dollar at list prices, with full numbers in Table 3 of App. D.

Post-training internalizes the cost. Post-training lowers steps against running without memory on all three actor models, by up to 26%, at

9% to 19% fewer total tokens, and raises resolution by 22% to 27%, so resolve per total token rises by 38% to 46%, 41% on average (Table 1). Against the same memory on the untrained actor model, steps fall by a further 24% on 9B and 8% on 27B.

Detailed analysis

We further conduct ablations on the three modules of § 3: what the memory layer (M1) carries that the next task acts on, whether the cost-internalizing post-training (M2) lowers effort beyond outcome learning, and whether the provenance-gated value credit (M3) changes how the actor model treats memory; w/o training runs M1 on the frozen actor model, resolve-only RL trains on the resolution term alone and M1+M2 trains without the value credit (settings in App. A and C).

M1: the memory hands over anchors the next task uses. Our memory packs the most anchors per thousand injected characters, and the next task acts on 1.32 of them per thousand characters against 0.92 for MemOp, 0.19 for ReasoningBank and 0.14 for Mem0 (Table 2).

Memory layerAnchors per 1K charsUsed anchors per memoryUsed anchors per 1K chars
Mem09.7 [9.4, 10.1]0.15 [0.09, 0.21]0.14 [0.08, 0.21]
MemOp14.4 [13.6, 15.2]2.06 [1.59, 2.51]0.92 [0.72, 1.11]
ReasoningBank8.5 [7.8, 9.1]0.65 [0.51, 0.80]0.19 [0.14, 0.24]
CoReMem w/o training15.8 [15.0, 16.7]2.24 [1.67, 2.87]1.32 [1.00, 1.68]

Table 2. Anchors the next task can act on, per memory layer. 27B frozen actor model, test set; an anchor is used when it occurs only in the memory and appears in a message of the next task’s session; brackets give 95% intervals over the test chains.

M2: charging steps inside success lowers effort further. Figure 7 (top) places each variant on the effort–resolution plane. Resolve-only RL lowers steps on 27B from 32.6 to 30.4 and on 9B from 91.9 to 75.5; charging steps inside success (M1+M2) lowers them further, to 29.7 and 63.8, and the full method stays at 29.2 and 72.4.

Figure 7. Evidence for M2 and M3. Top, steps per task and resolve rate of the with-memory arms in training order, where up and to the left is better and the larger marker is the full method. Bottom, paired differences in the memory benefit to resolve rate and in the step cost of a misplaced memory, blue for 27B and green for 9B as above, with 95% intervals.

M3: the value credit teaches when to act on memory. Paying the memory’s value to the steps that acted on it keeps the actor model from learning to follow any memory it is given (Figure 7, bottom): without the value credit a misplaced memory costs the 27B actor model 2.1 steps, while with it the cost shrinks to +0.3, and the memory benefit grows from +1.7 to +2.3 points on 27B.

Related Work

Memory design and valuation. Coding memory spans cross-task experience (Ouyang et al., 2026), within-task compression and trace validation (Gao et al., 2026; Xu et al., 2026a); MemOp evaluates memory through source-task replay and VibeMem-Bench through target-aware experience [14] (Guo et al. 2026).

Memory optimization. Reinforcement learning trains memory construction with outcome rewards (Wang et al., 2025b; Yan et al., 2026c), refines credit through shared-state rollouts (Yan et al., 2026b) and localizes it to selected turns or response tokens [6] (Xie et al. 2026). Our actor adaptation routes the memory’s on-policy value to provenance-marked steps on top of the outcome credit that every step keeps (§ 3.2).

Conclusion

Memory for successive coding tasks is what one task leaves for a task it has not seen. Its worth, measured by what the next task saves when it runs with the memory and without it, concentrates in a few anchors, the locations and checks the next task would otherwise rediscover on its own. A memory built around those anchors lowers the next task’s effort on six actor models, and an actor model trained on that value, paid where it acts on them, lowers effort further without lowering resolution.

Limitations

Our main experiments use Python repositories in the mini-swe-agent harness, and post-training covers the three open-weight actor models. Other programming languages and larger actor models remain to be tested. We measure effort by steps and cache-aware tokens and do not report wall-clock latency or energy use. How memory should be accumulated and refreshed over longer repository histories is future work.

Ethical Considerations

This work uses publicly released benchmarks, built from open-source repositories, and models in accordance with their licenses, and involves no human participants. Every agent session runs inside the per-task container image of its benchmark. In deployment, a cross-task memory may retain repository content such as file paths, commands and test output, so in private repositories it should follow the repository’s access control and retention policy, with secrets redacted before storage. As plain text, the memory can be audited and deleted.

Training Details

Boundaries are drawn without replacement with probability proportional to (ub+ϵ)gb(u_b+\epsilon)g_b. Here ubu_b is a running average of p^b(1−p^b)\hat{p}_b(1-\hat{p}_b), where p^b\hat{p}_b is a running estimate of how often the memory-free sessions at bb resolve, both at rate λ=0.25\lambda=0.25, gbg_b drops to 0.250.25 after a group at bb resolves nothing, and ϵ\epsilon is a floor that keeps every boundary reachable. A boundary the actor always or never resolves carries no outcome contrast, and the weight peaks where a resolved and an unresolved session are equally likely. Boundaries that cannot be graded are removed before training, and for the 27B actor also those that no session has ever resolved. Each training group runs G=8G=8 sessions at a boundary, four with no memory, three with memories of bb written by the frozen base actor, drawn from a pool of three per boundary for the 27B actor and twelve for the 9B, and one with a misplaced memory drawn from another repository. The reward of Eq. (4) uses W=250W=250, with nmax⁡=100n_{\max}=100 and α=50\alpha=50 for the 27B actor and nmax⁡=200n_{\max}=200 and α=16\alpha=16 for the 9B, and advantages use the fixed scale s=100s=100 rather than the group’s standard deviation, which would inflate the step differences of a group that resolves everything and would give the value credit a unit that changes from group to group, whereas a fixed scale keeps V^b/s\hat{V}_b/s comparable across boundaries. Dropping the standard deviation follows Dr. GRPO ((Liu et al., 2025)). The grouped return baseline is related to GRPO ((Shao et al., 2024)) and REINFORCE-style updates ([2]); our groups additionally separate memory conditions. The policy follows the advantages by policy gradient with a KL penalty to the base actor. The set Ub\mathcal{U}_b of Eq. (6) is collected from the first K=8K=8 steps of the memory-free sessions. The actor is a LoRA adapter on the base actor, and with xjx_j an assistant token, prefix⁡j\operatorname{prefix}_j the realised history before it and NN the number of assistant tokens in the update, the loss of session ii is

ℓi(θ)=−1N∑t∈τiAi,t∑j∈tlog⁡πθ(xj∣prefix⁡j,ci)(9)\ell_i(\theta)=-\frac{1}{N}\sum_{t\in\tau_i} A_{i,t}\sum_{j\in t}\log\pi_\theta(x_j\mid\operatorname{prefix}_j,c_i) \tag*{(9)}

with ci∈{∅,m,m~}c_i\in\{\varnothing,m,\tilde{m}\} the memory session ii ran with (m~\tilde{m} the misplaced one), Ai,t=AiA_{i,t}=A_i for sessions without their own memory, plus a KL penalty to the base actor with weight β=0.2\beta=0.2, summed over the same tokens and divided by NN. For the 9B actor the policy term of a session is instead divided by its own assistant tokens and by the number of sessions in the update. Nothing is resampled for the per-step credit, and one forward and one backward pass serve both credits. The adapter has LoRA rank and alpha 16 and is trained with AdamW at a learning rate of 2×10−42\times10^{-4} for the 27B actor and 10−410^{-4} for the 9B, with 3 warmup updates, gradient clipping at 1.0 and sampling temperature 1.0, for 20 updates. Training sequences are truncated at 32K tokens for the 27B actor and 49K for the 9B, sessions that do not return within 1,500 s and 3,600 s respectively are left out of their group, and for the 9B so are sessions that end in a repeated format error.

Training dynamics. The training reward cannot compare the two recipes, because the full method adds a step term and a value credit that resolve-only RL does not have. We therefore follow both runs on held-out sessions. Figure 8 reads the 27B actor after 8, 12, 16 and 20 updates of the full method and of resolve-only RL, which is the M1+M2 recipe without its step term, on the 96 test sessions with memory, with three replays per checkpoint, all in one window. Both runs sum their loss over tokens and share learning rate, update count, group shape and memory pool. From update 12 on, the full method keeps lowering its effort, by 0.25 steps per update, while resolve-only RL stays near 30 steps and its actor tokens rise back above those of the untrained actor. At update 20, the checkpoint of the main tables, the full method uses 2.0 fewer steps (95% CI [−4.1,+0.4][-4.1,+0.4]) and 6.9K fewer actor tokens ([−11.2,−3.1][-11.2,-3.1]) than resolve-only RL, and resolves 1.0 points more ([−2.4,+4.5][-2.4,+4.5]).

Figure 8. Training dynamics of the 27B actor on the test sessions with the memory. Lines are means over three replays and bands their standard deviation. Update 0 is the untrained actor, also drawn as the dashed line. The number beside each panel is the paired difference at update 20.

Experimental Details

Data. ChainSWE ((Jin et al., 2026)) provides 100 chains of successive tasks, each chain a sequence of real issues of one repository solved in order on the tree the earlier tasks left. We split the chains by repository, without looking at any outcome, into a training half of 52 chains (97 boundaries) and a test half of 48 chains (96 boundaries), so no repository appears in both. A test boundary is linked when the files that the gold and test patches of Tk+1T_{k+1} touch overlap those changed by earlier gold patches of its chain (54 boundaries) and unlinked otherwise (42). Training and checkpoint selection use the training half and every comparison uses the test half. The external sets are described in Appendix § 11.

Actor models and harness. Six actor models run in mini-swe-agent with a 98K-token winAlgorithm 1 One update of on-policy adaptation for memory use with provenance-gated value credit.

Require: actor πθ\pi_{\theta} as a LoRA adapter over the frozen base πbase\pi_{\mathrm{base}}; training boundaries BB with estimates p^b\hat{p}_{b}, ubu_{b} and gates gbg_{b}; a pool of memories per boundary written by πbase\pi_{\mathrm{base}} (three for 27B, twelve for 9B); a cross-repository donor pool

  1. draw 8 boundaries without replacement with probability proportional to (ub+ϵ)gb(u_{b}+\epsilon)g_{b}

  2. for each drawn boundary bb do

  3. restore SbS_{b} and run G=8G=8 sessions of πθ\pi_{\theta} on Tk+1T_{k+1}, four with no memory, three with memories of bb, one with a misplaced memory from another repository

  4. grade every session and score it by Eq. (4)

  5. if every session of the group carries a grading defect then

  6. drop the group from the update and from p^b\hat{p}_{b} and ubu_{b}, and lower gbg_{b} as for a group that resolves nothing

  7. else

  8. V^b←Rˉm−Rˉ∅\hat{V}_{b}\leftarrow\bar{R}_{m}-\bar{R}_{\varnothing}, and update p^b\hat{p}_{b} from the memory-free sessions, then ubu_{b} and gbg_{b}

  9. Ai←(Ri−Rˉ∅)/sA_{i}\leftarrow(R_{i}-\bar{R}_{\varnothing})/s on every step of the memory-free and the misplaced-memory sessions, as in Eq. (5)

  10. collect UbU_{b} from the first KK steps of the memory-free sessions and mark ωt\omega_{t} on every step of the own-memory sessions by Eq. (6)

  11. Ai,t←(Ri−Rˉm)/s+ωtV^b/sA_{i,t}\leftarrow(R_{i}-\bar{R}_{m})/s+\omega_{t}\hat{V}_{b}/s on the own-memory sessions, as in Eq. (7)

  12. end if

  13. end for

  14. update θ\theta once on ∑iℓi\sum_i\ell_i of Eq. (9) plus the KL term, over the retained sessions with nonzero credit, taken in descending mean ∣Ai,t∣\lvert A_{i,t}\rvert and skipping any that no longer fits, until the update’s token budget (350K tokens for 27B, 600K for 9B) is spent

dow, three open-weight models that we also post-train, Qwen3.5-9B (Qwen Team, 2026a), Qwen3.8-27B-FP8 (Qwen Team, 2026b) and Gemma-4-31B (Gemma Team, Google DeepMind, 2026), with a step limit of 100 for the 27B model and 200 otherwise, and three API-served models, Claude Opus 5.5 Anthropic, [4], GPT-5.6 Luna (OpenAI, 2026b) and DeepSeek-V4-Flash DeepSeek-AI, [11], with a step limit of 200.

Memory layers compared. No memory runs every next task from the inherited tree with its task description alone. Full history injects the most

recent part of the transcript of the earlier tasks. Mem0 Chhikara et al., [9], MemOp (Guo et al., 2026) and ReasoningBank (Ouyang et al., 2026) run with their official instructions and their own write and read calls, which the ledger counts on the memory side. CoReMem w/o training is our memory, written by the frozen actor model at the end of each current task’s session (App. L) and injected into the next task’s session, and CoReMem is the post-trained actor model with the same memory written by itself. Metrics. Resolve rate is the share of next tasks whose hidden tests pass on the working tree at the end of the session, reported overall and on the linked and unlinked boundaries. Steps is the number of assistant turns of a session, each one command. Tokens per session count every call of the session, cache-aware, the actor model’s own calls (Actor) and the calls of the memory module (Writer), with Total their sum. Resolve per token divides the overall resolve rate by the thousand actor or total tokens per session. For the API-served models, USD per session prices the same calls at the provider’s list rates, DeepSeek-V4-Flash at DeepSeek’s off-peak rate, a deployment-free conversion and not an expense, and resolve per USD divides the resolve rate by it.

Replays and tests. Every row is read on the mean over its replays, 12 for the frozen 9B rows, 6 to 7 for 27B, 6 for DeepSeek, 3 for Gemma and Luna and 1 for Opus. Differences against the no-memory row of the same actor model are tested with paired chain-cluster bootstrap intervals over the 48 test chains, and the main text calls a difference significant when the 95% interval excludes zero.

Post-training and checkpoint rule. The 27B and 9B actor models are post-trained with LoRA at a checkpoint chosen among the few saved during a run, on the training split and by a rule fixed in advance, resolution no lower than the base actor model’s and then the fewest steps. The Gemma actor model is post-trained for 8 updates with no checkpoint selection. App. § 7 reports the 27B actor model at every checkpoint on the test sessions.

Ablation Details

The ablation of § 4.3 and Figure 7 reads each variant with its own memory, without memory and with a misplaced memory, averaging 18/18/6 replays of these arms for w/o training, 18/9/6 for M1+M2 and 6/6/3 for the full method on 27B, and 3/3/3 on 9B except the full method with 6/3/3; the 27B resolve-only arm comes from the run of App. § 7 (3 replays in a later window). Memory benefit pairs a variant’s with-memory arm against its own no-memory arm, and misplaced cost pairs the same actor given another repository’s memory against that no-memory arm. Intervals are paired chain-cluster bootstrap 95% intervals over the 48 test chains (2000 resamples, seed 0), and an interval that excludes zero is what the main text calls significant. On the frozen 27B actor model the memory raises resolution from 21.3% to 23.4% (+2.1 [+0.4, +3.7]) and lowers steps from 35.3 to 32.6, and a misplaced memory changes steps by −0.1 [−1.7, +1.5]. Without the value credit (M1+M2) a misplaced memory costs the 27B actor model +2.1 steps [+0.4, +3.9] and with it +0.3 [−1.2, +2.1]. On 9B the with-memory and no-memory arms of the untrained, M1+M2 and full variants were read in one window, their misplaced-memory arms and the resolve-only variant in later ones. The trained variants differ from each other only in the reward and the credit rule; all share learning rate, update count, group shape, memory pool and serving path, and every variant’s untrained control shares that serving path.

Ledger of the API-served Models

Table 3 gives the ledger of the API-served models with the list-price cost per session; the open-weight models are in Table 1 and Figure 6 summarizes the API-served ones.

Results Beyond the Training Distribution

On SWE-bench Verified (OpenAI, 2024), one task per instance and no memory, the post-trained actor model resolves 4.5 points more than its untrained counterpart on 27B and 6.4 on 9B, with 7% and 22% fewer steps and 9% and 22% fewer actor tokens (Table 4). On two external task chains run with the frozen 27B actor model and the same memory-writing instruction as on Chain-SWE, our memory lowers steps by 29% on SWE-ContextBench ((Zhu et al., 2026)) and 14% on SWE-Bench-CL ((Joshi et al., 2025)). On SWEContextBench, where the next task inherits the current task’s tree, it also lowers total tokens by 38%, and the tightened instruction raises resolution by 8 points over no memory; on SWE-Bench-CL, where the memory alone crosses the boundary, resolution rises by 5 points (Table E). Under the OpenHands harness ((Wang et al., 2025a)), with the same frozen 27B actor model and memory, our memory raises resolution by 6 points and is the one memory layer that raises resolve per token, by 11%, and the post-trained actor model raises resolution by a further 5 points, to 21.3% (Table 6).

ActorCheckpointResolve (%) ↑Steps mean (med.) ↓Actor tok (K) mean (med.) ↓Raw tok (K) ↓Limit hit (%) ↓Res/Tok (actor) ↑
Qwen3.8-27B-FP8 ((Qwen Team, 2026b))untrained69.2 ±1.928.3 ±0.2 (21.2)24.7 ±0.6 (17.4)383.0 ±15.27.0 ±0.42.80 ±0.10
post-trained73.7 ±0.6 +7%**26.2 ±0.3 (20.5) −7%**22.5 ±0.2 (17.2) −9%**313.7 ±1.5 −18%**2.5 ±0.1 −64%**3.27 ±0.05 +17%**
Qwen3.5-9B ((Qwen Team, 2026a))untrained49.1 ±2.290.1 ±1.3 (86.2)93.5 ±0.4 (86.3)2471.9 ±20.67.1 ±1.90.53 ±0.03
post-trained55.5 ±0.3 +13%**69.9 ±1.4 (63.8) −22%**72.9 ±1.3 (64.1) −22%**1586.1 ±4.70 −36%**0.1 ±0.1 −99%**0.76 ±0.02 +43%**

Table 4. The post-trained actor on SWE-bench Verified. All 500 instances, one task each, no memory, 3 replays per row. The untrained row serves the zero-update adapter on the same path, and tags give the change against it (** for a paired 99% interval that excludes zero). Raw counts tokens with no credit for caching, and Limit hit is the share of instances that end at the step limit.

Table 6: Memory layers under the OpenHands harness. The 27B actor model on 94 of the 96 next tasks of the test split, mean of two runs, frozen in the upper rows and post-trained in the last row, where it is served through its LoRA adapter. Tokens are raw counts per session with no credit for prefix caching, memory module included, and do not compare with Table 1.

Memory layerResolve (%)StepsTokens (K)Resolve per M tokens
No memory10.633.889711.9
Full history14.941.817048.8
Mem011.238.311769.5
MemOp14.438.5127311.9
ReasoningBank21.848.0194311.3
CoReMem w/o training16.538.6124013.3
CoReMem21.345.9164713.0

Table 6.

SWE-bench Verified protocol. Standard SWE-bench Verified harness images and test commands; resolve is the official FAIL_TO_PASS and PASS_TO_PASS check. No memory in either row, since a Verified instance has no earlier task. The untrained row is the zero-update adapter served on the same LoRA path as the trained row, not the native base, so that the serving path does not enter the difference. Resolve grades the working tree at session end; grading only the submitted patch gives 68.9 (untrained) and 73.3 (post-trained) for 27B. The denominator is all 500 instances; on the 498 whose gold patch passes the dataset’s own test command the differences are unchanged. Paired bootstrap over instances (10,000 resamples), 27B post-trained minus untrained: resolve +4.5 [+2.4, +6.5], steps −2.2 [−3.1, −1.2], actor tokens −2.2K [−3.2, −1.3], limit hits −4.5 pp [−5.8, −3.2]; ** marks a 99% interval that excludes zero. Res/Tok is resolve (%) per thousand actor tokens. One Verified instance (pydata__xarray-3305) also appears in a ChainSWE test chain and none in a training chain.

For 9B (post-trained: the full method at the pre-registered checkpoint, after 12 updates), post-trained minus untrained: resolve +6.4 [+4.0, +8.8], steps −20.2 [−22.4, −18.0], actor tokens −20.6K [−23.0, −18.1], limit hits −6.9 pp [−8.4, −5.6], and context-window exits fall from 21.7% to 5.8%; the gold-validated subset gives the same differences.

External task chains and harnesses. Table E asks whether a memory the actor model writes for itself still lowers the next task’s effort on successive tasks we did not mine, on SWEContextBench with the inherited tree and on SWE-Bench-CL with the tree reset. Table 6 runs 94 of the 96 next tasks of the test split, the frozen and the post-trained 27B actor model and the same memory through OpenHands, with the harness alone changed.

Table 5: The memory layer off the training distribution: successive tasks of one repository on an external dataset. SWEContextBench (SCB) pairs are two-task chains of one repository in one image, the next task opening at an independent checkout from the first, so only memory crosses the border. CoReMem w/o training writes its memory under the instruction of Figure 11; we updated the writer instructions by adding that the next session starts from a new checkout without the earlier changes, that the memory should not include a summary of or reason for the changes, and that the memory should only include one clause per DID line. The adapted instructions were written after observing the first runs on the set, whose memories were getting cut off because of note length.

Memory layerLinked Res. (%) ↑Linked Steps ↓Unlinked Res. (%) ↑Unlinked Steps ↓Overall Res. (%) ↑Overall Steps ↓Tokens per session (K) Actor ↓Tokens per session (K) WriterTokens per session (K) Total ↓Res. per K tokens Actor ↑Res. per K tokens Total ↑
Qwen3.8-27B-FP8, agent without network access (n=4n=4 replays)
No memory31.659.2 (61.2)19.644.6 (37.5)28.154.9 (54.4)89.4 (60.8)–89.4 (60.8)0.3400.340
No memory, post-trained actor33.851.2 (48.0)21.439.9 (34.4)30.2 +7%47.9 (44.8) −13%76.2 (47.8)–76.2 (47.8) −15%0.4060.406 +19%
CoReMem w/o training36.840.3 (36.4)19.643.2 (39.1)31.8 +13%41.2 (39.1) −25%61.5 (41.4)5.2 (2.0)66.7 (43.4) −25%0.5610.517 +52%
CoReMem40.435.7 (32.0)16.134.8 (29.9)33.3 +19%35.4 (30.4) −35%57.6 (35.1)4.0 (1.9)61.6 (37.2) −31%0.6280.583 +71%

Table 5.

Proof of Proposition 1 {#sec:Proof of Proposition 1}

Full statement. Fix a boundary bb with memories qbq_b and veto set UbU_b, let Jbmem(θ)=EqbEm[R]J_b^{\mathrm{mem}}(\theta)=\mathbb{E}_{q_b}\mathbb{E}_{m}[R] be the expected reward of a session that runs with a memory of bb and Vb=Jbmem−E∅[R]V_b=J_b^{\mathrm{mem}}-\mathbb{E}_{\varnothing}[R] the memory’s value under the current actor. Under the credit At=(R−Jbmem)/s+ωtVb/sA_t=(R-J_b^{\mathrm{mem}})/s+\omega_t V_b/s, the population form of Eq. (7), the expected policy-gradient update on sessions that carry a memory of bb reads

gm=1s∇θJbmem(θ)+Vbs∑tEqbEm[∇θPθ(ωt=1∣ht,m)],g_m=\frac{1}{s}\nabla_\theta J_b^{\mathrm{mem}}(\theta) +\frac{V_b}{s}\sum_t\mathbb{E}_{q_b}\mathbb{E}_m\left[\nabla_\theta P_\theta(\omega_t=1\mid h_t,m)\right],

where the gradient in the second term acts on the policy at step tt with the history hth_t held fixed. Because ωt\omega_t depends on the step and its history and not on θ\theta, the expected score of the steps it selects is the gradient of the probability of selecting them, so the memory’s value pushes how often the actor acts on the memory. Paid to every step instead, the same value multiplies E[∇θlog⁡πθ(τ∣m)]=0\mathbb{E}[\nabla_\theta\log\pi_\theta(\tau\mid m)]=0 and teaches nothing about memory use.

Setup. Fix the current parameters θ\theta and condition on one memory m∼qbm\sim q_b; the statement follows by averaging over mm, whose distribution does not depend on θ\theta. A session τ∼πθ(⋅∣Sb,m)\tau\sim\pi_\theta(\cdot\mid S_b,m) is a finite sequence of steps, at each of which the actor emits a message xtx_t after a history hth_t, and the environment’s responses do not depend on θ\theta. The provenance ωt=ω(xt,ht)∈{0,1}\omega_t=\omega(x_t,h_t)\in\{0,1\} of Eq. (6) is a deterministic function of the message, its history and the veto set, and does not depend on θ\theta. Write Jm=Em[R]J_m=\mathbb{E}_m[R] for the expected reward under this mm, take JbJ_b and VbV_b as in the proposition, constants that do not depend on the sampled mm, and hold the veto set fixed.

Proof of Proposition 1. The per-step credit defines the ascent direction

gm=Em[∑tAt∇θlog⁡πθ(xt∣ht,m)]g_m=\mathbb{E}_m\left[\sum_t A_t\nabla_\theta\log\pi_\theta(x_t\mid h_t,m)\right]

with

At=(R−Jbmem)/s+ωtVb/s,A_t=(R-J_b^{\mathrm{mem}})/s+\omega_tV_b/s,

which the loss of Eq. (9) follows up to the normalisation discussed below. For the first part, the environment does not depend on θ\theta, so ∑t∇θlog⁡πθ(xt∣ht,m)\sum_t\nabla_\theta\log\pi_\theta(x_t\mid h_t,m) is the score of the session, its mean is zero, and

Em[(R−Jbmem)∑t∇θlog⁡πθ(xt∣ht,m)]=∇θJm,\mathbb{E}_m\left[(R-J_b^{\mathrm{mem}})\sum_t\nabla_\theta\log\pi_\theta(x_t\mid h_t,m)\right]=\nabla_\theta J_m,

and averaging over m∼qbm\sim q_b gives ∇θJbmem\nabla_\theta J_b^{\mathrm{mem}}. For the second, conditioning on hth_t and using that ω\omega does not depend on θ\theta,

E[ω(xt,ht)∇θlog⁡πθ(xt∣ht,m)∣ht]=∑xω(x,ht)∇θπθ(x∣ht,m)=∇θPθ(ωt=1∣ht,m),\mathbb{E}\left[\omega(x_t,h_t)\nabla_\theta\log\pi_\theta(x_t\mid h_t,m)\mid h_t\right] =\sum_x\omega(x,h_t)\nabla_\theta\pi_\theta(x\mid h_t,m) =\nabla_\theta P_\theta(\omega_t=1\mid h_t,m),

and taking the expectation over hth_t, summing over tt and averaging over m∼qbm\sim q_b yields the second term, with the constant VbV_b passing through the average. Under whole-trajectory credit ωt\omega_t is replaced by one, the same conditioning gives ∑x∇θπθ(x∣ht,m)=∇θ1=0\sum_x \nabla_\theta\pi_\theta(x \mid h_t,m)=\nabla_\theta1=0 for every tt, and the memory’s value contributes nothing.

Remark on the cancellation. At every step ∇θPθ(ωt=1∣ht,m)+∇θPθ(ωt=0∣ht,m)=0\nabla_\theta P_\theta(\omega_t=1\mid h_t,m)+\nabla_\theta P_\theta(\omega_t=0\mid h_t,m)=0. Paying the memory’s value to every step therefore adds, to the push toward the memory-driven actions, an equal and opposite push toward all the others, and the two cancel in expectation while both remain in the variance. The gated credit pays the first and withdraws the second.

Remark on the sample baselines. In training the two expectations are group means. On a memory-driven step the credit is (Ri−Rˉ∅)/s(R_i-\bar{R}_{\varnothing})/s, whose baseline is computed from other sessions and is independent of the one it is subtracted from. On every other step the baseline Rˉm\bar{R}_m includes the session itself, which scales the expected contribution of those steps by 1−1/nm1-1/n_m, with nm=3n_m=3 the number of own-memory sessions in the group, and leaves its direction unchanged. Under whole-trajectory credit the same self-inclusion turns the value term into 1nms∇θJm\frac{1}{n_m s}\nabla_\theta J_m, a rescaling of the outcome gradient with no push specific to memory-driven steps. The loss of Eq. (9) sums each step’s credit over its tokens and divides by the update’s token count, so for the 27B actor its gradient is the per-step estimator of the proposition scaled by a positive constant. The own-memory sessions of a group carry different memories of bb, so V^b\widehat{V}_b estimates the value of a memory for bb written by the base actor, averaged over those memories, which the proposition states with qbq_b.

Provenance Calibration

The gate of Eq. (6) reads the whole assistant message of a step, its reasoning text and its command, so an anchor named in the reasoning text counts as much as one in the command, and each anchor is credited at its first use. We calibrate provenance as training uses it, with the sibling veto over the first 8 steps, on the post-trained 27B actor’s held-out sessions with its own memories (288 sessions over three replays). Under a real memory 3.46% of steps carry provenance and 169 of the 288 sessions have at least one. Memory-free sessions scored against the memory they would have seen give a leakage null of 1.61% of steps, and misplaced memories give 1.05%. Credited steps concentrate late in a trajectory, with deciles 7 to 9 at about twice the rate of deciles 4 to 6 (ratio 2.02 [1.52, 2.78]), where the actor runs tests and the anchors it uses come from the memory’s TESTS and VERIFY lines. Steps that match the memory early, when the actor opens the files it names, are mostly steps that memory-free sessions also take, so the veto removes about 88% of them and leaves about 3% of credited steps in the first decile.

The early-window veto. The window KK was fixed before the arm was trained, on the 480 own-memory rollouts of an earlier training run. With no veto 5.5% of steps are memory-driven, with the veto over the first 8 steps of the memory-free sessions 1.9%, and with a veto over their whole length 0.65%. Memory-free sessions have a median of 26 steps, so the first 8 are an early prefix, and a veto over their whole length would remove most of what the memory supplied. In practice, a test command the memory lists is memory-driven at the step that first runs it, and not if the session ran it earlier or the memory-free sessions reach it in their first steps; a memory-free session has ω=0\omega=0.

Why not a likelihood ratio. The natural alternative weights a step by the ratio of its message’s likelihood with and without the memory in context. This alternative is related to context attribution (Cohen-Wang et al., [10]) and to probability contrasts used in context-aware decoding (Shi et al., 2024) and PMI-based summarization (van der Poel et al., 2022); their targets are attribution or faithfulness rather than executable-task effort. On this actor that ratio carries no signal. In a pilot of 36 sessions on the 27B actor its AUC is 0.506 for real against the null, and the weight moves with message length rather than with message content. A flat ratio next to a sharp anchor match says that the memory changes a few actions rather than conditioning the whole distribution, which is why the credit signal is provenance and not likelihood.

Segments of a Trajectory

Each step of a trajectory is an assistant message, made of reasoning text and a shell command, followed by the output of that command. The command goes to the commands segment together with the exit code of its step, and the output goes to one segment by what produced it, under rules fixed before the study (the first match wins). Output of a command that prints a diff (git diff, git show, a patch file) goes to the change segment; output of a test runner (pytest, tox, unittest and the like), of a script written in the session or of inline Python that contains an assert goes to the test segment; all other output goes to the repository segment, including that of linters such as flake8, which the list does not name. The change the task left in the tree joins the change segment. The outcome and the scratch files come from the boundary, not from the transcript, and harness format messages (0.05% of the material) are left out. Each segment is cut to a fixed quota (4,000 characters, 200 for the outcome and 800 for scratch files), so a segment is the same text in every arm that contains it. None of these assignments reads what the text says, since each segment is read off what the harness records, the assistant message, the command and its exit code, its output, the diff and the end of the session. Table 7 defines the seven segments with an example from one real session, shown in Figure 9.

SegmentWhat it holdsIn the example session (Figure 9)
Reasoning textThe actor’s own text in each step, outside the command“Now let me verify the fix works with a test script.” (step 8)
CommandsEvery command the actor ran, in order, with the shell exit code of its step (0 for success, nonzero for failure)python -m pytest tests/ -k "sim102" -q [exit 0] (step 9); a grep on a file that does not exist [exit 2] (step 2)
Repository contentOutput of commands that read or search the repository, and of any other command that is not a testThe file list of flake8_simplify/rules/ and the two lines of ast_if.py that mention SIM102 (step 3); the flake8 warning on the negative case (step 8)
Test outputOutput of test runners, of scripts written in the session and of inline Python with an assert4 passed, 88 deselected (step 9); 90 passed, 2 xfailed (step 10)
ChangeThe diff the task left in the tree, and output of commands that print a diff23 added lines in ast_if.py that define is_main_check and call it (step 11)
OutcomeHow the session ended, its exit status and step countSubmitted after 12 steps
Scratch filesPaths the session’s commands wrote, by shell redirection or from Python, and whether each still exists when the next task starts/tmp/test_sim102.py and /tmp/test_sim102b.py (gone), patch.txt at the repository root (kept)

Table 7. The seven segments of a trajectory. The first five partition the transcript, and the last two come from the boundary.

Three compressed forms are valued alongside the segments and decide how a kept segment is written: the failing commands with their output (here steps 1 and 2, a search that found nothing and a grep on a missing file), the tests with their exit codes but no output, and the file list of the change. The exit code is recorded once per step, so when a command pipes into tail (steps 9 and 10) it is the code of the pipeline, and the test’s own result is in its output.

The example comes from the first task of a three-task chain on flake8-simplify in the training split, run by the frozen 27B actor. The memory it wrote in its last turn is the one in Figure 10, and its lines trace back to the trajectory as follows. FILES and the WHERE of DID come from the change, whose added lines sit exactly at lines 34–58 of ast_if.py. STATUS comes from the outcome and TESTS from the full test run of step 10. The two VERIFY lines are the commands of steps 9 and 8 with their exit codes. The CONTEXT lines come from the repository content read in step 3 (one rule file per AST node type, SIM102 in ast_if.py) and in steps 4 to 6 (constants.py, utils.py), and from the test output of step 10 (90 passed, 2 xfailed). None of the reasoning text reaches the memory.

A memory written in-session by the 27B actor

Figure 10. A real memory and its anchors. The memory has 889 characters and 18 anchors.

Segment and Field Tests

App. J reads the result of every segment into a line of the memory (Table 8). Rerun on the training half alone, the segment conditions support the same choices for the commands, the repository content, the tests and the reasoning text, with Shapley values ((Shapley, 1953; Ghorbani and Zou, 2019)) of +3.09, +2.67 and +2.40 steps for the first three and a negative one for the reasoning text, and test commands with their exit codes alone save +4.03 steps. The memory also lowers steps on two external sets (App. § 11). The step differences quoted in § 3.1 are medians with BH-adjusted p∗=.0070p^*=.0070 for the commands (56/27) and p∗=.0302p^*=.0302 for the repository content read (52/34). Against the material it replaces, the memory keeps the whole median step saving on linked boundaries, 2 of 2 steps, with 6% of its bytes (1,056 against 17,320 characters) and a ratio interval of [0.50, 2.00], which meets a retention margin of 0.50, and gives up no measurable step (47/39, p=.48p=.48).

From Raw History to the Memory

This appendix records how each line of the CoRe-Mem memory was obtained from the raw session, and where each decision came from. The derivation ran in five steps. The first three are mechanical, the fourth arranges the fields into the memory’s two blocks, and the fifth validates the result. Table 8 maps every segment measurement to the line it produced.

Step 1, segments. The current task’s session is split by the role each piece of text plays, namely the agent’s reasoning (C1), the commands it issued (C2), the repository content it read (C3), the feedback of its tests (C4), the change it left (C5), its outcome (C6) and its scratch files (C7). The outcome segment is cut in two, the outcome the writer can observe and the verdict of the hidden tests, and the latter may never enter a memory. Three compressed forms are added as probes, the failing commands with their output, the diff’s file list, and the test commands with their exit codes but no output.

Step 2, values. Each segment subset is valued by replaying the next task from the fixed state the current task left (§ 3.1). The subsets are no segment, all segments twice, all but one segment and one segment alone, plus the three probes. A segment’s carried share is the fraction of the whole material’s median step saving that it keeps when injected alone. The readings below are on linked boundaries (App. § 8) unless stated otherwise.

Step 3, inventory and constraints. A decision program turns the values into the list of fields and the constraints on how each is written. It emitted VERIFY, CONTEXT, DID, TESTS and a one-line reason field, and fixed four constraints. The location of a change is written as anchors with its diff body banned, a failed check stays a VERIFY entry with its nonzero exit code, a test result is the exit code of its command, and the hidden-test verdict never appears.

Step 4, layout. The fields go into two blocks. The task block opens with FILES, the files the session modified or tested, and holds STATUS, VERIFY and DID, which describe this session’s task; the repository block holds the CONTEXT facts that hold for any task. The reasoning segment carried no step value, so the reason field was dropped, and TESTS was merged into the STATUS line.

Step 5, validation. The memory is compared with the raw material it replaces and keeps its whole median step saving with 6% of its bytes (App. § 15).

Scope of the procedure. Steps 2 and 5 use only paired replay and the next task’s cost, so they apply wherever sessions follow one another on persistent state. Steps 1 and 3 need a split of the session by role and a definition of an anchor, which on Chain-SWE are the seven segments and the locations and checks of Definition 1.

Anchors

Definition 1. Definition 1 is implemented as a string matcher, the same one that marks memory-driven steps in §3.2.2.

A text is split into tokens, and a token is an anchor when it falls into one of the four kinds of Table 9. Three filters keep generic strings out. Tokens shorter than six characters are dropped, as are tokens whose every part is a common English or shell word (command-line, pytest), and scaffolding found in nearly every repository (setup.py, conftest.py, reproduce.py and paths under /tmp). A path:lines reference is matched on its path, so the line range in a memory guides the next task without being required for a match. For provenance ((6)) the memory’s anchors are further reduced to those absent from the session so far and from what the memory-free sessions of the same group reach in their first eight steps.

KindRoleRuleExample
File pathlocationhas a / and a letter, or a code extensionflake8_simplify/rules/ast_if.py
Symbollocationsnake, camel, dotted or hyphenated, not all common wordsis_main_check, ast.Constant
Test node idcheckcontains ::; its path and name also counttests/test_x.py::test_y
Command tokenchecknon-flag token inside a command or a VERIFY/TESTS fieldflake8,sim102

Table 9. The four kinds of anchor. Examples are from the memory in Figure 10 except the node id, whose form is shown.

Memory Templates

Our memory is written by the acting model itself, in a final turn appended to the session that ends a task, under the instruction in Figure 11, reproduced verbatim from the deployed file (SHA-256 02a36ea0...). A malformed memory gets one corrective retry, and a session that still ends without a valid memory has it written in a separate call.

Memory-Writing Instruction (final turn of the session)

Figure 11. The instruction under which the actor writes its memory, verbatim from the deployed file. It states what the next session can see, fixes the memory’s two blocks and five line types, sets the rules and shows the finished shape. Bold, shading and gray placeholders are ours.

Design Choices and Their Alternatives

This section sets out the alternatives to three design choices and what the paper’s own measurements say about them.

Adapting the actor rather than training a separate memory reader. A separate reader, or a retrieval policy, decides what memory to hand the actor, either before the task or between its steps. In our setting the memory is short, at most ten lines, and already sits in the actor’s context, so the open question is not which memory to show but whether and when the actor acts on it. Which steps use the memory emerges as the task unfolds. What a coding agent needs is often not evident from the task description and surfaces as it explores and executes, so a single retrieval keyed on the task input falls short of multi-step repository exploration (Trivedi et al., 2023; Yang et al., 2024; Zhang et al., 2026a), retrieval from the unfinished code alone misses what a draft reveals (Zhang et al., 2023), and memory retrieved per subtask during execution outperforms memory retrieved by whole-task similarity (Shen et al., 2026). Under the detector that training uses, credited steps concentrate late in a trajectory, where the actor runs the tests.

the memory names, while early steps that match the memory are mostly steps the actor takes without any memory (App. § 13). A reader that selects memory up front cannot see this, and a reader that re-selects at every step would need the same per-step signal we give the actor. We therefore adapt the actor itself and pay the measured value to the steps that use the memory. Retrieval stays compatible with this choice, since a retrieval policy decides what memory enters the context and the adaptation changes what the actor does with it. Related controllers decide when to inject reminders (PMA; Wu et al., 2026), whether to retrieve or abstain (RSCB-MC; Iscan, 2026), and how to navigate memory at different granularities (NapMem; Xu et al., 2026b). These choices concern memory access, whereas our update targets execution after a short memory is already present.

A LoRA adapter rather than a separate model or full fine-tuning. A separate memory model leaves the actor untouched but cannot change how it acts on memory, and full fine-tuning can move the actor’s general coding behaviour. A LoRA adapter on frozen base weights is the middle ground, a low-rank update that bounds how far the actor moves while letting it adapt its use of memory. Whether general capability survives is a measurement, not a property of the adapter. On SWE-bench Verified, with no memory in context, the adapted 27B and 9B actors resolve 4.5 and 6.4 points more than their untrained counterparts with 7% and 22% fewer steps (Table 4), so on this benchmark the adaptation cost no general capability.

Paying the value through provenance rather than leaving it to the outcome reward. Outcome reward already favours whatever raises RR, including a good use of memory, but it spreads one scalar over every step of a session, and the steps that use the memory are about three percent of them (App. § 13). Proposition 1 shows that paid to every step the measured value is a baseline, while paid through the gate it becomes a push on how often the actor acts on the memory, sized and signed by the on-policy measurement. Figure 7 compares this credit with whole-trajectory credit under the same reward. A gate read from how much the memory raised a step’s likelihood is the natural alternative to anchor provenance and carried no signal on this actor (App. § 13).

Related Work

Agent memory beyond coding. Agent memory encompasses reflective feedback and extracted experience (Shinn et al., 2023; Zhao et al., 2024), reusable workflows and executable skills (Wang et al., 2025c, 2024), and adaptive inference-time experience (Suzgun et al., 2025; Tang et al., 2025). Other systems organize episodic or conversational information through reflection, retrieval, memory hierarchies and linked records (Park et al., 2023; Zhong et al., 2024; Packer et al., 2023; Xu et al., 2025). MemOS and EverMemOS address memory organization and lifecycle management (Li et al., 2025; Hu et al., 2026); Zhang et al. (2024) survey the broader design space.

Memory for coding agents. Memory systems keep different forms of experience: Mem0 extracts facts from conversations ([9]), ReasoningBank and SWE-Exp distill lessons from past trajectories ([7] (Ouyang et al. 2026)), Repository Memory and MemCoder mine commit history for localization and development knowledge ([13] (Wang et al. 2026)), and MemOp maintains a per-repository guidebook with a trained writer (Guo et al., 2026). These approaches emphasize retained experience or repository knowledge; our setting additionally carries the actual edited repository state. AdaRepair-Mem selects repair experience by coverage, quality and repair stage (Luo et al., 2026b). Repository context files also require empirical evaluation: AGENTS.md studies find that added instructions need not improve success and can increase cost (Gloaguen et al., 2026). Persistent project information appears in deployed assistants through Claude Code’s auto memory and Codex’s cross-session memory generation and injection ([3] (OpenAI 2026a)). Within one task, SWE-MeM and CompactR-CLN learn context compression jointly with issue resolution (Gao et al., 2026; Li et al., 2026c), and the concurrent MemTrace re-validates stored execution traces against the evolving repository (Xu et al., 2026a); these memories do not outlive the task. CAMG-RL likewise learns file-based memory operations across context boundaries within an episode (Luo et al., 2026a). Between the two lies the boundary a deployed agent meets, a memory written before the next task is known and read in the repository state the last task left.

Broader memory evaluation. LoCoMo and LongMemEval test long-term conversational memory (Maharana et al., 2024; Wu et al., 2025), StateMemBench tests evolving-state tracking ([15]), and MemoryArena couples memory with interdependent multi-session actions (He et al., 2026). LongCodeBench evaluates long-context code comprehension and repair (Rando et al., 2025). These settings probe memory retention and use, while our evaluation measures the effort saved on an unseen coding task from inherited repository state.

Evaluating memory on executable tasks. SWE-bench grades each issue from its own snapshot (Jimenez et al., 2024), whereas ChainSWE chains fixes in a shared workspace (Jin et al., 2026) and SWE-Milestone reports resolve falling from above 80% to 38% once state is carried ([12]); SWEContextBench and Handoff Debt study reuse across related issues and the cost of resuming an interrupted one (Zhu et al., 2026; KC and Budathoki, 2026). Memory-specific evaluations isolate the retained information: MemOp reruns the source task with and without a candidate memory (Guo et al., 2026), VibeMemBench pairs memory-off and memory-on runs of one target whose history is summarised with the target in view ([14]), and Decision-Aware Memory Cards score evidence by a heuristic estimate of its effect on the next action (Guan et al., 2026). Related proxies include interventions on candidate memories for answer quality (Srivastava, 2026), answer-conditioned information gain (Han et al., 2026), and Shapley-based context filtering for code completion (Huo et al., 2026). MemDelta emphasizes controlled model and retrieval comparisons and write-path cost accounting (Wang, 2026). These evaluations complement our paired runs of an unseen next task from the inherited tree, which measure resolution and effort and attribute savings to trajectory segments (§ 3.1).

Learning memory construction and use. Reinforcement learning has been applied to both sides of the memory interface. Writers are trained from outcome reward or neighbourhood-level marginal utility (Wang et al., 2025b; Yan et al., 2026c; Ye et al., 2026), with finer credit from rerolling at a shared memory state (Yan et al., 2026b), hindsight-filtered utility on writing tokens (Yan et al., 2026a), or token-level attribution (Li et al., 2026a); RoMeRL notes the outcome-broadcast trap but treats paired rollouts as infeasible (Yang et al., 2026). On the reading side, ECHO routes outcome credit to the turns a policy selects back into context (Xie et al., 2026), and MemCam labels credit by atom ablation ([6]). End-to-end memory learning also includes recurrent consolidation in MEM1 (Zhou et al., 2025), chunk-wise processing in MemAgent (Yu et al., 2025), self-memory policies in MemPO (Li et al., 2026b), and operation-tree credit in Mem-T (Yue et al., 2026). These methods optimize different memory interfaces and credit granularities. Our contribution pairs on-policy valuation on executable next tasks with provenance-gated routing of the additional memory-value term, while retaining outcome credit at every step (§ 3.2).

Credit assignment beyond memory. Classical RL assigns hindsight credit to past actions (Harutyunyan et al., 2019) or uses counterfactual baselines to separate action contributions ([17] (Mesnard et al. 2021)). For language models, process supervision supplies intermediate labels (Lightman et al., 2024), VinePPO estimates step values with sampled continuations (Kazemnejad et al., 2025), GiGPO groups repeated states for local advantages ([16]), and C3 replays downstream continuations after message interventions in agent teams ([8]). These methods address action or message utility; our provenance gate identifies traceable memory use and routes measured memory value without estimating each step’s causal effect.

Efficient coding and policy training. SWE-Gym and SWE-smith expand executable training tasks and agent trajectories (Pan et al., 2025; Yang et al., 2025), while SWE-RL trains on software-evolution data (Wei et al., 2025). SWE-Edit reduces overhead through editing-interface decomposition (Zhang et al., 2026b); L1 and efficient-reasoning RL shape generation length and inference compute ([1, 5]). These approaches complement our focus on information reuse and memory use across task boundaries.

References

  1. [1]Pranjal Aggarwal and Sean Welleck. 2025. L1: Controlling How Long a Reasoning Model Thinks with Reinforcement Learning. In Conference on Language Modeling (COLM).arxiv.org/abs/2503.04697
  2. [2]Arash Ahmadian, Chris Cremer, Matthias Gallé, Marzieh Fadaee, Julia Kreutzer, Olivier Pietquin, Ahmet Üstün, and Sara Hooker. 2024. Back to Basics: Revisiting REINFORCE-Style Optimization for Learning from Human Feedback in LLMs. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), ACL 2024, pages 12248–12267. Association for Computational Linguistics.arxiv.org/abs/2402.14740
  3. [3]Anthropic. 2026a. How claude remembers your project. Documentation accessed October 12, 2026.
  4. [4]Anthropic. 2026b. System Card: Claude Opus 5.5.
  5. [5]Daman Arora and Andrea Zanette. 2025. Training Language Models to Reason Efficiently. arXiv preprint arXiv:2502.04463.arxiv.org/abs/2502.04463
  6. [6]Ruike Cao, Fanyu Zhao, Fugen Yao, Liang Dong, Jian Xu, Yifei Zhao, Han Zhang, and Li Xiao. 2026. Mem-Calib: Benchmarking and Optimizing Memory Use in LLM Agents. arXiv preprint arXiv:2609.24259.arxiv.org/abs/2609.24259
  7. [7]Silin Chen, Shaoxin Lin, Yuling Shi, Heng Lian, Xiaodong Gu, Longfei Yun, Dong Chen, Lin Cao, Jiyang Liu, Nu Xia, and Qianxiang Wang. 2025. SWE-Exp: Experience-Driven Software Issue Resolution. arXiv preprint arXiv:2507.23361.arxiv.org/abs/2507.23361
  8. [8]Yanjun Chen, Yirong Sun, Hanlin Wang, Jinghan Wang, Xinming Zhang, Xiaoyu Shen, Wenjie Li, and Wei Zhang. 2026. The Trace Is the State: Exact Credit Assignment for LLM Agent Teams. arXiv preprint arXiv:2603.06859.arxiv.org/abs/2603.06859
  9. [9]Prateek Chhikara, Dev Khant, Saket Aryan, Taranjeet Singh, and Deshraj Yadav. 2025. Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory. In ECAI 2025 — 28th European Conference on Artificial Intelligence, Bologna, Italy, October 25–30, 2025, volume 413 of Frontiers in Artificial Intelligence and Applications, pages 2993–3000. IOS Press.arxiv.org/abs/2504.19413
  10. [10]Benjamin Cohen-Wang, Harshay Shah, Kristian Georgiev, and Aleksander Madry. 2024. ContextCite: Attributing Model Generation to Context. In Advances in Neural Information Processing Systems (NeurIPS), volume 37.
  11. [11]DeepSeek-AI. 2026. DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence. arXiv preprint arXiv:2606.19348.arxiv.org/abs/2606.19348
  12. [12]Gangda Deng, Zhaoling Chen, Zhongming Yu, Haoyang Fan, Yuhong Liu, Yuxin Yang, Dhruv Parikh, Rajgopal Kannan, Le Cong, Mengdi Wang, Qian Zhang, Viktor Prasanna, Xiangru Tang, and Xingyao Wang. 2026a. SWE-Milestone: Evaluating AI Agents on Continuous Software Evolution. In Proceedings of the 43rd International Conference on Machine Learning, volume 306 of Proceedings of Machine Learning Research, pages 23853–23890. PMLR.arxiv.org/abs/2603.13428
  13. [13]Yi-Xuan Deng, Xiaoqin Liu, Yi Zhang, Guo-Wei Yang, and Shuojin Yang. 2026b. Your Code Agent Can Grow Alongside You with Structured Memory. arXiv preprint arXiv:2603.13258.arxiv.org/abs/2603.13258
  14. [14]Liyang Fan, Yingcheng Shi, Yongbin Li, Chenchao Sun, Xin Chen, Xander Xu, Hu Wei, Shiwen Ni, Min Yang, and Jieping Ye. 2026a. VibeMemBench: Evaluating Memory Systems for Coding Agents on Real Repository Coding Tasks. arXiv preprint arXiv:2609.23570.arxiv.org/abs/2609.23570
  15. [15]Xinyi Fan, Miri Liu, Ruozhen Yang, Siru Ouyang, and Jiawei Han. 2026b. Can Agent Memory Systems Track Evolving State? arXiv preprint arXiv:2608.19652.arxiv.org/abs/2608.19652
  16. [16]Lang Feng, Zhenghai Xue, Tingcong Liu, and Bo An. 2025. Group-in-Group Policy Optimization for LLM Agent Training. In Advances in Neural Information Processing Systems (NeurIPS), volume 38.arxiv.org/abs/2505.10978
  17. [17]Jakob Foerster, Gregory Farquhar, Triantafyllos Afouras, Nantas Nardelli, and Shimon Whiteson. 2018. Counterfactual Multi-Agent Policy Gradients. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32.arxiv.org/abs/1705.08926

Paper details

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

views · 1

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