SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.14691 · ICLR · 2023

On the Robustness of Safe Reinforcement Learning under Observational Perturbations

Huan Zhang, Bo Li, Ding Zhao, Zuxin Liu, Zhepeng Cen, Zijian Guo, Jie Tan

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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; 0 honoured the contract we drafted, 1 violated it and 5 have no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2205.14691.json · badge: /api/ran/2205.14691.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
liuzuxin/safe-rl-robustness canonical (classifier label)
classifier basis not recorded on the link
8 ran · 3 no recorded run
FunctionStatusWhere it lives
convert_json Ran
ran; our contract draft was wrong, not the code
liuzuxin/safe-rl-robustness/rsrl/util/logger.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
find_config_dir Ran
ran on a synthesized input
liuzuxin/safe-rl-robustness/rsrl/util/run_util.py
code served (permissive licence) · get_code("6808510af734369e")
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 tuple, ndim 1, 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 os
import tempfile
import shutil

# Create a temporary directory structure with a config.yaml file
temp_dir = tempfile.mkdtemp()
nested_dir = os.path.join(temp_dir, "subdir1", "subdir2")
os.makedirs(nested_dir, exist_ok=True)

# Create a config.yaml file in the nested directory
config_path = os.path.join(nested_dir, "config.yaml")
with open(config_path, "w") as f:
    f.write("test_config: true\n")

# Set up the arguments
ARGS = {
    "dir": nested_dir,
    "depth": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 tuple, ndim 1, dtype family float — a tuple 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
find_model_path Ran
ran on a synthesized input
liuzuxin/safe-rl-robustness/rsrl/util/run_util.py
code served (permissive licence) · get_code("b686072a5a9a0280")
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 str. 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 shutil

# Create a temporary directory and a dummy model file
temp_dir = tempfile.mkdtemp()
model_path = os.path.join(temp_dir, 'model_5.pt')
with open(model_path, 'w') as f:
    f.write('')

ARGS = {
    'dir': temp_dir,
    'itr': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
gen_data_dir_name Ran
ran on a synthesized input
liuzuxin/safe-rl-robustness/script/evaluation.py
code served (permissive licence) · get_code("590dd799c8d0eefd")
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 1, 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 os
import tempfile
import json

# Create a temporary directory structure to simulate the load_dir
temp_dir = tempfile.mkdtemp()

# Create subdirectories that match the expected structure
env = "training"
valid_dir = os.path.join(temp_dir, f"experiment_{env}")
os.makedirs(valid_dir, exist_ok=True)

# Add a config.json to the valid directory
config_path = os.path.join(valid_dir, "config.json")
with open(config_path, 'w') as f:
    json.dump({"model": "test"}, f)

# Create an eval directory that should be skipped
eval_dir = os.path.join(temp_dir, "eval_results")
os.makedirs(eval_dir, exist_ok=True)
eval_config_path = os.path.join(eval_dir, "config.json")
with open(eval_config_path, 'w') as f:
    json.dump({"model": "test"}, f)

# Create a directory with wrong env that should be skipped
wrong_env_dir = os.path.join(temp_dir, "experiment_other")
os.makedirs(wrong_env_dir, exist_ok=True)
wrong_config_path = os.path.join(wrong_env_dir, "config.json")
with open(wrong_config_path, 'w') as f:
    json.dump({"model": "test"}, f)

ARGS = {
    "load_dir": temp_dir,
    "env": env
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 list, ndim 1, 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
get_cfg_value Ran
ran; our contract draft was wrong, not the code
liuzuxin/safe-rl-robustness/script/experiment.py
code served (permissive licence) · get_code("604ea5fcc35f7233")
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 str. 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 torch.nn as nn

# Construct valid arguments for get_cfg_value

# Test case 1: key exists at top level with string value
config_1 = {
    'model_name': 'resnet50',
    'batch_size': 32,
    'nested': {
        'learning_rate': 0.001
    }
}

# Test case 2: key exists with list value
config_2 = {
    'layers': [1, 2, 3, 4],
    'hidden_dims': [64, 128, 256],
    'model': {
        'activation': 'relu'
    }
}

# Test case 3: key in nested dict
config_3 = {
    'training': {
        'optimizer': 'adam',
        'hyperparams': {
            'weight_decay': 0.0001
        }
    },
    'data': {
        'split': 0.8
    }
}

# Test case 4: key not found
config_4 = {
    'param1': 'value1',
    'nested_1': {
        'param2': 'value2'
    }
}

ARGS = [
    # Scenario 1: key exists at top level with string value
    {'config': config_1, 'key': 'model_name'},
    
    # Scenario 2: key exists at top level with numeric value
    {'config': config_1, 'key': 'batch_size'},
    
    # Scenario 3: key exists with list value
    {'config': config_2, 'key': 'layers'},
    
    # Scenario 4: key in nested dict
    {'config': config_3, 'key': 'weight_decay'},
    
    # Scenario 5: key not found
    {'config': config_4, 'key': 'nonexistent'},
]

# Use the first valid case
ARGS = {'config': config_1, 'key': 'model_name'}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
is_json_serializable Ran
ran, violated the contract we drafted
liuzuxin/safe-rl-robustness/rsrl/util/logger.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
load_config Ran
ran on a synthesized input
liuzuxin/safe-rl-robustness/rsrl/util/run_util.py
code served (permissive licence) · get_code("ebd05ff21818703a")
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 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 yaml
import tempfile
import os

# Create a temporary YAML config file
temp_dir = tempfile.mkdtemp()
config_file = os.path.join(temp_dir, 'default_config.yaml')

config_content = """
model:
  name: test_model
  layers: 3
  hidden_dim: 128
training:
  epochs: 10
  batch_size: 32
  learning_rate: 0.001
data:
  train_split: 0.8
  val_split: 0.1
"""

with open(config_file, 'w') as f:
    f.write(config_content)

ARGS = {
    'config_path': config_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
yaml — 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
setup_logger_kwargs Ran
ran on a synthesized input
liuzuxin/safe-rl-robustness/rsrl/util/logger.py
code served (permissive licence) · get_code("502ce9931f9fac4d")
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 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 os.path as osp
import time

# Set up the ARGS dictionary with valid arguments for setup_logger_kwargs
ARGS = {
    'exp_name': 'test_experiment',
    'seed': 42,
    'data_dir': 'results',
    'datestamp': False,
    'use_tensor_board': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 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
gen_data_dir_name Not yet run
unverified (harvested, no recorded run)
liuzuxin/safe-rl-robustness/script/experiment.py
code served (permissive licence) · get_code("1b8912b121bcb5b3")
How it ran

no invocation recorded.

gen_exp_name Not yet run
unverified (harvested, no recorded run)
liuzuxin/safe-rl-robustness/script/experiment.py
code served (permissive licence) · get_code("bbaec49a08f13e20")
How it ran

no invocation recorded.

mlp Not yet run
unverified (harvested, no recorded run)
liuzuxin/safe-rl-robustness/rsrl/policy/model/mlp_ac.py
code served (permissive licence) · get_code("2bc10041d414773a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 4 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 4 later) and 7 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
is_json_serializable 9 other papers
3 dated earlier, 6 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.09110 (2021-06)
Safe Reinforcement Learning Using Advantage-Based Intervention
and 6 more not named here
convert_json 7 other papers
3 dated earlier, 4 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.09110 (2021-06)
Safe Reinforcement Learning Using Advantage-Based Intervention
and 4 more not named here
get_cfg_value 1 other paper
1 later
2602.08584 (2026-02)
Conditional Sequence Modeling for Safe Reinforcement Learning
mlp 1 other paper
1 later
2301.10923 (2023-01)
Trust Region-Based Safe Distributional Reinforcement Learning for Multiple Constraints

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-23.

Repositories linked to this paper

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

Abstract

Safe reinforcement learning (RL) trains a policy to maximize the task reward while satisfying safety constraints. While prior works focus on the performance optimality, we find that the optimal solutions of many safe RL problems are not robust and safe against carefully designed observational perturbations. We formally analyze the unique properties of designing effective observational adversarial attackers in the safe RL setting. We show that baseline adversarial attack techniques for standard RL tasks are not always effective for safe RL and propose two new approaches -one maximizes the cost and the other maximizes the reward. One interesting and counter-intuitive finding is that the maximum reward attack is strong, as it can both induce unsafe behaviors and make the attack stealthy by maintaining the reward. We further propose a robust training framework for safe RL and evaluate it via comprehensive experiments.

For agents

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

get_harvested_code_for_paper("2205.14691")
get_code_for_paper("2205.14691")
have("2205.14691")

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

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

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

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

Connect an agent — have() is free.