LEANGUARD:面向工具使用代理的精益验证护栏

·

研究论文 · 2026/11/03

LeanGuard 是一个运行时系统,在工具调用到达环境之前,用 Lean4 编写的策略检查每个提议的调用。策略结合状态谓词与执行历史的作用域过去时态算子,评估采用故障关闭,且决策过程被证明等价于 LeanLTL 语义。被拒绝的调用可通过反馈或证明引导的修复来纠正。在 Tau-Bench 上,未受保护的代理执行了至少 33 个 Lean 策略禁止的调用,而 LeanGuard 执行了零个;在 DTap 上,LeanGuard 将直接提示注入成功率从 57.9% 降至 5.9%。反馈减少了重复被阻止的调用,并在五个模型中的四个上提高了任务成功率。在重放的拒绝中,修复为 252 个由参数值引起的拒绝中的 88 个证明了可接受的编辑,中位时间为 2 毫秒。

LeanGuard 提供了一种基于形式化验证的运行时防护方法,能有效阻止工具使用代理执行违反策略的调用,同时通过反馈和证明引导的修复保持任务成功率,在安全性和实用性上取得了显著平衡,对于构建安全可靠的 AI 代理系统具有重要参考价值。

Tool-using language-model agents often execute actions that their domain policies forbid. We present LeanGuard, a runtime that checks every proposed tool call against a policy written in Lean4 before the call reaches the environment. Policies combine state predicates with scoped past-time temporal operators over the execution history, evaluation is fail-closed, and the decision procedure is proved equivalent to a LeanLTL semantics. A denied call can be corrected in two ways. With feedback, the agent receives the violated rule and a hint; with proof-guided repair, Lean metaprogramming searches for a nearby call that preserves the user's intent and proves that the policy admits it, without the model. On Tau-Bench with five Qwen models (0.8B-27B), unguarded agents execute at least 33 calls that the Lean policy forbids, while LeanGuard executes none; with feedback, task success does not change significantly. On DTap, LeanGuard reduces direct prompt-injection success from 57.9% to 5.9%, and in telecom, where benign tasks need no writes, benign success is unchanged. Feedback reduces repeated blocked calls and raises task success for four of five models over a bare denial. On replayed denials, repair proves an admissible edit for 88 of 252 denials caused by argument values, in a median of 2,ms.

阅读原文

参与讨论