{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/safe-reinforcement-learning-using-advantage","title":"Safe Reinforcement Learning Using Advantage-Based Intervention","arxiv_id":"2106.09110","date":"2021-06-16","proceeding":null,"authors":["Nolan Wagener","Byron Boots","Ching-An Cheng"],"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 chance-constrained 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 safety-constrained 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 well-performing policy that can be deployed safely without intervention. Our code is available at https://github.com/nolanwagener/safe_rl.","url_abs":"https://arxiv.org/abs/2106.09110v2","url_pdf":"https://arxiv.org/pdf/2106.09110v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"safe-reinforcement-learning-using-advantage","repo_url":"https://github.com/nolanwagener/safe_rl","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"reinforcement-learning","task_name":"Reinforcement Learning"},{"task_slug":"reinforcement-learning-1","task_name":"Reinforcement Learning (RL)"},{"task_slug":"safe-reinforcement-learning","task_name":"Safe Reinforcement Learning"},{"task_slug":"reinforcement-learning-2","task_name":"reinforcement-learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2106.09110","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.09110"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/nolanwagener/safe_rl","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"ran_draft_wrong":3,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":10,"ran":8,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"2103e65a90ce7a04","entry":"all_bools","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/run_utils.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/run_utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2103e65a90ce7a04"}},{"code_sha256_prefix":"7e36f1c357c4618d","entry":"colorize","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/logx.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/logx.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7e36f1c357c4618d"}},{"code_sha256_prefix":"57542f87e248db45","entry":"combined_shape","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/algos/cppo/core.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/algos/cppo/core.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"57542f87e248db45"}},{"code_sha256_prefix":"fbc505a5dac82646","entry":"convert_json","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/serialization_utils.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/serialization_utils.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fbc505a5dac82646"}},{"code_sha256_prefix":"4cca5e460067b900","entry":"count_vars","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/algos/cppo/core.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/algos/cppo/core.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4cca5e460067b900"}},{"code_sha256_prefix":"9ca8b8e45f7fbebf","entry":"is_json_serializable","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/serialization_utils.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/serialization_utils.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9ca8b8e45f7fbebf"}},{"code_sha256_prefix":"7569e2a512ec417c","entry":"mlp","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/algos/cppo/core.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/algos/cppo/core.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7569e2a512ec417c"}},{"code_sha256_prefix":"c6bdd181afa1fdf7","entry":"valid_str","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/run_utils.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/run_utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c6bdd181afa1fdf7"}},{"code_sha256_prefix":"db18a597508be1d7","entry":"get_all_datasets","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/plot.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/plot.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"db18a597508be1d7"}},{"code_sha256_prefix":"ed35dafc1e97db0c","entry":"get_datasets","repo":"nolanwagener/safe_rl","repo_kind":"official","path":"safe_rl/utils/plot.py","file_url":"https://github.com/nolanwagener/safe_rl/blob/HEAD/safe_rl/utils/plot.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ed35dafc1e97db0c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}