SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.09110 · ICML · 2021

Safe Reinforcement Learning Using Advantage-Based Intervention

Ching-An Cheng, Byron Boots, Nolan Wagener

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 2 violated it and 1 has no contract verdict; 6 failures of our instrument; 0 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2106.09110.json · badge: /api/ran/2106.09110.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
nolanwagener/safe_rl canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
all_bools Ran
ran, violated the contract we drafted
nolanwagener/safe_rl/safe_rl/utils/run_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from milanganai/milanganai.github.io, is pointer only (licence: NONE) · get_code("2103e65a90ce7a04")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from milanganai/milanganai.github.io, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

colorize Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/utils/logx.py
pointer only (licence: MIT); the stored copy get_code serves, from milanganai/milanganai.github.io, is pointer only (licence: NONE) · get_code("7e36f1c357c4618d")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from milanganai/milanganai.github.io, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

combined_shape Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/algos/cppo/core.py
pointer only (licence: MIT); the stored copy get_code serves, from yinglunxu/reward_poisoning_attack_drl, is pointer only (licence: NONE) · get_code("57542f87e248db45")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from yinglunxu/reward_poisoning_attack_drl, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

convert_json Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/utils/serialization_utils.py
code served (permissive licence) · get_code("fbc505a5dac82646")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import json

torch.manual_seed(0)

# Test case 1: JSON-serializable object (int)
obj1 = 42

# Test case 2: dict with nested structures
obj2 = {
    "name": "test",
    "values": [1, 2, 3],
    "nested": {"key": "value"}
}

# Test case 3: tuple
obj3 = (1, 2, "three")

# Test case 4: list with mixed types
obj4 = [1, "two", 3.14, True, None]

# Test case 5: object with __name__ attribute (function)
def my_function():
    pass
obj5 = my_function

# Test case 6: object with __dict__ (custom class instance)
class CustomClass:
    def __init__(self):
        self.attr1 = "value1"
        self.attr2 = 42

obj6 = CustomClass()

# Test case 7: tensor (not JSON serializable)
obj7 = torch.tensor([1.0, 2.0, 3.0, 4.0])

# Test case 8: complex nested structure
obj8 = {
    "tensors": [torch.randn(2, 4)],
    "objects": [CustomClass()],
    "functions": [my_function],
    "primitives": [1, "two", 3.14]
}

# Test case 9: lambda function (should convert to string)
obj9 = lambda x: x + 1

# Test case 10: empty dict
obj10 = {}

ARGS = {
    "obj": obj8
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
count_vars Ran
ran, honoured the contract we drafted
nolanwagener/safe_rl/safe_rl/algos/cppo/core.py
pointer only (licence: MIT); the stored copy get_code serves, from milanganai/milanganai.github.io, is pointer only (licence: NONE) · get_code("4cca5e460067b900")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from milanganai/milanganai.github.io, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_all_datasets Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/utils/plot.py
code served (permissive licence) · get_code("db18a597508be1d7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import json
import pandas as pd

# Create temporary directory structure with necessary files
tmpdir = tempfile.mkdtemp()

# Create first experiment directory
exp1_dir = os.path.join(tmpdir, 'exp1')
os.makedirs(exp1_dir)

# Create progress.txt for exp1
progress_data1 = pd.DataFrame({
    'AverageEpRet': [10.0, 20.0, 30.0],
    'Penalty': [1.0, 1.0, 1.0],
    'AverageEpSurrCost': [2.0, 2.0, 2.0],
    'AverageTestEpRet': [12.0, 22.0, 32.0]
})
progress_data1.to_csv(os.path.join(exp1_dir, 'progress.txt'), sep='\t', index=False)

# Create config.json for exp1
config1 = {'exp_name': 'experiment_1'}
with open(os.path.join(exp1_dir, 'config.json'), 'w') as f:
    json.dump(config1, f)

# Create second experiment directory
exp2_dir = os.path.join(tmpdir, 'exp2')
os.makedirs(exp2_dir)

# Create progress.txt for exp2
progress_data2 = pd.DataFrame({
    'AverageEpRet': [15.0, 25.0, 35.0],
    'Penalty': [1.0, 1.0, 1.0],
    'AverageEpSurrCost': [2.0, 2.0, 2.0],
    'AverageTestEpRet': [17.0, 27.0, 37.0]
})
progress_data2.to_csv(os.path.join(exp2_dir, 'progress.txt'), sep='\t', index=False)

# Create config.json for exp2
config2 = {'exp_name': 'experiment_2'}
with open(os.path.join(exp2_dir, 'config.json'), 'w') as f:
    json.dump(config2, f)

# Create third experiment directory without config.json
exp3_dir = os.path.join(tmpdir, 'exp3')
os.makedirs(exp3_dir)

# Create progress.txt for exp3
progress_data3 = pd.DataFrame({
    'AverageEpRet': [5.0, 10.0, 15.0],
    'AverageTestEpRet': [6.0, 11.0, 16.0]
})
progress_data3.to_csv(os.path.join(exp3_dir, 'progress.txt'), sep='\t', index=False)

# Define ARGS for get_all_datasets
ARGS = {
    'all_logdirs': [exp1_dir, exp2_dir, exp3_dir],
    'legend': ['exp_1', 'exp_2', 'exp_3'],
    'select': None,
    'exclude': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_datasets Ran
ran on a synthesized input
nolanwagener/safe_rl/safe_rl/utils/plot.py
code served (permissive licence) · get_code("ed35dafc1e97db0c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import json
import os
import tempfile
import shutil

# Create a temporary directory structure with the required files
tmpdir = tempfile.mkdtemp()

# Create a subdirectory that will be found by os.walk
exp_dir = os.path.join(tmpdir, 'experiment_1')
os.makedirs(exp_dir)

# Create a config.json file
config = {'exp_name': 'test_experiment'}
config_path = os.path.join(exp_dir, 'config.json')
with open(config_path, 'w') as f:
    json.dump(config, f)

# Create a progress.txt file with required columns
progress_data = pd.DataFrame({
    'AverageEpRet': [100.0, 110.0, 120.0],
    'Penalty': [0.1, 0.1, 0.1],
    'AverageEpSurrCost': [5.0, 4.5, 4.0]
})
progress_path = os.path.join(exp_dir, 'progress.txt')
progress_data.to_csv(progress_path, sep='\t', index=False)

# Reset global state
import sys
module = sys.modules[__name__]
module.exp_idx = 0
module.units = dict()

ARGS = {
    'logdir': tmpdir,
    'condition': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 3, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
is_json_serializable Ran
ran, violated the contract we drafted
nolanwagener/safe_rl/safe_rl/utils/serialization_utils.py
code served (permissive licence) · get_code("9ca8b8e45f7fbebf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json

def is_json_serializable(v):
    try:
        json.dumps(v)
        return True
    except:
        return False

# Test with various values
ARGS = {
    "v": {"key": "value", "number": 42, "list": [1, 2, 3]}
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mlp Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/algos/cppo/core.py
pointer only (licence: MIT); the stored copy get_code serves, from idsia/policyevaluator, is pointer only (licence: NONE) · get_code("7569e2a512ec417c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from idsia/policyevaluator, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

valid_str Ran
ran; our contract draft was wrong, not the code
nolanwagener/safe_rl/safe_rl/utils/run_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from milanganai/milanganai.github.io, is pointer only (licence: NONE) · get_code("c6bdd181afa1fdf7")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from milanganai/milanganai.github.io, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 9 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 1 the same month, 9 later) and 1 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
colorize 17 other papers
3 dated earlier, 14 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
1909.12255 (2019-09)
Harnessing Structures for Value-Based Planning and Reinforcement Learning
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
and 14 more not named here
combined_shape 14 other papers
4 dated earlier, 10 later
1906.06818 (2019-06)
Stacked Capsule Autoencoders
1912.13465 (2019-12)
Reward-Conditioned Policies
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
and 11 more not named here
mlp 12 other papers
5 dated earlier, 7 later · 2 only as an assembly brick
1905.01240 (2019-05)
Information asymmetry in KL-regularized RL
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2006.09359 (2020-06)
AWAC: Accelerating Online Reinforcement Learning with Offline Datasets
and 9 more not named here
is_json_serializable 9 other papers
2 dated earlier, 7 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2205.14691 (2022-05)
On the Robustness of Safe Reinforcement Learning under Observational Perturbations
and 6 more not named here
count_vars 8 other papers
2 dated earlier, 6 later
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2010.09635 (2020-10)
Deep Reinforcement Learning with Population-Coded Spiking Neural Network for Continuous Control
2109.12286 (2021-09)
Stackelberg Actor-Critic: Game-Theoretic Reinforcement Learning Algorithms
and 5 more not named here
convert_json 7 other papers
2 dated earlier, 5 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2205.14691 (2022-05)
On the Robustness of Safe Reinforcement Learning under Observational Perturbations
and 4 more not named here
get_all_datasets 4 other papers
2 dated earlier, 2 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2310.13230 (2023-10)
Absolute Policy Optimization
and 1 more not named here
valid_str 4 other papers
2 dated earlier, 1 the same month, 1 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2106.04619 (2021-06)
Self-Supervised Learning with Data Augmentations Provably Isolates Content from Style
and 1 more not named here
all_bools 3 other papers
2 dated earlier, 1 later
1802.09477 (2018-02)
Addressing Function Approximation Error in Actor-Critic Methods
2006.07442 (2020-06)
Self-Imitation Learning via Generalized Lower Bound Q-learning
2605.11975 (2026-05)
Stochastic Minimum-Cost Reach-Avoid Reinforcement Learning

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Many sequential decision problems involve finding a policy that maximizes total reward while obeying safety constraints. Although much recent research has focused on the development of safe reinforcement learning (RL) algorithms that produce a safe policy after training, ensuring safety during training as well remains an open problem. A fundamental challenge is performing exploration while still satisfying constraints in an unknown Markov decision process (MDP). In this work, we address this problem for the chanceconstrained setting. We propose a new algorithm, SAILR, that uses an intervention mechanism based on advantage functions to keep the agent safe throughout training and optimizes the agent's policy using off-the-shelf RL algorithms designed for unconstrained MDPs. Our method comes with strong guarantees on safety during both training and deployment (i.e., after training and without the intervention mechanism) and policy performance compared to the optimal safetyconstrained policy. In our experiments, we show that SAILR violates constraints far less during training than standard safe RL and constrained MDP approaches and converges to a wellperforming policy that can be deployed safely without intervention. Our code is available at https://github.com/nolanwagener/safe_rl. * be its state-action value function, and V * be its state value function. } be a subset of admissible intervention rules with a threshold of zero and average as the advantage function of the optimal policy. For some intervention rule G ∈ G 0 and policy π, let π = G(π). Then, the inequality A(s, a) ≥ A * (s, a) holds for all a ∈ A almost surely over the distribution d π (s). Proof. First, we show by induction that running π starting from d 0 results in the agent staying in the subset S G = {s ∈ S : For t = 0, consider some s 0 ∼ d 0 . We observe from admissibility of G and Proposition 2 that Now suppose the agent is in S G with probability one at some time step t. Consider some s t ∼ d π t (observing that s t ∈ S G ). We assume that s t ∈ S safe (otherwise, the below is trivially true as there is no intervention outside S safe ). By Lemma 4 and admissibility, we can derive: where the second and fourth equalities are due to s t ∈ S safe , and the third equality is due to s t ∈ S G . Notice also, since s t ∈ S safe , we have Therefore, combining the two inequalities above, we have Since Q(s, a) ≥ V * (s) on S × A, by the same argument we made for s 0 , we conclude Q(s t+1 , µ) = V * (s t+1 ) with probability one. Therefore, the agent stays in the subset S G . With this property in mind, let s ∼ d π . Then the following holds for all a ∈ A: where the second equality is due to Q Proposition 4. Let π * be an optimal policy for M, Q * be its state-action value function, and V * be its state value function. π * , 0) ∈ G 0 . Consider arbitrary G ∈ G 0 and policy π. Let M and M * be the absorbing MDPs induced by G and G * , respectively, and let d π and d * ,π be their state-action distributions of π. Then, Supp S×A ( d π ) ⊆ Supp S×A ( d * ,π ), where Supp S×A (d) denotes the support of a distribution d when restricted on S × A.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2106.09110")
get_code_for_paper("2106.09110")
have("2106.09110")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2106.09110.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2106.09110.svg)](https://syntology.ai/paper/2106.09110)

Connect an agent — have() is free.