paperbot · PL 论文追踪

全部论文 待读 收藏

P1 AgentSpec: Customizable Runtime Enforcement for Safe and Reliable LLM Agents

AgentSpec:面向安全可靠 LLM 智能体的可定制运行时约束执行
ICSE Proceedings of the 2026 IEEE/ACM 48th International Conference on Software Engineering2026匹配度 5/10 · 论文面向 Agentic/LLM 程序提出 DSL 进行运行时安全约束,并与 LLM 生成规则结合,与“Agentic 程序 + PL 技术”有交集;但其核心是运行时防护而非静态分析/形式化验证,与用户主线的“PL→AI 静态分析”或“AI→PL 改进静态分析”仅边缘相关。引用 0 inbox
Haoyu Wang, Christopher M. Poskitt, Jun Sun
crossref: 2026-09-12

AI 速览

一句话:提出轻量级 DSL AgentSpec,在运行时对 LLM 智能体施加可定制的安全约束,并支持用 LLM 自动生成规则。

基于 LLM 的智能体被广泛部署于复杂决策与任务执行,但其自主性带来安全漏洞、违法与有害行为等风险;现有基于模型的防护与早期干预方法在鲁棒性、可解释性和适应性方面不足。本文提出 AgentSpec,一种轻量级领域特定语言,用于在运行时指定并执行对 LLM 智能体的约束:用户以触发器、谓词和执法机制三类要素编写结构化规则,使智能体在预定安全边界内运行。作者在代码执行、具身智能体与自动驾驶等多个领域实现了 AgentSpec 并加以评估:其阻止了代码智能体超过 90% 的不安全执行,消除了具身任务中的全部危险动作,并使自动驾驶车辆实现 100% 合规,同时运行时开销仅为毫秒级。此外,作者还利用 LLM 自动生成规则并评估其效果:OpenAI o1 生成的规则在具身智能体上达到 95.56% 精确率与 70.96% 召回率,能识别 87.26% 的风险代码,并在 8 个场景中的 5 个里阻止自动驾驶车辆违法。

问题
LLM 智能体的自主性会引入安全漏洞、违法行为与意外有害动作,而现有基于模型的防护与早期干预手段在鲁棒性、可解释性和适应性上均有欠缺。
方法
提出轻量级领域特定语言 AgentSpec,用户以触发器、谓词与执法机制构造结构化规则,在运行时对智能体行为进行约束;并在代码执行、具身智能体与自动驾驶等域实现该语言,同时用 LLM 自动生成规则。
评估
在多个域中评估运行时约束的有效性与开销:代码智能体超过 90% 的不安全执行被阻止,具身任务中危险动作被全部消除,自动驾驶车辆实现 100% 合规,开销为毫秒级;并测量 LLM 生成规则的精确率、召回率与场景覆盖率。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot11746,
  title = {AgentSpec: Customizable Runtime Enforcement for Safe and Reliable LLM Agents},
  author = {Haoyu Wang and Christopher M. Poskitt and Jun Sun},
  booktitle = {ICSE},
  year = {2026},
  doi = {10.1145/3744916.3764546}
}