arXiv:2611.04010cs.LGNov 2026

Manuscript Offprint

arXiv:2611.04010

Decision Transformer with Task-Aware Representations for Offline Meta-Reinforcement Learning

Xinbo Zhao, Yuhang Liu, Xin Zhang, Lei Le, Zhaohan Xi, Yingxue Zhang

ABSTRACT

To enable effective generalization in offline meta-RL, it is essential to accurately infer the underlying task through latent task representations, which provide a compact and transferable summary of task-specific characteristics for guiding policy generation. In this paper, we propose Contrastive Task-Aware Decision Transformer (CoTA-DT), a DT-based offline meta-RL framework that learns task representations by jointly integrating four complementary components: (i) contrastive learning from offline trajectories, (ii) alignment with natural-language task descriptions, (iii) one-step supervision via a task-conditioned world model, and (iv) long-term supervision via a task-conditioned Q function. The learned task representations are used as conditioning signals for a DT-based policy, enabling task-aware meta-policy learning. To further support generalization in both zero-shot and few-shot settings, we design a language-grounded, self-adaptive strategy that enables effective and reliable adaptation to unseen tasks. Notably, in CoTA-DT, the pretrained LLM serves as a shared backbone for language encoding, world modeling, Q-function estimation, and policy learning. This unified design facilitates parameter sharing, improving both efficiency and generalization. Extensive experiments across diverse offline meta-RL benchmarks demonstrate that CoTA-DT consistently outperforms prior methods, particularly in challenging zero-shot generalization scenarios.

1 INTRODUCTION

Offline meta-reinforcement learning (RL) aims to learn transferable priors from offline trajectories across related tasks, enabling efficient adaptation to new tasks with little or no additional data. In recent years, a prominent line of work in offline meta-RL has built on Decision Transformers (DTs) (Chen et al., 2021), leveraging the strong generalization capabilities of transformer architectures (Mitchell et al., 2021; Lin et al., 2022). These DT-based approaches formulate policy learning as sequence modeling over trajectories and perform adaptation through sequence conditioning.

For example, Prompt-DT (Xu et al., 2022) leverages expert demonstrations as prompts to encode task-specific information, enabling prompt-based adaptation at test time. Generalized Decision Transformers (GDT) (Furuta et al., 2021; Wang et al., 2023) incorporate hindsight signals, such as reward statistics or retrospective summaries, as conditioning inputs for task adaptation. Meta-DT (Wang et al., 2024) conditions the policy on compact task representations learned from trajectories to support generalization. More recently, T2DA (Zhang et al., 2025) conditions a DT-based policy on text embeddings derived from natural-language task descriptions. Despite the advances, these approaches typically learn task identifiers from a single source—such as language, trajectory data, or reward signals—and use them as conditioning inputs to guide DT-based policies for generalization. When such signals are ambiguous, noisy, or distributionally shifted relative to training, task identification can become unreliable, leading to degraded adaptation performance. These limitations naturally raise a question: How can we learn an offline meta-policy that achieves reliable task identification and supports robust generalization in both few-shot and zero-shot settings?

Reliable task identification across a broad family of related tasks depends on the availability of task-specific information. In offline meta-RL, collected trajectories serve as the primary source of information and implicitly encode task differences. However, relying solely on offline data is often insufficient, especially when the data are limited, noisy, or provide only partial coverage of the task space. Beyond trajectories, additional sources of information are often available. For example, natural-language task descriptions derived from task-level metadata—such as task goals, names, relevant objects, and environment constraints—provide complementary high-level semantics that are not always recoverable from trajectories alone. Meanwhile, environment transitions and rewards vary across tasks, offering informative one-step signals of task-specific dynamics and objectives, while cumulative returns (e.g., Q functions) capture long-horizon goals and provide global signals for distinguishing tasks. These observations motivate jointly leveraging multiple sources of information to learn robust task representations and enable reliable task identification in offline meta-RL.

In this paper, we propose Contrastive Task-Aware Decision Transformer (CoTA-DT), a DT-based offline meta-RL framework that learns task representations by jointly integrating four complementary components: (i) contrastive task encoding from offline trajectories, (ii) alignment with natural-language task descriptions, (iii) one-step supervision via a task-conditioned world model, and (iv) long-term supervision via a task-conditioned Q function. Specifically, task representations are first learned from trajectories via a contrastive objective that pulls together representations from the same task while separating those from different tasks. However, trajectory-only representations can be noisy due to data variability. To better capture underlying task objectives and reduce bias, we further align them with natural-language task descriptions encoded by a pretrained large language model (LLM), promoting semantic consistency between trajectory- and language-derived information. To further refine the representations, we introduce a task-conditioned world model that provides one-step supervision through transitions and rewards, along with a task-conditioned Q function that offers long-horizon supervision over task objectives. These complementary signals regularize the representations, and all components are optimized jointly to learn task representations from multiple perspectives.

The resulting task representations are used as conditioning signals for a DT-based policy, enabling task-aware meta-policy learning. To support generalization in both zero-shot and few-shot settings, we design a language-grounded, self-adaptive strategy for reliable adaptation. Notably, in CoTA-DT, the pretrained LLM serves as a shared backbone for language encoding, world modeling, Q-function estimation, and policy learning. This unified design enables parameter sharing across stages and leverages the LLM's prior knowledge from large-scale pretraining, along with its strong sequence modeling and transfer capabilities under prompt conditioning (Brown et al., 2020; Ouyang et al., 2022; Touvron et al., 2023), thereby improving both efficiency and generalization. Our main contributions are as follows:

  • We introduce CoTA-DT, an offline meta-RL framework whose policy conditions on a task latent that supports both language-based initialization and updates from observed transitions.
  • We learn discriminative, language-grounded task representations that capture task dynamics and long-horizon returns, supporting adaptation to unseen tasks with a shared LoRA-adapted LLM backbone.
  • We develop zero-shot deployment through language-grounded latent inversion and few-shot adaptation through support-based initialization, with optional policy fine-tuning.
  • Extensive experiments across various offline meta-RL benchmarks demonstrate that CoTA-DT consistently outperforms prior methods, particularly in challenging zero-shot generalization settings¹.

References (75)