MemTrace: State-Consistent Memory for Long-Horizon Coding Agents
Hongming Xu, Le Zhou, ZhongHe Jin, Xiang Zhang, Bo Tang, Zhiyu Li, Xuanhe Zhou, Juncheng Zhang
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.
Create a lesson
Metadata
- Comments
- 20 pages, 7 figures. Code: https://github.com/Homy-Xu/MemTrace
Related papers
AMBER: Training Long-Horizon Web Agents through Append-Only Memory
Shared title terminologycs.AIChinmay Savadikar, Zhaoyu Zhang, Mingyu Zhao et al.
E2SIM: Long-Horizon Simulation of Everyday Human Behavior with Evolving States
Shared title terminologycs.AIZiwei Gong, Xiangyang Yin, Thai Quoc On et al.
DMC-5: Dual-Model Collaboration with Cache-aware Context Compression for Long-horizon Agents
Shared title terminologycs.AIHaochen Li, Xiaobing Tu, Yinggui Wang et al.
What Did the Agent Actually Do? Evidence-Grounded Oversight for Long-Horizon Agents
Shared title terminologycs.AIZhongxiang Sun, Jiahao Yan, Hongkang Zhao et al.
RocketAgent: A Long-Horizon Engineering Agent for Multidisciplinary Design of Liquid-Rocket Thrust Chambers
Shared title terminologycs.AIJunxiang He, Runze Mao, Kun He et al.
Runtime Authorization of Self-Generated Subgoals in Long-Horizon Tool-Using AI Agents
Shared title terminologycs.AIGenliang Zhu, Chu Wang