AI agents already know when they need to forget or remember something before they act, new research shows.
Researchers looked at the hidden states of language model agents in the moments just before they take an action during long, multi-step tasks. They found the model's internal representations already encode whether it needs to compress its history or recall an earlier detail, before any memory operation actually happens. That signal is not just a proxy for context length or how far along the task is; it forms differently depending on which layer of the model you look at. Building on this, the researchers propose PaMER (Preaction Memory with Evidence Retrieval), a system that uses those internal signals to guide compression and selectively retrieve only the historical evidence a given task needs.
Most context management tools today guess when to compress or retrieve, using fixed windows, similarity search, or arbitrary triggers. This work suggests the model already has an answer buried in its own activations, and current systems are throwing that signal away. For agents that run long, multi-step tasks, that is not a minor inefficiency; ballooning context is a major reason those agents get slow and expensive to run.
On the WorkBuddyBench benchmark, PaMER cut context consumption substantially while keeping task performance competitive, which is the unglamorous but useful kind of result: not a smarter agent, just a cheaper one that still works.