Research
Multi-agent In-context Coordination via Decentralized Memory Retrieval
Overview Research area: Cooperative Multi-Agent Reinforcement Learning (MARL), specifically In-Context Reinforcement Learning (ICRL) applied to decentralized partially observable domains. Technical le
- arXiv
- 2511.10030
- Published
- 2025-11-13
- Authors
- Tao Jiang, Zichuan Lin, Lihe Li, Yi-Chen Li, Cong Guan, Lei Yuan, Zongzhang Zhang, Yang Yu, Deheng Ye
AI summary
Overview
Research area: Cooperative Multi-Agent Reinforcement Learning (MARL), specifically In-Context Reinforcement Learning (ICRL) applied to decentralized partially observable domains.
Technical level: Intermediate. Readers should be comfortable with reinforcement learning basics (rewards, policies, trajectories) and Transformer architectures, but the paper's core ideas—retrieving similar past experiences to guide action—are intuitively accessible.
Scope: The paper introduces MAICC, a framework that lets a team of agents rapidly adapt to unseen cooperative tasks by retrieving relevant past trajectories as context, without updating any model parameters at test time.
What This Paper Is About
In-context learning lets large models tackle new tasks by conditioning on a few examples instead of retraining. This has been applied to reinforcement learning, but only works well for single agents in simple environments. Extending it to cooperating teams is hard because each agent only sees a partial view of the world, and the team receives a single shared reward that makes it unclear how much each individual agent contributed. MAICC solves both problems so that a team can coordinate quickly on a never-before-seen task.
Key Contributions
-
A centralized-to-decentralized embedding pipeline. The authors train one centralized embedding model (CEM) that sees all agents' observations and actions, then distill its team-level knowledge into per-agent decentralized embedding models (DEMs) via KL divergence. This gives each agent rich, team-aware trajectory representations using only local information.
-
Retrieval-augmented in-context decision making for MARL. Each agent embeds its current sub-trajectory, retrieves the top-k most similar past trajectories from memory, and concatenates them with its own history to condition a shared causal Transformer policy.
-
A selective memory mechanism with a hybrid utility score. At test time, memory mixes offline multi-task data with an online replay buffer using exponential time decay (early episodes favor offline exploration, later ones favor online exploitation). Retrieved trajectories are ranked by a hybrid score combining team-level global return and predicted individual returns, which mitigates the "lazy agent" problem.
-
A theoretical regret bound and extensive empirical validation. The paper proves online cumulative regret of Õ(CH^{3/2}ω√(AT)) and demonstrates faster adaptation than existing ICRL and multi-task MARL baselines on LBF, SMAC v1, and SMACv2.
Main Findings
- MAICC consistently outperforms all baselines across six scenarios (LBF 7x7-15s, LBF 9x9-20s, SMAC v1 Protoss/Terran/Zerg, SMACv2 including an "all-races" setting), adapting faster without any parameter updates.
- In-context adaptation matters most when observability is limited. Non-adaptive baselines (MADT, HiSSD) perform competitively on SMAC but collapse on LBF, where partial observability is severe.
- Task diversity amplifies MAICC's advantage. The largest gains appear in SMACv2 "all," where a single pretrained model handles three very different unit types—suggesting strong scaling potential.
- The RTG token hurts trajectory embedding. Including return-to-go during embedding training causes embeddings from different tasks to overlap, leading to retrieval of irrelevant trajectories and lower final return (13.52 vs. 14.51).
- Both offline and online memory are necessary. Using only offline data (β=1 → 11.17) or only the online buffer (β=0 → 12.16) both underperform the exponentially decaying mixture.
- All three embedding losses are required. Removing the reward loss, transition loss, or behavior-policy loss degrades performance, confirming that fine-grained trajectory modeling drives good retrieval.
- The hybrid utility score beats either extreme. Blending global return (α=1 → 13.61) with predicted individual return (α=0 → 13.26) yields the best result at α=0.8 (14.51), showing credit assignment benefits from both signals.
- t-SNE visualizations confirm the design choices. The proposed configuration produces clean task clusters; using the RTG token or fewer losses produces overlapping or overly compact clusters that generalize poorly.
Methodology in Plain English
The approach has three phases.
Phase 1 — Learn what trajectories look like. A centralized embedding model reads every agent's observations, actions, and post-step signals (reward, done flag, task completion), producing per-agent and team-level embeddings. It is trained with three objectives: predict each agent's action from its observation embedding, predict the shared reward by summing individual action-embedding predictions (implicit credit assignment), and predict the next observation from the post-step embedding. Separately, each agent's decentralized embedding model learns to mimic the centralized one's outputs using only local inputs, via KL divergence.
Phase 2 — Learn to act from retrieved examples. For a given partial trajectory, an agent computes a query embedding, searches the dataset for the k most cosine-similar trajectories, and concatenates them with its own history. A shared causal Transformer (GPT-2 scale) then predicts the next action, trained by supervised imitation of the offline data.
Phase 3 — Adapt online without training. On a new task, the team plays T episodes. Each episode builds a memory buffer by sampling from the offline dataset with probability β_t = exp(-λt/T) and from the online replay buffer otherwise. Retrieved candidates are ranked by cosine similarity plus a utility score combining normalized team return and predicted individual return. Actions are generated conditioned on the retrieved context. No gradients are computed during this phase.
The paper also derives a regret bound showing the expected cumulative gap to an expert policy grows only as √T, matching guarantees from prior in-context RL work.
Why This Matters
This is the first in-context RL method designed specifically for decentralized partially observable multi-agent settings, where prior single-agent ICRL methods break down. It shows that pretraining plus retrieval can substitute for gradient-based fine-tuning in cooperative teams—an important step toward agents that adapt in the field.
Real-world applications:
- Robot swarm coordination: Teams of drones or warehouse robots adapting to new configurations or obstacle layouts without retraining.
- Autonomous vehicle fleets: Vehicles coordinating at unfamiliar intersections or under changing traffic rules by recalling similar past scenarios.
- Multi-agent game AI: Opponent-adaptive NPC teams in strategy games, where each unit acts on local information only.
- Distributed logistics and trading: Independent decision-makers pursuing a shared objective with only partial market or supply-chain visibility.
Industry relevance: The framework's offline-pretraining-plus-online-retrieval design aligns with deployment constraints in industry—no expensive per-task fine-tuning, fixed inference-time parameters, and compatibility with existing offline datasets collected from prior systems. The Tencent co-authorship suggests direct interest in game AI and large-scale multi-agent deployment.
Future Directions
- Replacing exponential time decay with uncertainty-aware memory selection. The authors note that fixed decay may not suit all scenarios and suggest uncertainty-based metrics to improve generalization.
- Scaling to larger agent teams and longer horizons. The current benchmarks involve modest team sizes; whether retrieval stays effective as context length grows (and Transformer inference cost scales quadratically) is open.
- Extending beyond cooperative settings. The work assumes a shared reward; mixed-motive or competitive multi-agent tasks with partial alignment remain unaddressed.
- Better individual reward estimation. The hybrid utility score depends on a learned predictor of individual returns; improving that predictor—or learning it jointly with retrieval—could sharpen credit assignment further.
Target Audience
Researchers and graduate students working on multi-agent reinforcement learning, in-context learning, or decision-transformers. Practitioners building multi-robot or multi-agent systems who need fast task adaptation without retraining will also benefit, as will anyone studying retrieval-augmented methods for sequential decision making. A working knowledge of MARL terminology and Transformer mechanics is assumed.
Authors’ abstract
Large transformer models, trained on diverse datasets, have demonstrated impressive few-shot performance on previously unseen tasks without requiring parameter updates. This capability has also been explored in Reinforcement Learning (RL), where agents interact with the environment to retrieve context and maximize cumulative rewards, showcasing strong adaptability in complex settings. However, in cooperative Multi-Agent Reinforcement Learning (MARL), where agents must coordinate toward a shared goal, decentralized policy deployment can lead to mismatches in task alignment and reward assignment, limiting the efficiency of policy adaptation. To address this challenge, we introduce Multi-agent In-context Coordination via Decentralized Memory Retrieval (MAICC), a novel approach designed to enhance coordination by fast adaptation. Our method involves training a centralized embedding model to capture fine-grained trajectory representations, followed by decentralized models that approximate the centralized one to obtain team-level task information. Based on the learned embeddings, relevant trajectories are retrieved as context, which, combined with the agents' current sub-trajectories, inform decision-making. During decentralized execution, we introduce a novel memory mechanism that effectively balances test-time online data with offline memory. Based on the constructed memory, we propose a hybrid utility score that incorporates both individual- and team-level returns, ensuring credit assignment across agents. Extensive experiments on cooperative MARL benchmarks, including Level-Based Foraging (LBF) and SMAC (v1/v2), show that MAICC enables faster adaptation to unseen tasks compared to existing methods. Code is available at https://github.com/LAMDA-RL/MAICC.