arXiv:2611.02332cs.AINov 2026

Manuscript Offprint

arXiv:2611.02332

LEANGUARD: Lean-Verified Guardrails for Tool-Using Agents

Sreehari Sankar, Debargha Ganguly, Vikash Singh, Mohsen Hariri, Weicong Chen, Yanyan Zhang, Shouren Wang, Wang Yang, Chaoda Song, Alexander Nemecek, Osama Zafar, Idan Davidovich, Yuting Shao, Kai Ye, Biyao Zhang, Xinpeng Li, Joe Stubbs, Erman Ayday, Jing Ma, Vipin Chaudhary

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

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 Lean 4 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 τ2\tau^2-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.

1 Introduction

Language-model agents increasingly turn natural-language requests into sequences of tool calls, and compact models now make this feasible on device, within tight latency, privacy, and compute budgets (Liu et al., 2024). Such agents must obey domain policies, satisfy state-dependent preconditions, and preserve user intent across multi-step interactions, and current evaluations show that they often fail. Agents follow domain policies inconsistently (Yao et al., 2025; Barres et al., 2026), strug-

gle with state dependencies and missing information (Lu et al., 2025), and execute unsafe actions when untrusted tool outputs steer their reasoning (Debenedetti et al., 2024). These failures matter most when a tool call changes external state (sending a message, changing a reservation, initiating a payment), because a call that succeeds can still be a transition the policy forbids.

We study whether formal verification can both enforce policy-compliant behavior and help agents achieve it. We write agent policies in Lean 4 (Moura and Ullrich, 2021) and place a verifier be-

Figure

Figure 1: A retail exchange with and without LEANGUARD. Unguarded, the agent follows an instruction injected into a tool output and bills the price difference to an attacker's gift card without asking the customer. With LEANGUARD, the call is denied because the customer has not confirmed and the card is not on the account; the agent asks the customer, and the reissued call is admitted. Bottom: headline results.

*Equal Contribution tween the language model and its tools, so that an action executes only if its policy obligations are met (Figure 1). Prior work enforces symbolic or formally specified policies at runtime (Shi et al., 2026; Wang et al., 2026a; Palumbo et al., 2026) and has begun to use Lean to verify agents (Rashie and Rashi, 2026; Wang et al., 2026b). We add a decision procedure proved correct against an independent temporal semantics, and two ways to correct a denied call: the model can fix the call from LEANGUARD's feedback, or Lean can compute a fix and prove it admissible without the model. Our contributions are:

  • LEANGUARD, a Lean 4 runtime whose admission procedure is proved equivalent to a temporal-logic semantics (§2). On τ2\tau^2-bench, unguarded agents execute at least 33 calls that the Lean policy forbids, and LEANGUARD executes none; with feedback, task success does not change significantly. On DTap, it reduces direct prompt-injection success from 57.9% to 5.9%.

  • Proof-guided repair (§2.6). Lean metaprogramming searches for a nearby call that preserves the user's intent and returns it with a kernel-checked proof of admissibility, without involving the model. To our knowledge, no existing agent guardrail produces proved repairs. On replayed τ2\tau^2-bench denials, it repairs 88 of the 252 denials caused by argument values, in a median of 2 ms.

  • Feedback-guided recovery (§2.5). Returning feedback, the violated rule and a hint, instead of a bare denial, reduces repeated blocked calls, increases recovered actions from 34 to 48, and raises task success for four of five models.

  • A taxonomy and measurement of policy-violating tool calls by compact agents, in five categories that each map to a part of LEANGUARD.

References (34)