Forget Freely, Grep Later: Lossless, Index-Free Memory for Long-Horizon LLM Agents

Ziyan Yang, Taiwei Shi, Jieyu Zhao
11/18/2026
cs.CLcs.AI

No confident code implementation found for this paper.

Abstract

Long-horizon LLM agents often exceed their context windows, forcing them to discard information that may be needed later. Existing context management strategies rely on summarization, masking, or structured memory, requiring decisions about what to preserve or how to retrieve it before future needs are known.

Show full abstract

However, these methods can introduce lossy compression, potentially discarding details needed for future tasks. To address this limitation, we introduce GrepMem, a simple, lossless, and index-free memory mechanism built on two components: an append-only plain-text log of the agent's complete history and a regular-expression search tool for on-demand recall. Unlike structured memory systems, GrepMem requires no embeddings, retrieval index, memory extraction, or additional models. We train Qwen3.5-9B with reinforcement learning under five context management strategies and evaluate on multi-question research sessions, long-stream recall, and agent-trajectory question answering. GrepMem achieves 95-97% accuracy on ContextBench, versus at most 21% for lossy baselines, and outperforms SUPO's summarization by 8.8 percentage points on BCP-Multi. GrepMem scales effectively to increasingly long input streams while remaining on the accuracy-token-cost Pareto frontier across all five evaluation tasks. Our results show that a plain-text log and grep provide a simple but competitive approach to long-horizon agent memory, without requiring complex structured memory infrastructure.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yang2026forget,
  title  = {Forget Freely, Grep Later: Lossless, Index-Free Memory for Long-Horizon LLM Agents},
  author = {Ziyan Yang and Taiwei Shi and Jieyu Zhao},
  year   = {2026},
  eprint = {2611.25123},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2611.25123v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2611.25123.svg)](https://codeofpaper.com/paper/2611.25123)

Discussion