Trajectory-Class-Aware Multi-Agent Reinforcement Learning

Hyungho Na, Kwanghyeon Lee, Sumin Lee, Il-chul Moon

In the world of Multi-Agent Reinforcement Learning (MARL), we usually train agents to become experts at a single, specific task—like a team of robots learning to play one specific formation in soccer. But what happens when the "task" changes? If the opponents change their strategy or the field dimensions shift, these specialized agents often crumble. This is known as the multi-task generalization challenge.

To address this, researchers have introduced TRAMA (TRajectory-class-Aware Multi-Agent reinforcement learning), a framework that allows agents to figure out "what kind of mission am I on?" simply by looking at their own experiences, and then adapt their behavior accordingly.

TL;DR

TRAMA enables agents to generalize across diverse tasks by clustering their experience trajectories into "classes" and learning to predict these classes from partial observations. By conditioning their actions on these predicted task types, agents achieve state-of-the-art performance and superior zero-shot generalization in complex, multi-task StarCraft II environments.

What Problem Does This Paper Address?

Most MARL algorithms struggle with unsupervised multi-task settings. In these scenarios, agents are dropped into different versions of a problem (e.g., different unit combinations or starting positions) without being told which version they are playing.

Standard approaches try to learn one "master policy" to rule them all, but this often leads to suboptimal, "blurry" strategies that don't work well for any specific task. Previous "task division" methods (like assigning roles or skills) often rely on complex hierarchies that are hard to train or require the environment to provide a task ID—something rarely available in real-world applications. The core challenge is: how can agents identify the context of their mission using only their limited, partial observations?

Methods

TRAMA tackles this challenge through a three-stage pipeline designed to extract, cluster, and utilize trajectory data.

TRAMA Framework Overview
  1. Quantized Latent Space (VQ-VAE): The authors use a Vector Quantized-Variational Autoencoder to compress high-dimensional states into discrete "embeddings." Crucially, they introduce a modified coverage loss. Standard VQ-VAEs often suffer from "codebook collapse," where only a few embeddings are used. TRAMA’s loss ensures that the latent space is used evenly across different timesteps and task types, creating a diverse "vocabulary" of experiences.
  2. Trajectory Clustering: Once they have these embeddings, TRAMA groups entire sequences of experiences (trajectories) using K-means clustering. This identifies "trajectory classes"—essentially discovering the different types of tasks present in the training data without needing manual labels.
  3. Trajectory-Class-Aware Policy:
    • The Predictor: During execution, each agent uses a GRU-based predictor to guess which trajectory class it is currently in, based on its local history.
  4. The Representation: This prediction is fed into a representation model that generates a task-specific "context vector."
    • The Action: Finally, the agent’s policy is conditioned on this context vector, allowing it to switch between specialized behaviors depending on the discovered task type.

Datasets

The researchers evaluated TRAMA on several challenging benchmarks:

  • SMAC (StarCraft Multi-Agent Challenge): Standard single-task maps (e.g., 1c3s5z, MMM2).
  • SMACv2: A more difficult version of SMAC where unit combinations and positions are randomized, requiring much higher generalization.
  • Custom Multi-task Benchmarks: The authors introduced even harder variants like SurComb3 and SurComb4, which feature sparse rewards (you only get points if you win) and highly varied unit sets (e.g., mixing Stalkers, Zealots, and Colossi in different ratios).

Key Insights and Ideas

  • Trajectories as Task Signatures: The core "aha" moment is that while a single state might be ambiguous, the sequence of states (the trajectory) acts as a unique signature for a task type.
  • Stability via Centroid Initialization: Clustering can be unstable; if the cluster labels swap during training, the agent's predictor will get confused. TRAMA uses "centroid initialization" from previous iterations to keep the task labels consistent over time.
  • Decentralized Task Recognition: Even though the clustering happens centrally during training, the prediction happens locally. This means agents can "sniff out" the task type during decentralized execution using only their own partial view of the world.

Key Results

TRAMA consistently outperformed state-of-the-art baselines like QMIX, QPLEX, and RODE.

  • Performance Boost: In the reSurComb4 task (a complex multi-task setup), TRAMA achieved a mean return of ~3.0, while the next best baseline (QPLEX) struggled around 2.3.
  • Zero-Shot Generalization: Perhaps most impressively, TRAMA showed strong Out-of-Distribution (OOD) performance. When tested on unit combinations it had never seen before, TRAMA was able to map the new task to the "closest" known trajectory class and adapt its strategy, significantly outperforming other models in win rates (e.g., 22% vs 16-20% on the hardest OOD tasks).
  • Efficiency: Despite the extra modules, TRAMA’s training time is comparable to other complex MARL baselines, and the classifier converges quickly to high accuracy.

Limitations and Future Work

The authors acknowledge that the number of clusters ($n_{cl}$) is a hyperparameter that currently needs to be tuned. If $n_{cl}$ is too small, the model misses task diversity; if it's too large, the predictor's accuracy drops. While they propose an adaptive clustering method based on "Silhouette scores" in the appendix, fully automating the discovery of the "optimal" number of tasks remains an open area for research. Additionally, the current framework assumes that tasks can be neatly categorized into discrete classes, which might not hold for tasks that vary on a continuous spectrum.

Summary updated

BibTeX
@inproceedings{na2025trajectory,
  author = {Hyungho Na and Kwanghyeon Lee and Sumin Lee and Il-chul Moon},
  title = {{Trajectory-Class-Aware Multi-Agent Reinforcement Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=uqe5HkjbT9},
}
Figure