VeriGuard: Enhancing LLM Agent Safety via Verified Code Generation
Preprint
Abstract
The deployment of autonomous AI agents in sensitive domains, such as healthcare, introduces critical risks to safety, security, and privacy. These agents may deviate from user objectives, violate data handling policies, or be compromised by adversarial attacks. Mitigating these dangers necessitates a mechanism to formally guarantee that an agent's actions adhere to predefined safety constraints, a challenge that existing systems do not fully address. We introduce VeriGuard, a novel framework that provides formal safety guarantees for LLM-based agents through a dual-stage architecture designed for robust and verifiable correctness. The initial offline stage involves a comprehensive validation process. It begins by clarifying user intent to establish precise safety specifications. VeriGuard then synthesizes a behavioral policy and subjects it to both testing and formal verification to prove its compliance with these specifications. This iterative process refines the policy until it is deemed correct. Subsequently, the second stage provides online action monitoring, where VeriGuard operates as a runtime monitor to validate each proposed agent action against the pre-verified policy before execution. This separation of the exhaustive offline validation from the lightweight online monitoring allows formal guarantees to be practically applied, providing a robust safeguard that substantially improves the trustworthiness of LLM agents.Keywords
All Related Versions
This publication has 12 references indexed in Scilit:
- ReCode: Improving LLM-based Code Repair with Fine-Grained Retrieval-Augmented Generation2025
- Fifteen Years of Viper2025
- The rise and potential of large language model based agents: a surveyScience China Information Sciences, 2025
- AGrail: A Lifelong Agent Guardrail with Effective and Adaptive Safety Detection2025
- Automatically Correcting Large Language Models: Surveying the Landscape of Diverse Automated Correction StrategiesTransactions of the Association for Computational Linguistics, 2024
- A survey on large language model based autonomous agentsFrontiers of Computer Science, 2024
- Generative Agents: Interactive Simulacra of Human Behavior2023
- Reflexion: language agents with verbal reinforcement learning2023
- NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Rails2023
- Membership Inference Attacks against Language Models via Neighbourhood Comparison2023