SafeGen-LLM: Enhancing Safety Generalization in Task Planning for Robotic Systems
Organizations: University of Notre Dame · Washington State University · University of Pennsylvania
Abstract
Safety-critical task planning in robotic systems remains challenging: classical planners suffer from poor scalability, Reinforcement Learning (RL)-based methods generalize poorly, and base Large Language Models (LLMs) cannot guarantee safety. To address this gap, we propose safety-generalizable large language models, named SafeGen-LLM. SafeGen-LLM can not only enhance the safety satisfaction of task plans but also generalize well to novel safety properties in various domains. We first construct a multi-domain Planning Domain Definition Language 3 (PDDL3) benchmark with explicit safety constraints. Then, we introduce a two-stage post-training framework: Supervised Fine-Tuning (SFT) on a constraint-compliant planning dataset to learn planning syntax and semantics, and Group Relative Policy Optimization (GRPO) guided by fine-grained reward machines derived from formal verification to enforce safety alignment and by curriculum learning to better handle complex tasks. Extensive experiments show that SafeGen-LLM achieves strong safety generalization and outperforms frontier proprietary baselines across multi-domain planning tasks and multiple input formats (e.g., PDDLs and natural language).
Figures & tables
| Domain | Description | Safety Constraints |
|---|---|---|
| Blocksworld | The agent must rearrange stacked blocks into a desired configuration using pick-and-place actions. | Blocks must be stacked in a safe and stable order, e.g., a supporting block must be positioned before the blocks it supports. |
| Ferry | The agent controls a ferry that transports cars between locations. | The ferry must never be overloaded, and cars must safely reach their destinations before the ferry departs or returns. |
| Grippers | A robot with two grippers must pick up and deliver all objects to a target room. | Robots (or manipulators) must avoid operating simultaneously in the same narrow room, and certain grippers may be restricted for safety-critical objects. |
| Spanner | A worker must collect spanners and tighten all nuts across connected locations. | Bolts must be tightened in a safe sequence (e.g., foundation nuts before upper ones), and access to shared tools (e.g., entering the tool shed) is limited to prevent unsafe congestion. |
| Domain | Success Plans | Plan Format Error | Precondition Violation | Safety Constraint Violation | Goal Not Satisfied | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PT | SFT | GRPO | PT | SFT | GRPO | PT | SFT | GRPO | PT | SFT | GRPO | PT | SFT | GRPO | |
| Qwen3-14B | |||||||||||||||
| Blocksworld | 2.0 | 70.0 | 88.0 | 90.0 | 0.0 | 0.0 | 6.0 | 24.0 | 12.0 | 0.0 | 2.0 | 0.0 | 2.0 | 4.0 | 0.0 |
| Ferry | 0.0 | 86.0 | 96.0 | 10.0 | 0.0 | 0.0 | 90.0 | 4.0 | 4.0 | 0.0 | 10.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Grippers | 2.0 | 92.0 | 98.0 | 0.0 | 0.0 | 0.0 | 46.0 | 4.0 | 0.0 | 46.0 | 4.0 | 2.0 | 6.0 | 0.0 | 0.0 |
| Spanner | 0.0 | 100.0 | 100.0 | 2.0 | 0.0 | 0.0 | 98.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Domain | Success | Format Error | Precondition Violation | Safety Constraint Violation | Goal Not Satisfied | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PDDL3 | NL | JSON | PDDL3 | NL | JSON | PDDL3 | NL | JSON | PDDL3 | NL | JSON | PDDL3 | NL | JSON | |
| Blocksworld | 88.0 | 74.0 | 80.0 | 0.0 | 0.0 | 0.0 | 12.0 | 18.0 | 8.0 | 0.0 | 8.0 | 8.0 | 0.0 | 0.0 | 4.0 |
| Ferry | 96.0 | 90.0 | 96.0 | 0.0 | 0.0 | 0.0 | 4.0 | 6.0 | 2.0 | 0.0 | 4.0 | 2.0 | 0.0 | 0.0 | 0.0 |
| Grippers | 98.0 | 82.0 | 98.0 | 0.0 | 0.0 | 0.0 | 0.0 | 14.0 | 2.0 | 2.0 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Spanner | 100.0 | 90.0 | 96.0 | 0.0 | 2.0 | 0.0 | 0.0 | 8.0 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Average | 95.5 | 84.0 | 92.5 | 0.0 | 0.5 | 0.0 | 4.0 | 11.5 | 4.0 | 0.5 | 4.0 | 2.5 | 0.0 | 0.0 | 1.0 |
| Model | Blocksworld | Ferry | Grippers | Spanner | Avg. |
|---|---|---|---|---|---|
| Success Rate (%) | |||||
| Pretrained | 50.0 | 0.0 | 50.0 | 0.0 | 25.0 |
| GRPO | 94.0 | 98.0 | 98.0 | 100.0 | 97.5 |
| Avg. Retries | |||||
| Pretrained | 3.50 | 5.00 | 3.00 | 5.00 | 4.13 |
| GRPO | 1.36 | 1.12 | 1.14 | 1.00 | 1.16 |
| Hyperparameter | SFT | GRPO |
|---|---|---|
| Learning rate | ||
| LR scheduler | Cosine | Cosine |
| Batch size | 4 | 8 |
| Gradient accumulation | 2 | 4 |
| Effective batch size | 8 | 32 |
| Training duration | 3 epochs | 1,000 steps |
| Category | Reward range |
|---|---|
| Success ( ) | (fixed) |
| Goal not satisfied ( ) | |
| Precondition violation ( ) | |
| Safety violation ( ) | |
| Format error ( ) | (fixed) |
| Phase | Progress | Easy | Medium | Hard |
|---|---|---|---|---|
| Early | 0–30% | 70% | 25% | 5% |
| Mid | 30–70% | 40% | 40% | 20% |
| Late | 70–100% | 20% | 40% | 40% |
| Domain | Train | Test | Problem size range |
|---|---|---|---|
| Blocksworld | 500 | 50 | 3–6 blocks |
| Ferry | 500 | 50 | 3–4 locations, 2–3 cars |
| Grippers | 500 | 50 | 1 robot, 3–4 rooms, 3 objects |
| Spanner | 500 | 50 | 2–3 spanners, 2 nuts, 3–4 locations |
| Total | 2,000 | 200 | — |
| Parameter | Local | API |
|---|---|---|
| Temperature | 0.6 | default |
| Top- | 0.9 | default |
| Max new tokens | 1,024 | default |
| Max sequence length | 5,000 | — |
| Quantization | 4-bit | — |
| Timeout per problem | — | 300s |