In reinforcement learning environments with state-dependent action validity, action masking consistently outperforms penalty-based handling of invalid actions, yet existing theory only shows that masking preserves the policy gradient theorem. We identify a distinct failure mode of unmasked training: it systematically suppresses valid actions at states the agent has not yet visited. This occurs because gradients pushing down invalid actions at visited states propagate through shared network parameters to unvisited states where those actions are valid. We prove that for softmax policies with shared features, when an action is invalid at visited states but valid at an unvisited state s∗, the probability π(a∣s∗) is bounded by exponential decay due to parameter sharing and the zero-sum identity of softmax logits. This bound reveals that entropy regularization trades off between protecting valid actions and sample efficiency, a tradeoff that masking eliminates. We validate empirically that deep networks exhibit the feature alignment condition required for suppression, and experiments on Craftax, Craftax-Classic, and MiniHack confirm the predicted exponential suppression and demonstrate that feasibility classification enables deployment without oracle masks.
Figures & tables
Figure 1: Suppression mechanism illustrated on a staircase corridor. (a) The agent must traverse a corridor to reach a staircase at s∗ , where descend is the only valid goal-reaching action. At T=0 , all actions are equally likely ( 1/n ). After N training steps, gradient updates at visited states reinforce right and suppress all other actions, including descend . Because parameters are shared, this suppression propagates to s∗ before the agent arrives. The descend action is suppressed at the one state where it is needed. (b) Upper bound on π(descend∣s∗) from Theorem 1 . Without entropy regularization ( β=0 ), the probability decays exponentially. With entropy regularization ( β>0 ), a floor emerges but cannot eliminate suppression (Eq. 7 ).
Figure 2: Architecture overview. A shared encoder ϕ(s) feeds three heads: a classification head (blue) predicting action validity ν^(s,a) via sigmoid, a policy head (green) producing oracle-masked actions πθoracle(a∣s) , and a value head (orange) estimating V(s) . The predicted validity constructs a predicted policy πθpred(a∣s) . The KL divergence between πoracle and πpred yields per-action weights wa for the classification loss (Eq. 12 ). The total loss combines PPO and weighted classification objectives (Eq. 9 ). Dashed arrows indicate loss aggregation. At deployment, there are two modes: (i) with oracle masks available, classification heads can be discarded; (ii) without oracle masks, the learned predictor provides validity estimates for deployment.
Figure 3: Action suppression in Craftax and MiniHack Corridor-5 (PPO-Hybrid). Left: probability of rare critical actions at valid states (log scale). Right: fraction of timesteps with valid actions selected. Unmasked training (C2, red) exhibits exponential suppression, while oracle masking (C1, blue) prevents collapse. Dashed line: uniform initialization.
Figure 4: Representational correlation between valid and invalid states (PPO-Hybrid). Oracle masking preserves highly entangled representations, while KL-balanced classification induces validity-aware features without reintroducing policy-level suppression.
Craftax
Classic
Corridor5
GT
Pred
GT
Pred
GT
Pred
Frames → 1.0 (%)
Ep. Len
PPO-MLP
C2: Unmasked
26.9 ± 0.5
26.9 ± 0.5
19.2 ± 0.0
19.2 ± 0.0
0.9 ± 0.0
0.9 ± 0.0
—
161.3 ± 20.2
C1: Masked
30.4 ± 0.2
-0.9 ± 0.0
19.3 ± 0.0
-0.8 ± 0.0
0.9 ± 0.0
0.1 ± 0.0
—
118.3 ± 8.6
C3: Masked + Focal
24.6 ± 2.9
13.7 ± 1.5
19.4 ± 0.0
15.3 ± 0.6
0.9 ± 0.0
0.9 ± 0.0
—
113.6 ± 8.1
C4: Masked + KL
28.7 ± 3.2
28.6 ± 3.2
19.5 ± 0.0
19.3 ± 0.1
0.9 ± 0.0
0.9 ± 0.0
—
123.6 ± 6.6
Table 1: Evaluation with ground-truth (GT) versus predicted (Pred) masks. Masked-only agents fail when oracle masks are removed. KL-balanced classification enables near-oracle performance under predicted masks across architectures. Results report mean ± std over 4 seeds (10,240 episodes per seed); bold indicates best non-baseline per column.
Figure 6: Mask predictor ablation on Craftax (PPO-Hybrid, λ=20 ). Left: Episode return during training. Center-left: Classification accuracy. Center-right: Return with ground-truth masks. Right: Return with predicted masks.
Figure 7: Classification coefficient sweep with oracle masking and KL-balanced loss on Craftax (PPO-Hybrid). Left: Episode return. Center-left: Classification accuracy. Center-right: Classification loss. Right: Final return evaluated with ground-truth masks (dark) and predicted masks (light).
Figure 8: Suppression profile of the descend action during early training (PPO-Hybrid, λ=20 ). Left: probability at valid states (log scale). Center: probability at invalid states (log scale). Right: Pearson correlation between feature representations of valid and invalid states.