🚀NEW LABGetting Started with Claude AgentsStart lab
← All papers  /  Oct 7, 2026
Code · Memory · Agents

MemTrace: State-Consistent Memory for Long-Horizon Coding Agents

First page
MemTrace: State-Consistent Memory for Long-Horizon Coding Agents
The curator’s take

Hongming Xu, Zhiyu Li, Juncheng Zhang and colleagues at Shanghai Jiao Tong University and MemTensor introduce MemTrace, a memory system for long-horizon coding agents that checks recalled evidence against the current repository state before reusing it.

Ask this paper

Key points
01

Two failure modes. Long trajectories strain the context budget, and later code edits can invalidate evidence gathered earlier, such as a test result for a file that has since changed.

02

Memory Traces. History is stored as immutable traces anchored to files, symbols and tests, linked in a graph that records execution order and dependencies. After a context refresh, the working context keeps only compact anchors from which the latest state is rebuilt.

03

Validity check. Before restoring a trace, MemTrace checks it against the repository's current state and retrieves only what the next action needs.

04

Results. Under Codex CLI with a fixed backbone, it raises DeepSWE pass@1 by 21.2 points, SWE-EVO resolved rate by 4.4 points and SWE-Milestone score by 17.8 points over every fully evaluated baseline, with gains in a second harness as well.

Abstract

As coding agents take on long-horizon software evolution tasks spanning multiple files and stages, longer execution trajectories introduce two coupled challenges: (1) accumulated histories strain context budgets, and (2) repository changes can invalidate earlier execution evidence. Existing approaches address these challenges through techniques like larger context windows, compression, retrieval, or repository representations, but often fail to reconstruct a consistent task state after a context refresh or verify whether recalled evidence remains valid. Thus, we introduce MemTrace, a provenance-aware memory system that preserves execution history and aligns its reuse with the evolving task (e.g., iterative cross-file repair) and repository state. MemTrace stores history as immutable Memory Traces anchored to key information (e.g., files, symbols, tests), and organizes their execution order and dependencies in a Memory Trace Graph. When context is constrained, working memory retains only compact Memory Anchors, from which the agent can reconstruct the latest execution state and locate evidence relevant to its next action. Before restoring historical evidence, MemTrace checks its validity against the current repository state and retrieves only what the next action requires. Across three complementary long-horizon coding benchmarks, MemTrace consistently outperforms all fully evaluated baselines under the same backbone and harness, improving DeepSWE pass@1 by 21.2 points, SWE-EVO Resolved Rate by 4.4 points, and SWE-Milestone Score by 17.8 points under Codex CLI.

Every Monday
Get next week’s papers.
Subscribe on Substack