TIMA: Test-Time Internalization for Agentic Memory

Xiaohang Sui, Yongjian Fu, Yizhe Zhao, Sheng Yue, Ju RenNeurIPS 2026

TL;DR

Most AI agents suffer from a bizarre form of amnesia: they either stuff past experiences into a rapidly shrinking text prompt, or rely on compressed "latent" memories that are frozen in stone the moment deployment begins. TIMA (Test-Time Internalization for Agentic Memory) gives LLM agents a living, breathing muscle memory—allowing them to distill complex problem-solving patterns into compact, continuous tokens on the fly while keeping the main LLM completely frozen.

What Problem Does This Paper Address?

Imagine trying to learn guitar, but instead of building muscle memory, you have to read a massive diary of every finger placement you’ve ever tried before playing a single chord. That’s how standard textual memory (like RAG) works for LLM agents—it hogs the context window and struggles to capture abstract, procedural "how-to" knowledge.

An alternative is latent memory, which compresses experience into continuous vectors ("soft tokens") in the model's hidden space. However, existing latent memory modules are typically trained offline and frozen at test time. They can't adapt to new experiences during live deployment. Meanwhile, Test-Time Learning (TTL) allows models to update weights on the fly, but existing TTL methods are built for uniform text streams, not messy agentic loops where thoughts, actions, and environment observations interleave. The authors ask: How can an agent continuously refine compact, reusable procedural memory from its own live actions?

Figure 1: Overview of TIMA.

Methods

TIMA bridges latent memory and test-time learning without ever touching the weights of the heavy backbone LLM (e.g., Qwen-7B or Llama-3B). Instead, it introduces three coupled components:

  • The Memory-Augmented Loop: In a standard Think $\rightarrow$ Act $\rightarrow$ Observe loop, TIMA injects $K$ continuous "memory tokens" (default $K=8$) right into the context at every turn to guide the agent's next thought and action.
  • The Internalizer (with Online TTL): This is a lightweight sidecar model (a 1.5B model with LoRA adapters) that reads the task query and recent history to generate those $K$ memory tokens. What's new here is how it learns at test time: after each turn, TIMA updates the Internalizer's parameters by minimizing the negative log-likelihood of the agent's composite action (reasoning + tool call). Intuitively, good memory makes good reasoning more predictable. To prevent the agent from learning its own bad habits, entropy-aware filtering discards high-uncertainty (noisy) turns, updating only on confident steps using momentum and weight decay.
  • The Internalizer Bank: To carry knowledge across tasks without lumping everything into one muddled module, TIMA maintains a bank of specialized Internalizers indexed by query embeddings. New tasks retrieve the closest matching Internalizer, update it during execution, and save it back. To avoid a cold start, the bank is seeded with 20 domain-clustered anchor entries that are copied before specialization so foundational priors aren't overwritten.
Figure 2: The TIMA framework. For each incoming task, TIMA retrieves an Internalizer I from the Internalizer Bank (bottom) and uses it to produce latent memory tokens that augment the agent’s working loop (middle). After each turn, I is updated online through a test-time learning objective defined over the agent’s own trajectory (top), and the updated parameters are written back to the bank for reuse on subsequent tasks.

Datasets

No new benchmarks were introduced. The authors evaluated TIMA across eight existing benchmarks spanning four distinct task families:

  • Mathematical Reasoning: GSM8K, MATH
  • Code Generation: KodCode, BigCodeBench
  • Multi-Hop QA: HotpotQA, 2WikiMultihopQA
  • Multi-Turn Interactive Environments: ALFWorld (household tasks), WebShop (online shopping)

To warm-start the Internalizer Bank, 300 successful trajectories per benchmark (strictly disjoint from test sets) were drawn from official training splits for static tasks and from AgentBank for interactive tasks.

Key Insights and Ideas

  • Confidence is the antidote to catastrophic forgetting: Updating a model on its own live outputs sounds like a recipe for a death spiral. The authors show that without filtering, accuracy on HotpotQA plunges from 44.7% to 36.9% over subsequent update blocks. Simply ignoring high-entropy (uncertain) turns stabilizes memory, holding accuracy steady (45.6% $\rightarrow$ 43.7%).
  • Agentic TTL needs action-grounded objectives: Standard test-time learners like Titans (which updates memory based on token-level "surprise") actually perform near or below vanilla baselines here. Optimizing specifically to predict the agent's reasoning-and-action trajectory is what unlocks procedural learning.
  • Emergent specialization without hard caps: The Internalizer Bank doesn't explode in size over long task streams. It grows sub-linearly and naturally plateaus—routing new tasks to existing specialists and refining them in place, with t-SNE plots revealing clean, interpretable sub-clusters inside the memory space.
  • Tiny footprints carry massive weight: Going from $K=0$ to just $K=4$ continuous memory tokens boosts HotpotQA accuracy on Qwen by 24.1 percentage points, proving procedural patterns can be remarkably compact.

Key Results

Across both Qwen2.5-7B-Instruct and Llama3.2-3B-Instruct, TIMA consistently beats vanilla prompting, textual memory (RAG, A-Mem), RL-augmented search (Search-R1), and latent-memory baselines (MemGen, Titans).

  • Reasoning Benchmarks: On Qwen2.5-7B, TIMA takes first place on all six static benchmarks, averaging 61.25% accuracy (a +12.81% jump over Vanilla, +4.47% max gain over MemGen, and up to +15.96% over Titans). Turning off test-time updates (TIMA w/o ttl) drops average accuracy by ~4.3%, proving live adaptation—not just bank retrieval—drives the win.
  • Interactive Agents: On ALFWorld, TIMA hits 78.1% overall success, crushing textual memory A-Mem by 26.3 percentage points (a ~50.8% relative leap) and beating offline latent-memory MemGen (76.3%), with the biggest gains on complex multi-step tasks like clean (+7.7%) and pick2 (+6.4%). On WebShop, it leads with a 58.7% success rate.
Table 1: Main results on reasoning benchmarks across two backbones. Accuracy (%) on math (GSM8K, MATH), code (KodCode, BigCodeBench), and multi-hop QA (2Wiki, HotpotQA). Bold denotes the best result per column; a dash (–) indicates methods not evaluated on that benchmark. Search-R1 is a retrieval-specialized RL baseline that is applicable only to multi-hop QA.

Limitations and Future Work

Not discussed in the paper. (Note: The provided text concludes after Section 6 without a dedicated Limitations or Future Work section, deferring extended ablations and hyperparameters to the appendices.)

Summary updated

Abstract

Agentic memory is critical for accumulating and reusing experience in LLM agents across long interaction horizons and related tasks. While latent-memory approaches offer a compact representation of such experience without incurring additional context overhead, existing methods are designed to encode transient in-context states or rely on pre-trained modules that remain fixed at test time to inject experiential representations. Consequently, an effective mechanism for continually refining reusable latent memory from execution experience is still missing in current agents.To this end, we propose **TIMA**, a framework for test-time internalization that enables agents to acquire and update latent memory during interaction. **TIMA** couples a memory-augmented agent loop with an online-updated *Internalizer* and an *Internalizer Bank* for retrieval and continual refinement across episodes. Through self-supervised updates derived from execution trajectories, **TIMA** progressively encodes task-relevant solving patterns into compact latent memory, enabling both within-episode adaptation and cross-episode transfer. Extensive experiments across eight benchmarks show that **TIMA** consistently outperforms strong baselines, surpassing A-Mem by up to 50.8% and latent-memory baselines such as MemGen and Titans by up to 4.47%--15.96%. Further analysis indicates that the learned latent memory remains stable under continual updates, generalizes well out of distribution, and exhibits interpretable clustering structure across *Internalizers*.
BibTeX
@inproceedings{sui2026tima,
  author = {Xiaohang Sui and Yongjian Fu and Yizhe Zhao and Sheng Yue and Ju Ren},
  title = {{TIMA: Test-Time Internalization for Agentic Memory}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=e1BjgiaD5E},
}
Figure