RoboSafe: Safeguarding Embodied Agents via Executable Safety Logic

Le Wang, Zonghao Ying, Xiao Yang, Quanchen Zou, Zhenfei Yin, Tianlin Li, Jian Yang, Yaodong Yang, Aishan Liu, Xianglong Liu

TL;DR

RoboSafe is a novel runtime safety guardrail for vision-language-model (VLM) driven robots that translates safety reasoning into executable Python code. By combining forward-predictive and backward-reflective reasoning over a hybrid memory system, it successfully mitigates implicit contextual and temporal risks, reducing hazardous actions by 36.8% while preserving the robot's ability to complete benign tasks.

What Problem Does This Paper Address?

While Vision-Language Models (VLMs) excel at high-level task planning for embodied agents (robots), they are highly vulnerable to malicious or unsafe instructions. Unlike standard LLMs whose harms are confined to text, an embodied agent can translate a dangerous prompt into irreversible physical damage.

Existing runtime guardrails typically rely on static rule filters or prompt-level constraints. However, these methods struggle with two types of implicit risks:

  1. Contextual Risks: Actions that are safe in one context but hazardous in another. For example, "turn on the microwave" is fine unless someone put a metal fork inside it.
  2. Temporal Risks: Hazards that emerge from a sequence of actions over time, such as turning on a stove and leaving it unattended for too long.

RoboSafe addresses these challenges by introducing a dynamic, verifiable, and executable safety logic framework that evaluates actions based on both immediate environmental context and historical execution traces.

Figure 1. Illustration of RoboSafe, where runtime safety guardrail generates executable safety logic to eliminate implicit temporal hazards and prevent contextual risks under dynamic scenarios.

Methods

RoboSafe operates as a black-box runtime guardrail that intercepts an agent's proposed action before execution. It leverages a Hybrid Long-Short Safety Memory and processes safety checks through two bidirectional reasoning modules:

  • Forward Predictive Reasoning (Contextual Safety): This module evaluates the immediate risk of the proposed action. It uses a multi-grained retrieval mechanism to pull relevant safety knowledge from a long-term memory ($M^L$) based on the current multimodal observation and the proposed action. It then generates low-level, verifiable logical predicates ($\Phi_t$). If a risk is detected, it triggers a BLOCK command.
  • Backward Reflective Reasoning (Temporal Safety): This module continuously monitors the short-term working memory ($M^S$), which stores recent execution trajectories. It infers temporal safety predicates from the global instruction (e.g., ensuring a prerequisite action occurred or an obligation is met). If a temporal violation is detected, it proactively triggers a REPLAN command to insert corrective actions (like turning off a stove) rather than shutting down entirely.

Crucially, these predicates are compiled into executable Python code, allowing a lightweight Python interpreter to act as a deterministic safety verifier at runtime.

Figure 2. Overall runtime guardrail framework. RoboSafe introduces both Forward Predictive Reasoning for preventing contextual risks and Backward Reflective Reasoning for mitigating temporal risks, ensuring defense effectiveness in dynamic, temporally dependent scenarios.

Datasets

The authors evaluated RoboSafe using SafeAgentBench, a comprehensive safety evaluation benchmark for embodied agents in household settings. The benchmark includes:

  • A detailed unsafe instruction dataset (for immediate situational risks).
  • A long-horizon unsafe instruction dataset (for temporal sequential hazards).
  • A safe instruction dataset (to test general task performance preservation on benign tasks).

Key Insights and Ideas

  • Code as a Safety Verifier: Instead of relying on a VLM to output a fuzzy "safe/unsafe" text label, RoboSafe forces the VLM to generate structured Python logic. This makes the safety guardrail verifiable, deterministic, and highly interpretable.
  • The Power of "Replan" over "Block": Traditional guardrails simply block an action when something goes wrong, which often breaks the agent's long-term execution. RoboSafe realizes that temporal risks (like forgetting to turn off a faucet) are better handled by forcing a temporary deviation to fix the hazard, then returning to the original plan.
  • Knowledge Decoupling: RoboSafe decouples safety knowledge into high-level reasoning demonstrations and low-level executable predicates. This allows the system to handle complex physical reasoning while maintaining simple, reliable execution logic at runtime.

Key Results

RoboSafe was tested across three representative agent architectures (ReAct, ProgPrompt, and Reflexion) using GPT-4o as the core planner.

  • Superior Risk Mitigation: RoboSafe achieved an average Accurate Refusal Rate (ARR) of 89.89% on contextual unsafe tasks, significantly outperforming baselines like ThinkSafe, Poex, and AgentSpec.
  • High Task Preservation: Unlike competing guardrails that are overly aggressive—for instance, ThinkSafe drops the agent's success rate on benign tasks to a dismal 24.11%—RoboSafe maintains a 89.00% Execution Success Rate (ESR) on safe instructions.
  • Jailbreak Resistance: Against advanced contextual jailbreak attacks, RoboSafe suppressed the hazardous execution success rate to just 5.22%.
  • Efficiency & Real-World Viability: The framework introduces negligible computational overhead (~0.15 seconds per step) and was successfully validated on a physical 6-DoF myCobot 280-Pi robotic arm.
Case studies showing RoboSafe blocking contextual hazards in simulation

Limitations and Future Work

The authors note a few areas for improvement:

  1. Platform Generalization: Future work will focus on extending RoboSafe to more diverse and complex robotic platforms beyond the manipulators tested.
  2. Scalability: Evaluating the framework on even longer-horizon tasks and improving its robustness against entirely unforeseen, highly creative adversarial jailbreak strategies remains an open challenge.

Summary updated

BibTeX
@inproceedings{wang2026robosafe,
  author = {Le Wang and Zonghao Ying and Xiao Yang and Quanchen Zou and Zhenfei Yin and Tianlin Li and Jian Yang and Yaodong Yang and Aishan Liu and Xianglong Liu},
  title = {{RoboSafe: Safeguarding Embodied Agents via Executable Safety Logic}},
  booktitle = {ES-Reasoning @ ICLR},
  year = {2026},
  url = {https://openreview.net/forum?id=wyKCkQ2GyO},
}
Figure