mlsanityData to 7 Oct 2026

AgentSpec: Customizable Runtime Enforcement for Safe and Reliable LLM Agents

arXiv 2503.18666 ↗First posted 24 Mar 2025cs.AI cs.CLcited by 196

On the map: LLM agents and tool use → Agent threats, guardrails and governance

Abstract (arXiv)

Agents built on LLMs are increasingly deployed across diverse domains, automating complex decision-making and task execution. However, their autonomy introduces safety risks, including security vulnerabilities, legal violations, and unintended harmful actions. Existing mitigation methods, such as model-based safeguards and early enforcement strategies, fall short in robustness, interpretability, and adaptability. To address these challenges, we propose AgentSpec, a lightweight domain-specific language for specifying and enforcing runtime constraints on LLM agents. With AgentSpec, users define structured rules that incorporate triggers, predicates, and enforcement mechanisms, ensuring agents operate within predefined safety boundaries. We implement AgentSpec across multiple domains, including code execution, embodied agents, and autonomous driving, demonstrating its adaptability and effectiveness. Our evaluation shows that AgentSpec successfully prevents unsafe executions in over 90% of code agent cases, eliminates all hazardous actions in embodied agent tasks, and enforces 100% compliance by autonomous vehicles (AVs). Despite its strong safety guarantees, AgentSpec remains computationally lightweight, with overheads in milliseconds. By combining interpretability, modularity, and efficiency, AgentSpec provides a practical and scalable solution for enforcing LLM agent safety across diverse applications. We also automate the generation of rules using LLMs and assess their effectiveness. Our evaluation shows that the rules generated by OpenAI o1 achieve a precision of 95.56% and recall of 70.96% for embodied agents, successfully identify 87.26% of the risky code, and prevent AVs from breaking laws in 5 out of 8 scenarios.

Key facts. Cited by 196 papers in the map (data through 7 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 35 of its 61 references that are in the map. First posted on arXiv 24 Mar 2025.

Builds on

35 of 61 references.

Closest ancestors · 6

Same direction, newest first

  1. 2024SafeAgentBench: A Benchmark for Safe Task Planning of Embodied LLM Agents17 Dec
  2. 2024EIA: Environmental Injection Attack on Generalist Web Agents for Privacy Leakage17 Sep
  3. 2024Breaking Agents: Compromising Autonomous LLM Agents Through Malfunction Amplification30 Jul
  4. 2024AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases17 Jul
  5. 2024Watch Out for Your Agents! Investigating Backdoor Threats to LLM-Based Agents17 Feb
  6. 2023Identifying the Risks of LM Agents with an LM-Emulated Sandbox25 Sep

Other references · 29

  1. 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
  2. 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
  3. 2023Generative Agents: Interactive Simulacra of Human Behaviorcited by 3,500
  4. 2023A Survey on Large Language Model based Autonomous Agentscited by 2,203
  5. 2023Voyager: An Open-Ended Embodied Agent with Large Language Modelscited by 2,081
  6. 2023CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Societycited by 1,348
  7. 2024Large Language Model based Multi-Agents: A Survey of Progress and Challengescited by 752
  8. 2022A Survey on In-context Learningcited by 717
  9. 2024GPT-4V(ision) is a Generalist Web Agent, if Groundedcited by 547
  10. 2024Executable Code Actions Elicit Better LLM Agentscited by 537
  11. 2023A Language Agent for Autonomous Drivingcited by 161
  12. 2024AI Agents Under Threat: A Survey of Key Security Challenges and Future Pathwayscited by 122
17 more
  1. 2024LLM Multi-Agent Systems: Challenges and Open Problemscited by 119
  2. 2024Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editingcited by 77
  3. 2024EHRAgent: Code Empowers Large Language Models for Few-shot Complex Tabular Reasoning on Electronic Health Recordscited by 75
  4. 2024Safeguarding Large Language Models: A Surveycited by 73
  5. 2024Understanding the Weakness of Large Language Model Agents within a Complex Android Environmentcited by 60
  6. 2023From Prompt Injections to SQL Injection Attacks: How Protected is Your LLM-Integrated Web Application?cited by 53
  7. 2024ALI-Agent: Assessing LLMs' Alignment with Human Values via Agent-based Evaluationcited by 46
  8. 2024LLMArena: Assessing Capabilities of Large Language Models in Dynamic Multi-Agent Environmentscited by 35
  9. 2024CROW: Eliminating Backdoors from Large Language Models via Internal Consistency Regularizationcited by 29
  10. 2022LawBreaker: An Approach for Specifying Traffic Laws and Fuzzing Autonomous Vehiclescited by 15
  11. 2024LLMScan: Causal Scan for LLM Misbehavior Detectioncited by 13
  12. 2024Efficient Detection of Toxic Prompts in Large Language Modelscited by 11
  13. 2018A Survey of Challenges for Runtime Verification from Advanced Application Domains (Beyond Software)cited by 9
  14. 2025FixDrive: Automatically Repairing Autonomous Vehicle Driving Behaviour for 0.08 per Violationcited by 3
  15. 2024μDrive: User-Controlled Autonomous Drivingcited by 2
  16. 2018Detecting Standard Violation Errors in Smart Contractscited by 1
  17. 2023Runtime Verification for Trustworthy Computingcited by 1

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 20; 2026: 176.

196 papers.

Sort:

By area:

  1. 2025A Survey of LLM-Driven AI Agent Communication: Protocols, Security Risks, and Defense Countermeasurescited by 54
  2. 2026Natural-Language Agent Harnessescited by 54
  3. 2026Towards Verifiably Safe Tool Use for LLM Agentscited by 34
  4. 2025MCIP: Protecting MCP Safety via Model Contextual Integrity Protocolcited by 33
  5. 2025AGENTSAFE: Benchmarking the Safety of Embodied Agents on Hazardous Instructionscited by 33
  6. 2025Enforcing Temporal Constraints for LLM Agentscited by 31
  7. 2026Formal Policy Enforcement for Real-World Agentic Systemscited by 31
  8. 2026ATBench: A Diverse and Realistic Agent Trajectory Benchmark for Safety Evaluation and Diagnosiscited by 30
  9. 2026From Agent Traces to Trust: A Survey of Evidence Tracing and Execution Provenance in LLM Agentscited by 29
  10. 2025Security Concerns for Large Language Models: A Surveycited by 26
  11. 2025Building a Foundational Guardrail for General Agentic Systems via Synthetic Datacited by 26
  12. 2025Agentic AI Security: Threats, Defenses, Evaluation, and Open Challengescited by 26
38 more
  1. 2025ProbGuard: Proactive Runtime Monitoring for LLM Agent Safety via Probabilistic Predictioncited by 25
  2. 2026ClawGuard: A Runtime Security Framework for Tool-Augmented LLM Agents Against Indirect Prompt Injectioncited by 25
  3. 2026A Survey on Long-Term Memory Security in LLM Agents: Attacks, Defenses, and Governance Across the Memory Lifecyclecited by 21
  4. 2025A Survey on Agentic Security: Applications, Threats and Defensescited by 17
  5. 2026Runtime Governance for AI Agents: Policies on Pathscited by 17
  6. 2026A Framework for Formalizing LLM Agent Securitycited by 16
  7. 2026Auditable Agentscited by 14
  8. 2026SafeHarness: Lifecycle-Integrated Security Architecture for LLM-based Agent Deploymentcited by 14
  9. 2026When Safe Skills Collide: Measuring Compositional Risk in Agent Skill Ecosystemscited by 14
  10. 2026ARGUS: Defending LLM Agents Against Context-Aware Prompt Injectioncited by 13
  11. 2025RoboSafe: Safeguarding Embodied Agents via Executable Safety Logiccited by 11
  12. 2026Wink: Recovering from Misbehaviors in Coding Agentscited by 11
  13. 2026The Evolution of Tool Use in LLM Agents: From Single-Tool Call to Multi-Tool Orchestrationcited by 11
  14. 2025Secure and Efficient Access Control for Computer-Use Agents via Context Spacecited by 10
  15. 2025AGENTSAFE: A Unified Framework for Ethical Assurance and Governance in Agentic AIcited by 9
  16. 2026AgenTRIM: Tool Risk Mitigation for Agentic AIcited by 9
  17. 2026ACRFence: Preventing Semantic Rollback Attacks in Agent Checkpoint-Restorecited by 9
  18. 2026Auditing Automated Evaluation, Error Propagation, and Runtime Mitigation in Tool-Using Language Agentscited by 9
  19. 2026AIRGuard: Guarding Agent Actions with Runtime Authority Controlcited by 9
  20. 2025Maris: A Formally Verifiable Privacy Policy Enforcement Paradigm for Multi-Agent Collaboration Systemscited by 8
  21. 2026Defense Against Indirect Prompt Injection via Tool Result Parsingcited by 8
  22. 2026AIR: Improving Agent Safety through Incident Responsecited by 8
  23. 2026Reframing LLM Agent Security as an Agent-Human Interaction Problemcited by 8
  24. 2026Agent libOS: A Runtime Substrate for Capability-Controlled Self-Evolving LLM Agentscited by 8
  25. 2026SEAGym: An Evaluation Environment for Self-Evolving LLM Agentscited by 8
  26. 2026VIGIL: Runtime Enforcement of Behavioral Specifications in AI Agent Skillscited by 8
  27. 2026Reason Less, Verify More: Deterministic Gates Recover a Silent Policy-Violation Failure Mode in Tool-Using LLM Agentscited by 8
  28. 2025When Developer Aid Becomes Security Debt: A Systematic Analysis of Insecure Behaviors in LLM Coding Agentscited by 7
  29. 2025Agentic Services Computingcited by 6
  30. 2025PARSE: LLM Driven Schema Optimization for Reliable Entity Extractioncited by 6
  31. 2026Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammarscited by 6
  32. 2026Cloak and Detonate: Scanner Evasion and Dynamic Detection of Agent Skill Malwarecited by 6
  33. 2026AgentRewind: Recoverable Execution for Long-Horizon LLM Agentscited by 6
  34. 2026StepShield: When, Not Whether to Intervene on Rogue Agentscited by 5
  35. 2026SMCP: Secure Model Context Protocolcited by 5
  36. 2026SafeClaw-R: Towards Safe and Secure Multi-Agent Personal Assistantscited by 5
  37. 2026Sovereign Agentic Loops: Decoupling AI Reasoning from Execution in Real-World Systemscited by 5
  38. 2026Semia: Auditing Agent Skills via Constraint-Guided Representation Synthesiscited by 5

50 most cited of 196 All 196 (JSON)

Similar, not cited

Close in wording, no citation either way

  1. 2026Toward Safe LLM Agents: A Survey of Specification, Verification, and Enforcement
  2. 2026SafeAgent: A Runtime Protection Architecture for Agentic Systems
  3. 2025VeriGuard: Enhancing LLM Agent Safety via Verified Code Generation
  4. 2026AgentWall: A Runtime Safety Layer for Local AI Agents
  5. 2026Agentao: A Policy-Governed Runtime Harness for Embeddable Tool-Using LLM Agents
  6. 2026Agent Safety Should Be a Runtime Contract
  7. 2026AgentFlow: A Flow-Centric Policy Language and Framework for Securing LLM Agent Systems
  8. 2026From Natural Language Policies to Executable Obligations: A Verification Harness for Dependable In-Car LLM Agents