Skip to content

LatentMem: Customizing Latent Memory for Multi-Agent Systems

Conference: EMNLP 2026
Paper: https://aclanthology.org/2026.emnlp-main.457/
Code: https://github.com/KANABOON1/LatentMem
Area: LLM Agent
Keywords: multi-agent systems, latent memory, policy optimization, experience replay, role-aware customization

TL;DR

LatentMem addresses the fundamental bottlenecks of memory homogenization and long-context information overload in Multi-Agent Systems (MAS) by retrieving raw trajectories from a lightweight experience bank, composing role-aware continuous latent memories via a memory composer, and optimizing them end-to-end via Latent Memory Policy Optimization (LMPO).

Background & Motivation

Large Language Model (LLM)-powered Multi-Agent Systems (MAS) have emerged as an effective paradigm for tackling complex tasks through collaborative problem solving and competitive debate across domains such as code generation, multi-step reasoning, and embodied planning. A pivotal component underpinning their continual adaptation and long-horizon coordination is the multi-agent memory architecture, which stores and retrieves shared historical interaction traces. Recent memory designs have attempted to retain multi-agent experiences across multiple granularities, ranging from recording raw execution trajectories to distilling high-level semantic insights or constructing orchestrable procedural skill schemas. Nevertheless, existing systems remain largely tethered to the discrete natural language space, which imposes steep performance and efficiency costs as interaction complexity grows.

Existing multi-agent memory architectures suffer from two coupled systemic bottlenecks. The first is memory homogenization: conventional memory frameworks distribute identical, one-size-fits-all memory entries to all agents, ignoring their functional heterogeneity (such as planners, coders, and critics). This dilutes role adherence and amplifies correlated error cascades across agents. The second is information overload: multi-agent collaboration already generates lengthy conversational contexts, and injecting large volumes of detailed textual memory entries further saturates the LLM context window. This not only incurs prohibitive inference latency and token overhead, but also frequently leads agents to blindly follow retrieved historical trajectories, causing execution failures such as step repetition or violation of current task specifications.

While direct multi-agent fine-tuning (such as MARTI) can adjust agent policies using reinforcement learning, it necessitates fine-tuning entire underlying foundation models, demanding substantial computational resources while lacking flexibility across diverse MAS collaboration topologies. LatentMem tackles these dilemmas by shifting memory customization from discrete natural language down to continuous latent space representations. Core idea: maintain a lightweight experience bank of uncompressed raw trajectories, employ a learnable memory composer to distill retrieved trajectories and agent role profiles into compact, fixed-length latent memory vectors, and optimize the composer end-to-end via Latent Memory Policy Optimization (LMPO) while keeping foundation agent backbones frozen.

Method

Overall Architecture

LatentMem comprises two primary modules: an uncompressed, lightweight experience bank (\(B\)) for storing raw interaction trajectories, and a parameter-efficient memory composer (\(C\)) that synthesizes role-aware continuous latent memory vectors. During inference, given a user query \(q\), LatentMem retrieves relevant raw trajectories from the bank using dense vector similarity. The memory composer transforms these trajectories, conditioned on the active agent's role profile, into a compact sequence of latent tokens. These continuous vectors are seamlessly concatenated into the agent's input hidden states, steering generation without altering the host MAS framework's execution graph \(\mathcal{G}\) or the agent's core model parameters. After execution, the newly generated trajectory is appended to the bank for continuous online self-evolution. During training, LMPO leverages scalar task rewards to optimize the memory composer via backpropagation through the differentiable latent memory interface.

The complete operational flow of LatentMem is illustrated below:

%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
    Q["User Task Query q"] --> R["Lightweight Experience Bank Retrieval<br/>MiniLM Semantic Matching of Top-K Raw Trajectories"]
    R --> C["Role-Aware Latent Memory Composition<br/>Transformer Fuses Profile & Trajectory into Fixed Latent Tokens"]
    C --> I["Seamless Latent Memory Injection<br/>Concatenates Hidden State (R^(L+L')xD) into Forward Pass"]
    I --> E["Multi-Agent Collaborative Execution & Topology<br/>AutoGen / MacNet / CAMEL / DyLAN"]
    E -->|Collect New Trajectory| U["Online Trajectory Accumulation<br/>B <- B U {tau_new} Continual Self-Evolution"]
    E -->|Sample Rollout Group| L["LMPO End-to-End Policy Optimization<br/>SAGA Gradient Propagation to Memory Composer"]
    L -.->|Update Parameters phi| C

Key Designs

1. Lightweight Experience Bank Retrieval: Avoiding Heuristic Bias and Information Loss

Conventional memory frameworks rely heavily on human-engineered heuristics to condense, summarize, or structure historical interactions into graph nodes or reflective insights, which inevitably discards nuanced coordination details and introduces fragile inductive biases. Adhering to the principle that scalable systems should prioritize general learning mechanisms over hand-crafted priors, LatentMem's experience bank \(B\) records only uncompressed raw multi-agent interaction trajectories. Each trajectory \(\tau = \{(\alpha_j, p_j, o_j)\}_{j=1}^H\) faithfully captures the active agent index \(\alpha_j\), input prompt \(p_j\), and generated output \(o_j\) across horizon \(H\). Upon receiving a new query \(q\), LatentMem executes dense vector retrieval via an embedding encoder \(v(\cdot)\) (such as MiniLM-L6-v2) by computing cosine similarities against historical queries or trajectories:

\[T_q = \operatorname{top-K}_{\tau_i \in B}(\operatorname{sim}(v(q), v(\tau_i))) = \{\tau_i\}_{i=1}^K\]

Following task completion, the new interaction trajectory \(\tau_{\text{new}}\) is incrementally appended (\(B \leftarrow B \cup \{\tau_{\text{new}}\}\)) without destructive textual rewriting, preserving raw collaborative evidence for subsequent task-level distillation.

2. Role-Aware Latent Memory Composition: Resolving Memory Homogenization and Overload

Supplying extensive textual trajectories directly to all agents consumes excessive context tokens and obscures distinct agent roles. LatentMem introduces a neural memory composer \(\sigma_\phi\), parameterized by \(\phi\) and initialized from the base LLM. For an active agent \(a_{\alpha_j}\) executing step \(j\), the composer conditions on both the retrieved raw trajectories \(T_q\) and the agent's explicit role profile \(\gamma_{\alpha_j}\) (which details specific duties such as strategy formulation, code generation, or test evaluation):

\[m_j = \sigma_\phi(\gamma_{\alpha_j}, T_q) \in \mathbb{R}^{L' \times D}\]

where \(L'\) is the fixed, compact latent memory length (set to \(L'=8\) tokens by default) and \(D\) denotes the hidden embedding dimension of the foundation LLM. By conditioning on \(\gamma_{\alpha_j}\), the composer projects the shared multi-agent trajectory into distinct latent subspaces tailored to individual roles, effectively mitigating memory homogenization while compressing thousands of textual tokens into a fixed-size vector matrix.

3. Seamless Latent Memory Injection: Non-Invasive Integration into Existing MAS

To remain fully compatible with diverse MAS architectures (such as decentralized random-graph structures like MacNet or dynamic conversational frameworks like AutoGen), LatentMem injects memories at the continuous representation layer without modifying application-level communication protocols. When agent \(a_{\alpha_j}\) processes its textual prompt \(p_j\), the LLM encodes it into an initial hidden state sequence \(h_j = (h_j^{(1)}, \dots, h_j^{(L)}) \in \mathbb{R}^{L \times D}\). The latent memory matrix \(m_j\) is then directly concatenated along the token sequence dimension to construct an augmented hidden sequence of shape \(\mathbb{R}^{(L + L') \times D}\). The memory-augmented agent policy is expressed as:

\[\tilde{\pi}_{\theta_{\alpha_j}}(p_j, m_j) = \pi_{\theta_{\alpha_j}}(\operatorname{concat}(h_j, m_j))\]

This injection operates natively within the transformer forward pass, remaining completely transparent to higher-level agent control logic. Crucially, this provides a continuous and differentiable computational pathway through which task-level learning signals can flow back from agent actions to the composer parameters \(\phi\).

Loss & Training

Rather than relying on manual prompt tuning or supervised imitation, LatentMem introduces Latent Memory Policy Optimization (LMPO). LMPO leverages a GRPO-style objective to train the memory composer \(\sigma_\phi\) using task-level outcome rewards \(R(\tau)\) while maintaining all agent base models \(\{\theta_k\}_{k=1}^N\) completely frozen.

Given query \(q\) and retrieved trajectories \(T_q\), a group of \(G\) multi-agent rollout trajectories \(\{\hat{\tau}_i\}_{i=1}^G\) is sampled. The group-normalized advantage for trajectory \(\hat{\tau}_i\) is computed as:

\[\hat{A}_i = \frac{R(\hat{\tau}_i) - \operatorname{mean}(\{R(\hat{\tau}_i)\}_{i=1}^G)}{\operatorname{std}(\{R(\hat{\tau}_i)\}_{i=1}^G) + \epsilon}\]

Because trajectory-level objectives penalize longer interaction traces by under-weighting individual token gradients, LMPO optimizes a token-level clipped surrogate objective over all generated tokens:

\[\mathcal{J}_{\text{LMPO}}(\phi) = \mathbb{E}_{q, \{\hat{\tau}_i\}_{i=1}^G} \left[ \frac{1}{|\{\hat{\tau}_i\}_{i=1}^G|} \sum_{i=1}^G \sum_{j=1}^{H_i} \sum_{t=1}^{T_{i,j}} \min \left( r_{i,j,t}(\phi)\hat{A}_i, \, \operatorname{clip}(r_{i,j,t}(\phi), 1-\varepsilon, 1+\varepsilon)\hat{A}_i \right) \right]\]

where the token-level importance sampling ratio \(r_{i,j,t}(\phi)\) captures how memory parameter updates alter the generation probability:

\[r_{i,j,t}(\phi) = \frac{\tilde{\pi}_\theta\left(o_{i,j}^{(t)} \mid p_{i,j}, o_{i,j}^{(<t)}, \sigma_\phi(\gamma_{\alpha_{i,j}}, T_q)\right)}{\tilde{\pi}_\theta\left(o_{i,j}^{(t)} \mid p_{i,j}, o_{i,j}^{(<t)}, \sigma_{\phi_{\text{old}}}(\gamma_{\alpha_{i,j}}, T_q)\right)}\]

To prevent the activation memory overhead of joint multi-agent backpropagation from scaling linearly with agent count \(N\), training incorporates Sequential Agent Gradient Accumulation (SAGA). SAGA decomposes each trajectory into sequential per-agent batches and computes gradients iteratively via accumulation, slashing the peak activation memory complexity from \(\mathcal{O}(N)\) to \(\mathcal{O}(1)\). On 2 NVIDIA H200 GPUs, the LoRA-adapted memory composer (\(r=16, \alpha=32\)) trains in approximately 15 hours.

Key Experimental Results

Main Results

Evaluation spans six benchmarks across four domains: in-domain tasks TriviaQA, PopQA (knowledge QA), KodCode (coding), and StrategyQA (reasoning); and out-of-domain tasks BigCodeBench (challenging code generation) and PDDL (symbolic planning from AgentBoard). In-distribution MAS frameworks include AutoGen and MacNet, while CAMEL and DyLAN serve as unseen evaluation frameworks with distinct topologies and roles. The base model is Qwen3-4B-Instruct-2507.

The table below contrasts LatentMem against the no-memory baseline and leading single-/multi-agent memory frameworks:

MAS Framework Memory Architecture TriviaQA KodCode StrategyQA PopQA BigCodeBench PDDL Average (Avg)
AutoGen (Held-in) No-memory 60.31 68.40 58.25 38.78 79.53 16.39 53.61
ChatDev 57.34 68.55 59.18 33.24 79.15 15.22 52.11 (-1.50)
MetaGPT 60.35 70.05 60.92 33.80 80.40 11.95 52.91 (-0.70)
Generative 59.65 70.90 62.66 40.37 81.14 13.94 54.78 (+1.17)
G-Memory 60.56 71.40 63.89 42.67 80.96 17.06 56.09 (+2.48)
OAgents 59.85 70.80 62.45 40.70 81.32 16.70 55.30 (+1.69)
LatentMem 76.51 (+16.20) 76.80 (+8.40) 65.48 (+7.23) 52.70 (+13.92) 81.49 (+1.96) 23.49 (+7.10) 62.75 (+9.14)
MacNet (Held-in) No-memory 53.77 70.40 56.44 24.89 78.15 20.73 50.73
G-Memory 62.43 72.50 62.20 43.88 80.44 21.82 57.21 (+6.48)
OAgents 60.63 71.30 61.79 41.90 78.86 22.83 56.22 (+5.49)
LatentMem 65.98 (+12.21) 78.90 (+8.50) 64.46 (+8.02) 44.14 (+19.25) 81.49 (+3.34) 25.13 (+4.40) 60.02 (+9.29)
CAMEL (Held-out) No-memory 56.96 70.70 58.04 32.38 79.14 22.10 53.22
G-Memory 59.20 70.40 60.12 38.04 79.28 24.56 55.27 (+2.05)
LatentMem 68.74 (+11.78) 77.75 (+7.05) 64.20 (+6.16) 47.23 (+14.85) 80.70 (+1.56) 28.12 (+6.02) 61.12 (+7.90)
DyLAN (Held-out) No-memory 53.87 69.25 57.44 24.89 79.81 23.81 51.51
G-Memory 61.23 71.35 63.76 42.28 80.35 17.94 56.15 (+4.64)
LatentMem 65.55 (+11.68) 78.80 (+9.55) 65.22 (+7.78) 44.25 (+19.36) 81.40 (+1.59) 29.08 (+5.27) 60.72 (+9.21)

In scaling experiments with Llama-3.1-8B-Instruct, LatentMem elevates AutoGen's KodCode accuracy from 47.45% to 65.90% (+18.45%) and MacNet's KodCode from 48.50% to 65.50% (+17.00%). Additionally, when compared against MARTI (a multi-agent backbone fine-tuning framework), LatentMem outperforms it by 11.73% on AutoGen-TriviaQA (76.51% vs 64.78%) and by 5.80% on MacNet-KodCode (78.90% vs 73.10%), underscoring that optimizing an external memory composer is more effective than end-to-end backbone tuning.

Ablation Study

The contribution of each design component was thoroughly investigated through algorithmic and structural ablations:

Table 1: Training Strategy & Memory Interface Ablation (AutoGen, Qwen3-4B)

Variant / Configuration TriviaQA KodCode StrategyQA PopQA PDDL Notes
LatentMem (LMPO Full) 76.51 76.80 65.48 52.70 23.49 Complete RL policy optimization framework
LatentMem (SFT) 60.82 74.55 61.92 45.80 10.34 Supervised fine-tuning; degrades severely on PDDL
Role-Conditioned Prefix-Tuning - 70.15 - 42.78 - Static learned prompt prefixes without trajectory conditioning

Table 2: Component Sensitivity & Hyperparameter Ablations

Ablation Dimension Variant Setting Key Observation & Degradation Pattern
Role Conditioning (\(\gamma\)) Without role profile (w/o role) Agents share identical latent vectors; drops by 2.30% on AutoGen-KodCode and collapses by 6.45% on multi-role MacNet
Experience Accumulation (\(B\)) Without experience update (w/o experience) Disables online trajectory appending; KodCode drops by 3.60% and out-of-domain PDDL drops by 7.63%
Latent Memory Length (\(L'\)) Varied from 2 to 16 tokens Performance scales steadily up to \(L'=8\), beyond which gains saturate; \(L'=8\) balances expressivity and compute
Retrieved Trajectory Count (\(K\)) Varied from 1 to 5+ G-Memory degrades when \(K > 3\) (KodCode falls from 72.95% to 70.25% due to text overload); LatentMem improves monotonically

Key Findings

  • Role conditioning prevents multi-agent coordination collapse: Omitting role profiles induces sharp performance drops on decentralized multi-agent setups like MacNet (-6.45% on KodCode). t-SNE visualizations confirm that role conditioning projects latent memories into well-separated clusters (e.g., User Proxy vs. Assistant), preventing role drift and error cascades.
  • LMPO yields robust out-of-distribution generalization: While SFT performs reasonably on seen distributions, it collapses on out-of-domain planning tasks (PDDL drops from 23.49% with LMPO to 10.34% with SFT), demonstrating that reinforcement learning on task-level rewards instills transferable problem-solving heuristics into the composer.
  • Superior efficiency and immunity to retrieval noise: By replacing verbose textual prompts with 8 continuous latent tokens, LatentMem reduces inference time by up to 2.16x compared to OAgents and operates with fewer tokens than memory-free baselines (due to eliminating cyclic error-correction turns). Moreover, while textual memory systems degrade as retrieved items increase (\(K > 3\)), LatentMem's continuous bottleneck filters redundancy effectively.

Highlights & Insights

  • Continuous latent vectors supersede verbose text injection: Rather than appending thousands of tokens of retrieved dialog, LatentMem compresses interaction histories into 8 continuous virtual tokens, bypassing context window saturation and attention dilution.
  • Differentiable memory interface under frozen backbones: Conditioning base models on continuous prefix representations preserves end-to-end differentiability, enabling task-level policy gradient optimization of the composer without modifying or fine-tuning foundation LLMs.
  • Zero-shot topology transferability: Trained exclusively on AutoGen and MacNet, LatentMem transfers seamlessly to unseen multi-agent architectures (CAMEL debate and DyLAN dynamic networks) with average gains exceeding 7.90%, proving that latent memory composition abstracts away specific execution graphs.

Limitations & Future Work

  • Text-only modality scope: The framework is evaluated exclusively on text-based question answering, coding, and symbolic planning, leaving multimodal settings (e.g., vision-language agents or embodied robotics) unaddressed.
  • Requirement of white-box model access: Injecting latent states into input representations assumes access to model weights or hidden representations, precluding deployment on black-box, API-only proprietary LLMs.
  • Theoretical properties in infinite-horizon settings: While LMPO demonstrates empirical success, formal theoretical bounds on information retention and signal-to-noise ratios over extremely long agent interactions warrant further investigation.
  • vs G-Memory / OAgents: Traditional MAS memory systems construct complex multi-tiered hierarchical graphs or textual summaries, yet still overwhelm the context window and suffer performance drops when \(K > 3\). LatentMem maps trajectories into compact latent vectors, maintaining linear performance scaling with more retrieved examples.
  • vs MemGen / SoftCoT: Prior latent reasoning works focus on single-agent chain-of-thought compression or self-evolution. LatentMem represents the first framework to customize continuous latent memories for heterogeneous multi-agent systems via role conditioning.
  • vs MARTI (Multi-Agent Fine-Tuning): MARTI directly updates the entire multi-agent LLM backbone, which is computationally expensive and risks catastrophic forgetting. LatentMem freezes the base LLMs and tunes only a lightweight memory composer module.

Rating

  • Novelty: โญโญโญโญโญ Pioneering transition of multi-agent memory from discrete natural language to continuous, role-conditioned latent representations.
  • Experimental Thoroughness: โญโญโญโญโญ Rigorous evaluation across 6 diverse benchmarks, 4 distinct MAS frameworks, 2 backbone model scales, with detailed ablations, cost analyses, and t-SNE geometric validations.
  • Writing Quality: โญโญโญโญโญ Clearly structured, mathematically disciplined formulation of LMPO with elegant experimental visualizations and insightful failure-mode case studies.
  • Value: โญโญโญโญโญ Offers a practical, token-efficient, and parameter-efficient blueprint for scaling multi-agent persistent memory.