1. Introduction
Offline safe reinforcement learning (RL) aims to learn reliable decision-making policies from a fixed dataset while maximizing task performance under cumulative cost constraints, without any additional environment interaction [
1,
2,
3,
4]. This setting is particularly relevant for safety-critical domains such as robotics and autonomous systems, where online exploration can be prohibitively expensive and unsafe [
5,
6]. In practice, safety requirements vary widely; different deployment scenarios or operating conditions may impose different cost constraints, and policies often need to evaluate return–cost trade-offs and adapt across a range of cumulative cost thresholds [
2,
7]. Such variability highlights the need for policies with zero-shot adaptability across multiple cost thresholds [
8]. However, most prior offline safe RL methods are trained under a pre-specified cost threshold, resulting in policies that are tied to that specific constraint and hence do not naturally support one-policy, zero-shot deployment across varying thresholds [
9,
10,
11].
Recent advances in offline RL via conditional sequence modeling (CSM) suggest a promising route to accommodating varying deployment requirements within a single policy [
12,
13,
14,
15,
16]. Conceptually, CSM reformulates offline RL into supervised learning on trajectory data by training a goal-conditioned action predictor [
17,
18]. One representative CSM approach is the Decision Transformer (DT) [
17], which trains a Transformer to predict actions from trajectory prefixes conditioned on a target return-to-go (RTG) signal. At inference time, DT treats decision making as a conditional generation problem, and thus can adjust its behavior by varying the target RTG token. By making decisions directly from temporally extended trajectories, this paradigm also bypasses recursive value estimation, thereby mitigating bootstrapping errors and challenges associated with dynamic programming in offline settings [
17,
18]. These properties make CSM a compelling backbone candidate for offline safe RL, where one would ideally like to adapt the return–cost trade-off across budgets without retraining.
Nevertheless, a straightforward extension of DT to constrained settings, by introducing a cost-to-go (CTG) token and conditioning on both return and cost, does not necessarily yield satisfactory safety behavior. The key issue is that maximum-likelihood training encourages the model to match the conditioning signals, which obscures the asymmetry in constrained Markov decision processes (CMDPs) where return is to be optimized while cost specifies a constraint. As a result, naive CTG matching can induce unstable return–cost trade-offs and even constraint violations, especially when the dataset provides limited coverage of low-cost behaviors. Such instability and constraint violations under naive CTG-conditioned DT variants have been widely observed in prior work and in our experiments [
1,
3,
4,
7]. Consequently, a central question arises:
how can we endow CSM-based policies with a principled and robust mechanism for achieving favorable return–cost trade-offs while preserving their zero-shot adaptation flexibility?To develop a robust CSM-based approach for offline safe RL, we first analyze the discrepancy between the specified RTG/CTG signals and the resulting expected return and cumulative cost induced by a conditioned CSM policy. More precisely, we consider a fixed conditioning function that determines the RTG/CTG inputs used at inference, and let and denote the (random) return and cumulative cost of a trajectory generated by the behavior policy from an initial state . Our analysis shows that, under mild CMDP assumptions, this discrepancy admits an upper bound that scales as , where lower-bounds the joint return–cost coverage of the target profile in the offline dataset, i.e., . Consequently, when the desired return–cost conditioning function has low coverage (small ), the induced optimal policy may substantially deviate from the intended RTG/CTG targets, leading to unstable return–cost trade-offs and potential constraint violations. In particular, simply specifying a high RTG together with a low CTG does not reliably yield favorable return–cost trade-offs on challenging datasets where safe high-return behaviors are under-represented. This analysis motivates augmenting naive conditioning with weighted and regularized training mechanisms that shift learning toward trajectories with better return–cost trade-offs while preserving zero-shot adaptability.
Building on this insight, we propose the first CSM-based offline safe RL algorithm that integrates a Lagrangian-style cost penalty while preserving zero-shot adaptation across different cost thresholds. We term the proposed algorithm Return–Cost Regularized Constrained Decision Transformer (RCDT). At a high level, RCDT minimizes a weighted maximum-likelihood objective augmented with an explicit cost penalty, where the penalty term is induced from a primal–dual Lagrangian formulation of CMDPs. Specifically, RCDT treats the cost-penalty coefficient as a dual variable and updates it via a standard dual-ascent step driven by the current cost estimate, which provides a principled, auto-adaptive mechanism for tuning the regularization strength while avoiding hard-wiring the policy to a single cost threshold. To avoid overly conservative behavior and achieve a more favorable return–cost trade-off, RCDT further incorporates two complementary ingredients: (i) a reward–cost-aware trajectory-level reweighting mechanism that emphasizes trajectories with desirable return–cost profiles; and (ii) Q-value regularization as an additional optimization signal to steer the policy toward high-return regions. Together, these designs decouple policy learning from any single pre-specified cost threshold while maintaining strong task performance, thereby enabling one-policy deployment across multiple cost thresholds in a zero-shot manner.
Our contributions are summarized as follows:
- 1.
We propose RCDT, the first CSM-based offline safe RL method that integrates a Lagrangian-style cost penalty with an auto-adaptive dual-ascent update of the penalty coefficient. RCDT achieves favorable return–cost trade-offs while enabling zero-shot deployment across multiple cost thresholds, and empirically outperforms state-of-the-art offline safe RL baselines under stringent constraints.
- 2.
We theoretically characterize the discrepancy between the prescribed RTG/CTG signals and the realized expected return and cumulative cost of CSM policies through the lens of joint return–cost coverage. The theoretical analysis pinpoints when a CSM policy can be regarded as a reliable backbone for offline safe RL and establishes performance limits for zero-shot control via RTG/CTG conditioning.
- 3.
To encourage strong return performance without inducing overly conservative behavior, we introduce a reward–cost-aware trajectory-level reweighting scheme together with Q-value regularization as complementary training signals. This design introduces an additional inductive bias toward trajectories with favorable return–cost trade-offs. Moreover, we show that the commonly used expert KL regularizer can be interpreted as a special case of our reweighting mechanism.
We evaluate RCDT on the DSRL benchmark [
19] under multiple cumulative cost thresholds, where a single trained policy is assessed in a zero-shot manner across all thresholds. Experimental results show consistent improvements in return–cost trade-offs over representative baselines, establishing RCDT as a strong candidate for advancing the state-of-the-art in offline safe RL.
4. Methodology
4.1. Conditioned Sequence Modeling in CMDPs
We analyze how conditional sequence modeling behaves in an idealized CMDP setting with infinite data and a fully expressive policy class. Our goal is to show that, under suitable assumptions, the policy that optimizes the CDT objective (
2) is guaranteed to be near-optimal for the underlying CMDP. Let
denote the joint distribution over states, actions, returns, and costs induced by
and the CMDP dynamics. Recall that CDT is trained to maximize the likelihood of actions conditioned on states and target return–cost signals. Thus, when the model is given a conditioning function
the CDT loss in (
2) attempts to learn the conditional distribution
. In the infinite-data and realizable limit, the optimal CDT policy (denoted by
) for a fixed conditioning function
F can be written as
Here,
and
can be interpreted as the target RTG and CTG associated with state
s, and
denotes the probability (under
) that the trajectory starting from
attains total return and cost equal to
. In other words,
re-weights the behavior policy
according to how likely each action is to lead to a trajectory whose joint return–cost pair matches the conditioning signal
.
Our analysis relies on a coverage condition and a mild regularity assumption. For an initial state , let and denote the (random) return and cost of a trajectory sampled from the behavior policy starting from . Represent the return–cost coverage for by which is the conditional probability that the total return and cost of the trajectory match the conditioning signal . For any policy , we define and as its expected return and expected cumulative cost, respectively.
Assumption 1. 1. Return–cost coverage. There exists a constant such that - 2.
Near determinism. (This assumption does not restrict the stochasticity of the initial state .) There exist deterministic functions , , and such that, for all and all time steps t, - 3.
Consistency of F. For every transition under the deterministic dynamics T, the conditioning function satisfies
Theorem 1 (Joint alignment with respect to the conditioning function in CMDPs).
Consider a finite-horizon CMDP, a behavior policy , and a conditioning function . Suppose Assumption 1 is satisfied. Let denote the CDT policy in (3). Then there exists a universal constant , such that
The proof is provided in
Appendix A.1.
Theorem 1 formalizes the alignment behavior of return–cost conditioned sequence modeling in CMDPs. Under joint return–cost coverage and near-deterministic dynamics, the optimal solution to the CDT objective induced by a fixed conditioning function F produces a policy whose expected return and expected cumulative cost track the prescribed targets, with a mismatch bounded by . This result provides a theoretical basis for viewing RTG/CTG conditioning as a mechanism for zero-shot control of the return–cost trade-off: when the target profile specified by F is sufficiently represented in the behavior data (large ), conditioning can be realized reliably up to a controllable error. At the same time, the explicit dependence on clarifies a fundamental limitation of naive target conditioning in offline safe RL. In realistic datasets where safe high-return trajectories are scarce, can be small for ambitious targets, and the induced policy may substantially deviate from the intended profile, leading to unstable return–cost trade-offs and even constraint violations. In particular, simply specifying a high RTG together with a low CTG does not reliably yield favorable return–cost trade-offs on challenging datasets with limited coverage of safe, high-performance behaviors.
This motivates augmenting the plain CDT backbone with data-aware mechanisms that reshape the effective training distribution and provide additional optimization signals beyond maximum likelihood. Specifically, we seek to bias learning toward trajectories with more desirable return–cost profiles while retaining the flexibility of target conditioning for multi-threshold, zero-shot deployment. Notably, the same proof technique also extends to multi-goal conditioning by viewing each conditioning coordinate as an additional scalar, reward-like signal that obeys a Markov-consistent recursion along transitions, leading to analogous coverage-dependent alignment bounds in higher-dimensional conditioning spaces. In the following, we instantiate this principle by introducing a regularized CDT variant that incorporates trajectory-level reweighting and value-based terms, aligning with a broader line of work showing that reweighting and regularization can substantially improve DT-style and CSM-based offline RL under distribution shift and data imbalance [
13,
18,
26,
36].
Theorem 1 characterizes the infinite-data behavior of the ideal CDT policy induced by a fixed conditioning function
F. We next give a finite-data extension showing that, under an additional occupancy-mismatch condition, the performance gap between the ideal CMDP-conditioned CDT policy and a finite-data estimator can be reduced to the supervised learning loss optimized by CDT. Let
denote the average state occupancies of the behavior policy and the ideal CDT policy, respectively. For any candidate conditional policy
, define its deployment under the conditioning function
F by
We also define the expected CDT loss as
Assumption 2 (Bounded occupancy mismatch).
There exists a constant , such that Theorem 2 (Finite-data reduction of CMDP-conditioned CDT to supervised learning).
Consider the finite-horizon CMDP setting in Theorem 1, and suppose that Assumption 1 holds, i.e., Assume further that Assumption 2 holds. Let be any estimated conditional policy, and let denote its deployed policy under F. Then Proof. For brevity, write
For each state
s, define the joint distributions
By construction, the ideal CDT policy satisfies
while
Therefore,
By the joint return–cost coverage assumption,
Substituting this into (
12) and then applying Pinsker’s inequality gives
Next, we bound the performance difference by the action-distribution mismatch. For reward, by the standard performance-difference decomposition for finite-horizon MDPs,
where
is the state distribution at time
t under
, and
is the reward-to-go under
. Since each per-step reward is bounded by 1, we have
Hence,
Using Assumption 2,
for any non-negative function
g. Applying this to (
15) and then using (
13), we obtain
where the last step follows from Jensen’s inequality.
It remains for us to identify the expectation in (
16) with the CDT loss. Since
the chain rule of KL divergence yields
Taking expectation over
gives exactly
in (
9). Substituting into (
16) proves (
10).
The proof of the cost bound is identical. Since each per-step cost is bounded by 1, we have
which yields
This completes the proof. □
Theorem 2 reduces the CMDP performance gap to the supervised loss optimized by CDT. We next convert this reduction into a finite sample bound under a finite policy class and standard uniform-convergence assumptions.
Let
be a dataset of
N i.i.d. samples drawn from the joint distribution induced by
and
. For a policy class
, define the empirical loss
and let
Corollary 1 (Sample complexity of plain CMDP-conditioned CDT). Under the assumptions of Theorem 2, additionally assume that
- 1.
Π is finite;
- 2.
There exists a constant such that - 3.
The approximation error of Π
is bounded by , i.e.,
Then for any , with probability at least ,Equivalently, up to universal constants, Proof. For each fixed
, the random variable
takes values in
. Therefore, by Hoeffding’s inequality,
Applying a union bound over all
, we obtain that with probability at least
,
Let
Since
minimizes the empirical loss,
Using (
23) twice, we obtain
Substituting (
24) into Theorem 2 gives (
19) and (20). The simplified
-form follows by
This completes the proof. □
Remark 1. Assumption 1 adopts an equality-based return–cost coverage condition,which is consistent with prior theoretical analyses of conditional sequence modeling in RL [18,26] and is particularly natural in idealized or tokenized formulations where return and cost signals are discrete or effectively quantized. The coverage condition can be extended in a straightforward manner to neighborhood-based (δ) coverage, which replaces exact matching by requiring non-trivial probability mass in a δ-neighborhood of the target signal, i.e.,Another closely related perspective is to define coverage through density-based support via a kernel (e.g., a Gaussian kernel or a ball indicator); for example,In Equation (3), such a smoothing corresponds to replacing by a smoothed likelihood of landing near , yielding the same reweighting interpretation in a continuous manner. 4.2. Trajectory-Weighted Value-Regularized Constrained Decision Transformer
Building on CDT, we introduce two data-aware training ingredients to improve algorithm performance while retaining the RTG/CTG conditioning interface for multi-threshold, zero-shot deployment. Specifically, we (i) reshape the effective training distribution via trajectory-level reweighting toward more desirable return–cost profiles, and (ii) incorporate value-based guidance as an additional optimization signal to discourage overly conservative behaviors. This design follows the technical progression summarized in
Table 1: it generalizes the sub-dataset resampling used in DT-style methods (e.g., RDT/RVDT) to a more flexible trajectory-level scheme, and adapts the Q-value regularization principle of QT to the constrained CDT setting.
Let
and
denote the cumulative return and cumulative cost of a trajectory
respectively. We introduce a non-negative weighting function
which assigns larger weights to trajectories that exhibit more favorable return–cost trade-offs. It suffices to note that
depends jointly on return and cost, and therefore encodes both performance and safety preferences at the trajectory level. Given these weights, consider the following weighted variant of the CDT loss:
The loss (
26) preserves the behavior-cloning structure of CDT while explicitly rebalancing the empirical training distribution toward trajectories that are simultaneously high-return and low-cost.
To connect this formulation with existing DT-based methods, we draw a connection to the KL-based expert regularization used by RDT and RVDT in prior work [
26]. Consider the RDT objective:
where
is a subset of near-optimal trajectories and
is an expert policy obtained from imitation learning on
. The following result shows that the expert KL term implicitly induces a particular trajectory-level weighting scheme, and can therefore be seen as a special case of our general reweighting formulation.
Proposition 1 (KL regularization as a special case of trajectory weighting).
Assume that is parameterized as a factorized Gaussian policy with a fixed standard deviation and that is fitted on via maximum-likelihood imitation learning. Then the RDT objective in Equation (27) can be rewritten as a weighted DT loss: with trajectory weights
The proof is provided in
Appendix A.2.
Proposition 1 indicates that KL-based expert regularization effectively performs a weighted resampling of expert trajectories, where all trajectories in
share an increased weight and all others retain unit weight. In this sense, RDT is a special case of trajectory-level reweighting that is typically constructed based on return ranking. Our formulation in Equation (
26) generalizes this mechanism by allowing
to depend on both return and cost, and by instantiating it on the constrained CDT backbone.
In addition, prior results from QT [
13] and RVDT [
26] indicate that value-based regularization can improve the robustness of DT-style policies for challenging offline datasets. Accordingly, we augment Equation (
26) with a value guidance term and obtain
where
is a regularization coefficient and
denotes the action-value function of the current CSM policy
. We term the resulting algorithm as Trajectory-Weighted Value-Regularized Constrained Decision Transformer (TVCDT). The first term in Equation (
29) performs explicit trajectory-level return-cost reweighting on CDT, and the second term provides an optimization signal that encourages actions with higher long-term value under
.
4.3. Return–Cost Regularized Constrained Decision Transformer
While TVCDT already biases learning toward trajectories that are both high-return and low-cost, it lacks an explicit cost-penalization mechanism to further discourage unsafe behavior. A standard approach in safe reinforcement learning is to formulate policy learning as a constrained optimization problem in CMDPs and to introduce Lagrangian penalties to balance performance and safety. Following this perspective, we derive a cost-penalized training objective together with an adaptive update rule for its coefficient, while avoiding coupling CDT to a single fixed-cost threshold. To motivate the penalty term, consider minimizing the weighted CDT loss with value guidance subject to an upper bound
on the expected cumulative cost of the learned policy. A CMDP-style formulation can be written as
where
denotes a target cost level. Introducing a Lagrange multiplier
leads to the Lagrangian
Equation (
31) serves as a motivating formulation rather than as a strict optimization problem: it suggests that a natural way to bias the policy towards safer behaviors is to augment the training loss with the expected cost term, weighted by an appropriate coefficient. Imposing this constraint as a hard requirement tied to a fixed
would also be at odds with the zero-shot adaptation capability of conditional sequence modeling, where a single CDT policy is expected to generalize across a range of cost thresholds. Instead, we treat the cost term as a flexible regularizer whose influence is controlled by an adaptive coefficient
.
Finally, we arrive at our offline safe RL algorithm, referred to as Return–Cost Regularized Constrained Decision Transformer (RCDT), by optimizing the following cost-penalized actor objective:
where we reinterpret
as an adaptive regularization coefficient rather than an exact Lagrange multiplier associated with a fixed hard constraint, thereby using it to balance performance and safety. To obtain such an adaptive update rule, we note that the derivative of the Lagrangian in Equation (
31) with respect to
is proportional to
. This suggests adjusting
according to whether the current policy is above or below the target cost level. In practice, let
denote a minibatch estimate of
We update
using
where
denotes the Euclidean projection onto the interval
,
is the update step size,
is the estimated cumulative cost at iteration
t, and
is the reference cost threshold. When the estimated expected cost
exceeds
,
is increased and the cost penalty in Equation (
32) becomes stronger; when the
falls below
, the penalty is gradually relaxed. This update follows the primal–dual intuition of adjusting a penalty coefficient based on the current level of constraint violation, and provides an automatic way to tune the strength of safety regularization during training. Importantly, since the CDT architecture explicitly conditions on cost tokens, the resulting policy remains compatible with evaluation under multiple cost thresholds without retraining and
should be interpreted as a training-time reference level, rather than a hard constraint that fixes a single deployment threshold.
To further clarify the role of the adaptive coefficient , we note that the clipped update used in practice can be equivalently viewed as a projection step onto a compact interval. This observation does not by itself imply convergence of the full nonconvex Transformer training objective, but it does provide a simple and rigorous boundedness guarantee for the dual coefficient throughout training.
Proposition 2 (Boundedness of the adaptive coefficient).
Consider the update where denotes the Euclidean projection onto the interval , is the update step size, is the estimated cumulative cost at iteration t, and κ is the reference cost threshold. Then, for any initialization , the iterate sequence satisfies Proof. The result follows directly from the definition of the projection. Assume
. Let
By definition of the Euclidean projection onto the closed interval
,
Since
, the claim follows by induction. □
Proposition 2 shows that the clipped update of admits a standard projection-based interpretation. Therefore, the adaptive coefficient remains bounded throughout training by construction. We emphasize that this boundedness result is a property of the projected dual update itself, and should be understood as a stability guarantee for the coefficient , rather than as a convergence guarantee for the full nonconvex optimization of the Transformer-based objective.
In practice, the trajectory weights
in Equation (
32) are instantiated by a return–cost shaped function that increases with return and decreases with cost relative to a prescribed limit. Specifically, we use
where
and
control the sensitivity of
to return and cost, and
denotes a trajectory-level cost reference. This choice is consistent with the general form
introduced in
Section 4.2, and makes explicit how return and cost jointly shape the effective training distribution.
Figure 2 illustrates the effect of Equation (
34) on representative tasks. Each point corresponds to a trajectory in the offline dataset, with cumulative cost on the horizontal axis and return on the vertical axis; color intensity indicates the magnitude of
(darker means larger weight). As costs increase beyond the reference
, trajectories are progressively down-weighted, whereas trajectories that achieve higher returns while remaining within (or near) the cost reference are emphasized. This visualization highlights how trajectory-level return–cost reweighting reshapes the training signal toward safer and more performant regions of the offline data.
Putting these components together, RCDT can be viewed as a CMDP-inspired extension of CDT within the CSM paradigm. It retains the target-conditioning interface of CDT for multi-threshold, zero-shot evaluation, while augmenting maximum-likelihood training with three complementary ingredients: trajectory-level return–cost reweighting to emphasize favorable behaviors in the offline data, value-based guidance to refine the policy beyond pure imitation, and an explicit cost penalty whose coefficient is adaptively tuned to control safety in expectation. In this way, RCDT aligns with the DT-based objective design path summarized in
Table 1, while remaining directly applicable to zero-shot adaptation across multiple cost thresholds at evaluation time.
4.4. Training and Inference
We instantiate RCDT using a transformer-based architecture. The policy is implemented as an autoregressive Transformer that takes as input a context window of past states, actions, and target return–cost tokens, and outputs the parameters of a stochastic policy. Following common practice in sequence-modeling RL, is modeled as a factorized Gaussian distribution whose mean and log-variance are predicted by separate fully connected output heads at each step of the sequence. For a CDT policy at timestep i, and denote the RTG and CTG tokens obtained by cumulatively summing future rewards and costs along the underlying trajectory, and denotes the length-K history of past states and actions. When , the context window is truncated to the available prefix of the trajectory.
Training. The overall training pipeline of RCDT is summarized in Algorithm 1. Prior to training, the cumulative return
and cumulative cost
are computed for each trajectory
. These statistics are used to instantiate the trajectory weights
via Equation (
34), which increase with return and decrease with cost relative to a reference limit
. During each training iteration, a trajectory
is sampled from the dataset, a length-
K subsequence is extracted, and the corresponding CDT inputs are
.
Value learning is carried out using standard offline temporal-difference (TD) methods. The reward critic
approximates the action-value function
, while the cost critic
approximates the cost-to-go function
. Given a transition
from the sampled subsequence, a next action
is drawn from the current policy
, and TD targets are constructed using
and
for the reward and cost critics, respectively. In practice, standard stabilization techniques such as target networks [
47] and double Q-learning [
48] are employed for both
and
.
| Algorithm 1: RCDT: Return–Cost Regularized Constrained Decision Transformer |
|
The policy parameters
are updated by minimizing the actor loss in Equation (
32). Concretely, for each CDT input in the subsequence, an action
is sampled from
, and the corresponding critic evaluations
and
are used to form a Monte Carlo estimate of the expectations in Equation (
32). The trajectory weight
is applied to the negative log-likelihood term to realise the return-cost reweighting effect. The critic-based terms provide value and cost guidance, and the combined stochastic gradient is used to update
via gradient descent.
The coefficient
that controls the strength of the cost penalty is updated adaptively according to Equation (
33). At each iteration, an empirical estimate
of
is obtained by averaging
over the sampled subsequence. The update
then increases
when the current policy exceeds the reference cost level
, and decreases it otherwise. As discussed in
Section 4.3,
is therefore interpreted as an adaptive regularization coefficient rather than an exact Lagrange multiplier, and its update rule is inspired by Lagrangian dual ascent in safe RL.
Inference. The inference procedure of RCDT closely follows that of CDT and other CSM methods, with the additional capability of conditioning on cost. At each decision step, the model receives four input sequences: the target RTG, the target CTG, the past states, and the past actions. Given these inputs, the Transformer autoregressively predicts a sequence of K actions, of which only the final action in the window is executed in the environment.
After executing the selected action and observing the realized reward and cost, both the RTG and CTG tokens are updated for the next timestep. Specifically, the target RTG is decreased by the observed reward, and the target CTG is decreased by the observed cost, mirroring the cumulative structure used to construct and in the offline dataset. These updated tokens are appended to the conditioning sequence and fed back into the Transformer to generate the next action sequence. Different evaluation thresholds on the cumulative cost are imposed by choosing different initial CTG values without retraining the model. In this way, RCDT preserves the zero-shot adaptation capability of CDT across a range of safety requirements, while leveraging trajectory-level reweighting, value guidance, and cost regularization to produce policies that are both high-performing and safety-aware.
5. Experiments
We conduct a comprehensive empirical evaluation of RCDT on the DSRL benchmark [
19]. In
Section 5.1, we compare RCDT against a broad range of representative offline safe RL baselines spanning multiple methodological paradigms, including imitation learning [
1], value-based methods [
10,
23,
24], CSM-based approaches [
7], distribution-matching methods [
9], as well as data-quality and feasible-region methods [
2,
11]. In
Section 5.2, ablation studies are conducted to analyze how each key component of RCDT affects the safety–performance trade-off, focusing on the Lagrangian-style cost penalty, trajectory-level reweighting, and Q-value regularization. Moreover, to further assess the robustness of RCDT under more demanding evaluation settings, dataset variants from the original DSRL benchmark with (i) a lower proportion of expert-level trajectories and (ii) more imbalanced data distributions are considered.
Tasks. We evaluate RCDT on the DSRL benchmark [
19], a public benchmark that includes a variety of continuous-control and robot locomotion tasks commonly used in prior offline safe RL research [
1,
2,
4,
10,
11,
25,
49]. DSRL provides offline datasets collected from three widely used safety-critical simulators, including Mujoco-based SafetyGym [
50], PyBullet-based BulletSafetyGym [
51], and the autonomous-driving simulator MetaDrive [
52]. In
SafetyGym, we consider
goal-reaching,
pushing, and
circle-tracking tasks with two agent morphologies (
Point and
Car). The agent is rewarded for completing the intended objective, such as reaching a target location, pushing an object to a goal, or tracking a circular route, while safety cost is incurred when the agent enters hazardous regions and, for circle-style tasks, when it violates the safety boundary constraints. We additionally include velocity-constrained locomotion tasks with standard Mujoco agents, including
Swimmer,
Hopper,
HalfChee,
Walker2d, and
Ant. In these tasks, reward encourages forward progress, whereas cost is triggered when the agent’s speed exceeds a predefined limit.
BulletSafetyGym provides analogous safety-critical locomotion tasks with different robot morphologies. We evaluate on
Run and
Circle tasks with multiple robots (
Ball,
Car,
Drone, and
Ant). In
Run, the agent is rewarded for fast forward motion within boundaries, but incurs cost when leaving the corridor or exceeding a velocity cap. In
Circle, the agent is rewarded for clockwise circular motion while being penalized for leaving a designated safe region. Finally, in
MetaDrive we evaluate offline safe driving datasets with increasing scenario difficulty and traffic density (e.g.,
Easy/Medium/Hard combined with
Sparse/Mean/Dense), which capture realistic safety–performance tensions in interactive driving. Here reward encourages route progress and stable driving, while safety cost is issued for events such as collisions and driving out of the road. Across all suites, reward promotes task completion, whereas cost penalizes safety violations. This inherent reward–cost conflict makes it necessary to balance return maximization against cumulative cost constraints: aggressively pursuing high reward can lead to constraint violations, while overly conservative policies tend to satisfy constraints at the expense of performance.
Baselines. We compare RCDT against the following baselines. (i) Imitation learning: Behavior cloning (BC) and its safety-aware variant BC-Safe [
1]. (ii) Value-based with constraint handling: CPQ [
10], BCQ-Lag, and BEAR-Lag, where the latter two are safety-constrained variants of BCQ [
23] and BEAR [
24] obtained by incorporating Lagrangian penalties. (iii) CSM-based: Constrained Decision Transformer (CDT) [
7], a representative CSM method that learns conditioned policies. (iv) Distribution matching: COptiDICE [
9], which performs constrained policy optimization via occupancy-measure matching in the DICE family [
53]. (v) Data-quality and feasible-region methods: TraC [
2], and FISOR [
11], which explicitly reason about safe regions or trajectory-level feasibility.
Implementation. Our implementation of RCDT is built upon the CDT implementation provided in the OSRL (
https://github.com/liuzuxin/OSRL/tree/main (accessed on 12 March 2026)) project repository released by the CDT authors. We reproduce CDT using this codebase and its recommended hyperparameters. For the remaining baselines, we either run their publicly available implementations or report results from the original papers or representative prior work [
1,
2,
3,
4], depending on availability. Additional implementation details are provided in
Appendix B.2.
Evaluation. We follow the standard
constraint-variation evaluation protocol for offline safe RL [
1,
2,
19], which assesses an algorithm’s robustness and versatility under different levels of safety constraints. Concretely, each method is evaluated on every dataset under three target cumulative-cost thresholds, i.e.,
for SafetyGym,
for BulletSafetyGym, and
for MetaDrive, and the final score is obtained by averaging over these thresholds. For methods that can be evaluated under multiple thresholds without retraining (BC, BC-Safe, CDT, and our RCDT), we train a single policy per dataset and evaluate its behavior across all thresholds in a zero-shot manner. Notably, although CDT and RCDT involve a target cost level
during training, which is set as a fixed hyperparameter for each dataset, the learned policies remain CTG-conditioned and are evaluated across all target thresholds without additional retraining. By contrast, for threshold-dependent baselines whose training objective explicitly depends on the target constraint level, including BCQ-Lag, BEAR-Lag, COptiDICE, CPQ, FISOR, and TraC, we train separate models for different thresholds following their original training pipelines and the benchmark protocol to align with their intended training settings. Overall, this protocol provides a comprehensive assessment of the return–cost trade-off across a range of cost requirements, and it also directly validates the zero-shot deployment capability of RCDT under varying cost thresholds.
Metrics. We report the
normalized return and
cumulative cost as the comparison metrics, consistent with prior offline safe RL literature [
1,
2,
19]. Let
and
denote the maximum and minimum returns, respectively, observed in dataset
. The normalized return is computed by
where
denotes the evaluated return of policy
. The normalized cumulative cost is defined by the ratio of the evaluated cumulative cost
to the target threshold
, i.e.,
with
, noting that all costs in our setting are non-negative.
5.1. Main Results for RCDT on DSRL Benchmark
The experimental results of RCDT and all baselines on the DSRL benchmark are summarized in
Table 2. Overall, RCDT achieves consistently strong performance across SafetyGym, BulletSafetyGym, and MetaDrive, attaining the best return–cost performance on the majority of tasks. Interpreting
Table 2 requires jointly considering safety and task performance. We first identify methods that satisfy the cost constant, indicated by
bold entries where the averaged normalized cost is below 1. Among these safe methods, we primarily compare the averaged normalized return, with the highest safe return highlighted in
blue. Lower cost among already-safe methods is reported but treated as secondary, since overly conservative behavior can reduce cost without translating into meaningful task progress. This evaluation criterion aligns with the objective of constrained offline RL: satisfying safety requirements while preserving as much task performance as possible.
BC simply imitates the behavior in the offline dataset without any cost awareness, and can be viewed as an approximation of the behavior policy
. As shown in
Table 2, such naive imitation does not provide meaningful safety guarantees, and often yields costs well above the constant. BC-Safe, in contrast, explicitly restricts training to trajectories that satisfy the cost constraint, and consequently achieves normalized costs below 1 on most tasks. However, this safety is obtained at the expense of substantially reduced returns, particularly on more challenging velocity-control and circle tasks where high-return behavior is relatively scarce in the dataset. Notably, RCDT consistently attains higher returns than BC-Safe across all tasks, while maintaining competitive costs in most cases, leading to a markedly better return–cost trade-off. This comparison highlights an inherent limitation of purely supervized imitation-style methods under imbalanced data: imitating only a small “safe” subset may enforce constraint satisfaction, but the resulting loss of coverage over high-return regions severely limits achievable performance and generalization.
Value-based offline RL baselines with constraint handling (BCQ-Lag, BEAR-Lag, COptiDICE, and CPQ) often struggle to deliver a reliable return–cost trade-off across domains. On SafetyGym and BulletSafetyGym, these methods frequently incur normalized costs well above the safety constraint on a nontrivial portion of tasks, even when their returns are relatively competitive. In contrast, on MetaDrive, several of them (BEAR-Lag and CPQ) exhibit overly conservative behavior with markedly reduced returns despite achieving low costs. Taken together, these results suggest that simply incorporating scalar penalties, Lagrangian relaxations, or distribution-matching objectives into otherwise unconstrained offline RL pipelines does not consistently provide strong returns: the resulting trade-off is highly sensitive to the environment and the underlying data distribution, and does not robustly balance safety satisfaction with task performance. By comparison, RCDT achieves substantially more consistent return–cost trade-offs across SafetyGym, BulletSafetyGym, and MetaDrive, attaining strong returns while keeping costs close to or below the safety constraint on the vast majority of tasks.
FISOR and TraC are strong offline safe baselines that explicitly target safety-critical offline learning and often achieve low costs in practice. This pattern is evident from
Table 2. On BulletSafetyGym and MetaDrive, FISOR attains extremely low average costs (0.03 and 0.08) but yields notably lower average returns (0.39 and 0.36) than RCDT (0.63 and 0.69). On SafetyGym, FISOR is less reliable, with an average cost of 3.81 despite a moderate return of 0.42. TraC maintains relatively low costs across domains (average costs of 0.93/0.56/0.54 on SafetyGym/BulletSafetyGym/MetaDrive), yet its average returns (0.46/0.61/0.53) consistently trail those of RCDT (0.59/0.63/0.69). Overall, while these methods provide competitive safety-oriented baselines, RCDT achieves a more favorable return–cost trade-off across all three domains, delivering higher returns while keeping costs close to or below the safety constraint on the majority of tasks.
The comparison with CDT is particularly informative. Both CDT and RCDT are CTG-conditioned CSM methods, so their policies can be evaluated across multiple cost thresholds in a zero-shot manner. As shown in
Table 2, CDT tends to yield costs that concentrate around the safety constraint, and it even slightly exceeds the threshold on SafetyGym on average (cost
). In contrast, RCDT achieves lower costs than CDT across all three domains (1.09→0.95 on SafetyGym, 0.77→0.68 on BulletSafetyGym, and 0.95→0.71 on MetaDrive), while also improving average returns (0.55→0.59, 0.61→0.63, and 0.40→0.69, respectively). This gap is consistent with the fact that CDT can be viewed as a degenerate variant of RCDT that relies on naive CTG-conditioned maximum-likelihood training alone. By augmenting CDT with (i) a Lagrangian-style cost penalty with an auto-adaptive coefficient, (ii) reward–cost-aware trajectory-level reweighting, and (iii) Q-value regularization, RCDT more effectively suppresses behaviors that lead to constraint violations while still encouraging high-return actions. As a result, RCDT achieves a more favorable return–cost trade-off than CDT, demonstrating that principled regularization and reweighting are essential for realizing the full potential of CSM backbones in CMDPs.
Overall, the experimental results show that RCDT achieves consistently strong return–cost trade-offs on the DSRL benchmark. Compared with representative baselines, RCDT more reliably attains high normalized returns while satisfying the cost constraint on the vast majority of tasks, indicating robust behavior across diverse environments and data regimes. Moreover, RCDT supports one-policy evaluation across multiple cost thresholds: a single trained policy can be deployed in a zero-shot manner by adjusting the target CTG, accommodating different safety requirements at inference time. Taken together, these comparisons demonstrate the effectiveness of RCDT across multiple methodological baselines and suggest that it is a competitive approach with strong potential to advance the state-of-the-art in offline safe RL.
5.2. Ablation Studies
5.2.1. Component-Level Ablation
To empirically investigate the contribution of each individual component in the proposed RCDT under safety-constrained settings, we compare RCDT with its ablation variants on representative SafetyGym tasks. The ablations target four key aspects:
CSM-based architecture,
trajectory-level weighting,
Q-value guidance, and
Lagrangian-style cumulative cost penalty, whose configurations are summarized in
Table 3. In this table, “CSM-based architecture” indicates whether the policy is implemented as a Decision Transformer-style conditional sequence model, “Trajectory-level weighting” denotes the use of our data-weighting mechanism, “Q-value guidance” corresponds to value-based guidance, and “Cumulative-cost penalty” reflects the presence of the cost-penalization term in the objective. BC and BC-Safe serve as imitation-learning baselines without a CSM backbone; BC-Safe differs from BC only in that it applies trajectory-level weighting to favor safer trajectories. CDT is the vanilla CSM-based baseline without any of the newly introduced components. Building on CDT, TVCDT enables both trajectory-level weighting and Q-value guidance, TCCDT combines trajectory-level weighting with the cumulative-cost penalty, and VCCDT uses Q-value guidance together with the cumulative-cost penalty but no weighting. Finally, RCDT activates all four components and thus represents the full version of our proposed method.
Table 4 summarizes the component-level ablation results on three representative SafetyGym velocity-constrained tasks. We first observe that plain behavior cloning (BC) consistently yields unsafe policies, exhibiting large normalized costs across all tasks (e.g., costs well above 1), which confirms that these datasets are challenging and that naive imitation of the behavior data does not suffice for constraint satisfaction. Introducing safety-aware trajectory reweighting in BC-Safe substantially reduces costs compared with BC, but this improvement often comes with a notable return drop (e.g., on
HopperVel), reflecting the typical conservatism induced by prioritizing low-cost behavior without an explicit mechanism to recover high-return actions.
A key takeaway is that a CSM backbone provides a stronger and more controllable foundation for offline safe RL. Although CDT is also trained via maximum-likelihood action modeling, it consistently achieves a better return–cost trade-off than BC-Safe, attaining both higher return and lower cost across all tasks. This suggests that the target-conditioned sequence-modeling form can better accommodate constraint variation at evaluation time, and that leveraging trajectory context together with RTG/CTG conditioning yields more effective trade-off control than non-CSM imitation baselines. Notably, all RCDT variants built on top of the CSM architecture inherit this advantage, further highlighting the importance of CSM as the policy backbone in safety-constrained offline learning.
The ablations also confirm that each proposed component contributes meaningfully and the full combination is necessary for the best trade-off. Compared with CDT, all partial variants (TVCDT, TCCDT, and VCCDT) that activate any two of the three mechanisms (weighting, Q-guidance, and cost penalty) improve (or keep) return while remaining within a comparable safety range, indicating that each ingredient provides non-trivial gains over naive CTG-conditioned training. However, these gains are consistently smaller than those of the full method: RCDT achieves the best overall return–cost trade-off on all tasks, and removing any single component leads to performance degradation, demonstrating that the components are complementary rather than redundant.
A more fine-grained comparison further clarifies the role of each ingredient. First, TVCDT consistently increases return over CDT, but it also increases cost across all tasks, which matches our design intuition: trajectory-level weighting and Q-value guidance primarily mitigate overly conservative behavior and steer learning toward higher-return regions, typically at the expense of additional cost. Crucially, RCDT introduces the Lagrangian-style cumulative-cost penalty on top of these return-seeking signals, and achieves lower cost than TVCDT without sacrificing its return gains, indicating that the penalty term provides an effective counterbalance that stabilizes constraint satisfaction while remaining compatible with the other mechanisms. Second, TCCDT and VCCDT both combine one return-improving signal with the cost penalty; the resulting policies generally outperform CDT in return but still exhibit higher costs than the full method, suggesting that using only a single return-seeking mechanism is insufficient to fully resolve the conservatism–violation tension, and that the best trade-off emerges only when both weighting and Q-guidance are jointly leveraged under the cost-penalized objective.
Overall, the ablation study provides clear evidence for the intended functional roles of the components: the Lagrangian-style penalty is essential for reducing cost and stabilizing constraint satisfaction, whereas trajectory-level weighting and Q-value guidance are key to improving return by avoiding overly conservative solutions. Importantly, RCDT achieves the most favorable return–cost trade-off only when all components are enabled, validating the necessity and complementarity of the proposed design choices.
5.2.2. Robustness Evaluation on DSRL Dataset Variants
To further examine the robustness of RCDT under more demanding data regimes by evaluating it on a set of dataset variants derived from the original DSRL benchmark. All variants are constructed by retaining a subset of trajectories from each original dataset to induce (i) a lower proportion of expert-level trajectories and (ii) more imbalanced return distributions. The corresponding results are reported in
Table 5 and
Table 6, respectively. For each environment, we order the retention ratios from larger to smaller values, so that the reported settings become progressively more challenging as the available data decreases (or becomes more skewed).
Performance under lower expert-data coverage. Table 5 reports results on degraded datasets constructed by retaining only the bottom-
low-return trajectories (ranked by return), which directly reduces expert-level coverage and makes it substantially harder to recover favorable return–cost trade-offs from offline data. Across the five velocity-constrained locomotion tasks (
SwimmweVel,
HopperVel,
HalfCheetahVel,
Walker2dVel, and
AntVel), RCDT remains consistently competitive as
decreases from
to
. In most settings, RCDT achieves the highest reward while maintaining costs comparable to CDT, whereas BC often incurs noticeably larger cumulative costs. For example, on
HopperVel and
AntVel, RCDT preserves strong reward across all retention ratios and avoids the severe cost explosion observed for BC, indicating that the Lagrangian-style penalty provides an effective bias toward constraint satisfaction even when safe expert trajectories are removed. Moreover, RCDT often improves reward over CDT at similar cost levels (e.g.,
and
on multiple tasks), suggesting that the proposed trajectory-level reweighting and Q-value regularization can still exploit informative sub-optimal data to enhance performance under reduced expert coverage.
Performance under imbalanced data distributions. Table 6 evaluates a complementary stress test where the dataset is made increasingly imbalanced by retaining only the top-
and bottom-
trajectories. This construction amplifies distribution skew and can exacerbate the tendency of likelihood-trained policies to overfit dominant modes, making robust trade-off control more challenging as
decreases. Overall, RCDT exhibits strong robustness across tasks when
is reduced from
to
: it consistently achieves the highest reward, and it remains competitive in cumulative cost relative to CDT, while BC typically suffers substantial reward degradation and often very large costs. Notably, on
HalfCheetahVel and
SwimmweVel, RCDT maintains near-saturated normalized returns even at
, demonstrating that its training recipe can still leverage the retained high-quality trajectories without being derailed by the low-return tail. At the same time, costs can increase under the most extreme imbalance on some tasks (e.g.,
SwimmweVel and
HopperVel at small
), reflecting the intrinsic difficulty of satisfying constraints when the dataset provides limited coverage of safe behaviors under heavily skewed mixtures; nevertheless, RCDT typically delivers a better overall return–cost trade-off than both CDT and BC. These results suggest that RCDT is less sensitive to return-distribution skew and can better tolerate highly imbalanced offline datasets, which aligns with our goal of robust zero-shot safe control under limited and biased coverage.
5.2.3. Sensitivity Analysis of the Training-Time Cost Reference
We further investigate the sensitivity of RCDT to the training hyperparameter
in Equation (
33), which serves as a
reference cost level for adapting the penalty coefficient
. Here,
is
not a hard deployment-time constraint; rather, it only modulates the strength of the cumulative-cost penalty during training through the update of
.
Table 7 reports the results of training RCDT with different
values and evaluating the resulting policies under the standard constraint-variation protocol.
As increases, the learned policy generally becomes less conservative, which often improves return but also tends to increase cumulative cost. This effect is particularly visible on the MetaDrive tasks (MediumSparse and HardMean), where the normalized cost rises noticeably once exceeds 10, eventually leading to cost values above the safety threshold. This behavior is consistent with the evaluation protocol, where each method is tested under multiple target cumulative-cost thresholds (SafetyGym: ; BulletSafetyGym: ; and MetaDrive: ): when the training reference level exceeds the most stringent evaluation budget, the learned policy is more likely to incur a higher risk of constraint violation under the strictest test conditions. At the same time, this trend is not absolute. For example, on the BulletSafetyGym tasks (AntRun and CarCircle), increasing does not lead to severe violations, which further suggests that the target CTG specified at inference still plays an important role in maintaining alignment with the desired cost level and enables effective zero-shot adaptation across different evaluation budgets.
A complementary trend is observed on the return side. When is set too small, the policy is encouraged to be overly conservative, which suppresses return; when is increased to a moderate range, return improves consistently. However, excessively large may yield only marginal additional (or even negative) return gains while substantially increasing the risk of violating the evaluation-time safety requirements. Overall, these results support our interpretation that mainly controls the return–cost trade-off indirectly through the training-time regularization strength, rather than imposing a strict cost constraint by itself. From a practical standpoint, a reasonable choice is to set slightly below, but not overly below, the smallest evaluation-time cost budget, which provides a balanced trade-off between avoiding overly conservative behavior and maintaining robustness under strict safety thresholds.