Adaptable Safe Policy Learning from Multi-task Data with Constraint Prioritized Decision Transformer

Ruiqi Xue, Ziqian Zhang, Lihe Li, Cong Guan, Lei Yuan, Yang YuNeurIPS 2025

TL;DR: CoPDT (Constraint Prioritized Decision Transformer) is a novel framework for offline safe reinforcement learning (RL) designed to excel in multi-task environments with varying safety budgets. By introducing a specialized prompt encoder to identify constraints and a dynamic mechanism to generate conflict-free reward targets, CoPDT satisfies safety requirements in more than twice as many tasks as previous state-of-the-art methods.

The Challenge of Offline Safe RL

Safe Reinforcement Learning aims to maximize rewards while strictly adhering to safety constraints—much like a self-driving car navigating quickly without exceeding speed limits or colliding. Learning these policies "offline" (from a pre-collected dataset without risky trial-and-error) is the gold standard for real-world deployment.

However, existing methods struggle when transitioning from simple, single-task setups to complex multi-task and multi-budget scenarios. For example, a robot might need to follow different speed limits (multi-constraint) or operate under different fuel-consumption limits (multi-budget) across various environments. Current Decision Transformer (DT) models often fail here because:

  1. They cannot easily distinguish between different types of constraints in a mixed dataset.
  2. They rely on manually defined "Return-To-Go" (RTG) targets. If a human sets a reward target that is too high while the safety budget is too tight, the model experiences a "conflict," usually choosing to chase the reward and ignore the safety limit.

Introducing CoPDT

To address these limitations, the authors propose CoPDT, which augments the standard Decision Transformer architecture with two novel components designed to enhance adaptability.

CoPDT Architecture
  • Constraint Prioritized Prompt Encoder: To help the model understand which task it is currently performing, this encoder partitions trajectory data into "safe" and "unsafe" segments based on cost signals. By encoding these segments separately, the model learns to identify specific constraint configurations (e.g., "this task penalizes speed over 2.0") even when cost signals are sparse.
  • Constraint Prioritized Return-To-Go (CPRTG): Instead of feeding the model a static, heuristic reward target, CoPDT uses a secondary neural network to predict a feasible reward target conditioned on the current safety budget (Cost-To-Go) and the identified task.
  • $\beta$-quantile Sampling: During deployment, the model uses a "conservative" sampling strategy rather than just picking the average reward. If the safety budget is low, it selects a lower reward target to ensure the policy stays cautious.

The framework also utilizes environment-specific encoders to handle tasks with different state and action dimensions, allowing a single model to learn across entirely different robot types (e.g., a 2D point mass and a complex quadruped).

Key Insights

  • Cost as a Task Identifier: A clever insight from the paper is that even sparse, binary cost signals (0 or 1) are incredibly informative for task identification if trajectories are grouped by their safety status. This allows the model to "prompt" itself with the correct context.
  • Resolving the Reward-Safety Tug-of-War: In standard DTs, the RTG (reward target) and CTG (safety budget) are treated as independent inputs. CoPDT recognizes they are intrinsically linked. By generating the RTG based on the CTG, the model avoids asking the agent to do the impossible (e.g., "get a massive reward with zero safety budget"), which typically leads to safety violations.

Experimental Results

The researchers evaluated CoPDT using the OSRL (Offline Safe RL) benchmark, covering 26 distinct tasks including navigation (Point, Car) and velocity management (Ant, HalfCheetah, Hopper, Swimmer, Walker2d).

Performance Comparison on OSRL Benchmark
  • Safety Superiority: In multi-task settings, CoPDT satisfied safety constraints in more than twice as many tasks as previous DT-based methods like MTCDT or Prompt-CDT.
  • Efficiency: CoPDT achieved higher normalized rewards while maintaining lower costs compared to hard-constraint baselines (like FISOR and LSPC), which often struggle to adapt to varying budgets.
  • Robust Transfer: When fine-tuned on just 10 expert trajectories for a completely new task, CoPDT significantly outperformed learning from scratch, proving that its multi-task pre-training successfully captures transferable safety knowledge.

Limitations and Future Work

While CoPDT excels at few-shot adaptation, its "zero-shot" performance (handling a totally new constraint with no examples) remains limited, a common hurdle in Meta-RL due to training task diversity. Additionally, the model can struggle with tasks that have extremely wide or diverse reward distributions. Future work could explore more unified architectures that do not require re-initializing specific network heads for new robot types, further streamlining the scaling process.

Summary updated

BibTeX
@inproceedings{xue2025adaptable,
  author = {Ruiqi Xue and Ziqian Zhang and Lihe Li and Cong Guan and Lei Yuan and Yang Yu},
  title = {{Adaptable Safe Policy Learning from Multi-task Data with Constraint Prioritized Decision Transformer}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=HmsEHahtGx},
}
Figure