The Hidden Costs of Forgetting: A Study of Trajectory Deletion in Software Engineering Agents
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
Software engineering agents resend their entire trajectory to an LLM at every turn, motivating online trajectory reduction. Prior work shows that randomly deleting 75% of tokens in old turns may preserve agent effectiveness, but it remains unclear why, how agents compensate for missing content, and whether it actually reduces costs. This paper presents an empirical study of 42 trajectory-reduction configurations, focusing on effectiveness, agent behavior, and cost. We systematically explore deleting content from old turns by varying the scope, granularity, amount, and timing of deletion across 9,400 runs with two state-of-the-art agents on SWE-bench Verified. We find deleting large amounts of trajectory content (e.g., up to 100% of reasoning text) can preserve overall effectiveness. Importantly, such deletion must be applied with a delay, as immediate deletion tends to significantly degrade effectiveness. Agents often compensate for deleted content by re-fetching it, increasing both the number of turns taken and the input/output tokens. Whether trajectory reduction reduces costs depends on the pricing model: Under a flat pricing model, estimated costs fall in 26 of 42 evaluations. Surprisingly, under a caching-aware pricing model, zero evaluations yield lower costs, since reducing the trajectory breaks the cached prefix billed at a lower rate. Our findings have three implications: First, token counts alone are misleading; trajectory reduction techniques must consider overall costs under a realistic pricing model. Second, analyzing trajectories is crucial to understand agent behavior, as end-to-end effectiveness hides differences such as excessive re-fetching. Finally, these results highlight the need for future work on memory management to reduce costs without sacrificing effectiveness.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 32 of its 40 references that are in the map. Submitted 26 Oct 2026.
Builds on
32 of 40 references.
Closest ancestors · 16
Same direction, newest first
- 2026AutoCompact: Learning When to Compact Context in Long-Horizon Coding Agents1 Oct
- 2026Beyond Token Savings: A Systematic Study of Context Compression in LLM Agents26 Sep
- 2026AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents8 Sep
- 2026TokenPilot: Cache-Efficient Context Management for LLM Agents15 Jun
- 2026SWE-chat: Coding Agent Interactions From Real Users in the Wild22 Apr
- 2026Wink: Recovering from Misbehaviors in Coding Agents19 Feb
- 2026SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents23 Jan
- 2025Context as a Tool: Context Management for Long-Horizon SWE-Agents26 Dec
- 2025Does SWE-Bench-Verified Test Agent Ability or Model Memory?11 Dec
- 2025Process-Centric Analysis of Agentic Software Systems2 Dec
- 2025Reducing Cost of LLM Agents with Trajectory Reduction28 Sep
- 2025Trae Agent: An LLM-based Agent for Software Engineering with Test-time Scaling31 Jul
4 more
- 2025Understanding Software Engineering Agents: A Study of Thought-Action-Result Trajectories23 Jun
- 2025Understanding Automated Program Repair Agents Through the Lens of Traceability: An Empirical Study10 Jun
- 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agents23 Jul
- 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering6 May
Other references · 16
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 6,685
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,871
- 2023SGLang: Efficient Execution of Structured Language Model Programscited by 1,372
- 2026DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligencecited by 1,363
- 2024LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compressioncited by 397
- 2023LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Modelscited by 324
- 2025ACON: Optimizing Context Compression for Long-horizon LLM Agentscited by 171
- 2023An Empirical Study of the Non-determinism of ChatGPT in Code Generationcited by 161
- 2025The Complexity Trap: Simple Observation Masking Is as Efficient as LLM Summarization for Agent Context Managementcited by 73
- 2025The SWE-Bench Illusion: When State-of-the-Art LLMs Remember Instead of Reasoncited by 64
- 2026How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding Taskscited by 48
- 2026Token Reduction Is Not Cost Reductioncited by 9
4 more
- 2026AGORA: Adapter-Grounded Observation-Action Retention for Inference-Free Prompt Compression in LLM Agentscited by 5
- 2026What Does Context Compression Cost an Agent? Interaction Costs Unrevealed by Task-Completion Metricscited by 5
- 2026When Can Agents Forget Their Reasoning? ICLR for Long-Horizon Agent Context Compressioncited by 5
- 2026Agent-Controlled Forgetting for Tool-Using Agents: Reversible Context Curation in Practicecited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026Analyzing and Mitigating Cost-Inefficient Behaviors in Coding Agents
- 2026The Handoff Tax: Continuing Non-Native Trajectories in LLM Agents
- 2026Scores Are Not Decisions: Cost-Aware Stopping for Tool Acquisition in LLM Agents
- 2026Handoff Debt: The Rediscovery Cost When Coding Agents Take Over Interrupted Tasks
- 2026How Fast Do Agents Rot? An Empirical Study of Long-Horizon Degradation in LLM Agents for Production Decision-Making
- 2026TACT: Mitigating Overthinking and Overacting in Coding Agents via Activation Steering
- 2026AllocBench: Measuring Online Tool Allocation Capability in LLM Agents
- 2026Yet Even Less Is Even Better For Agentic, Reasoning, and Coding LLMs