Lean Guardrails presents Lean-verified guardrails for agents that use tools.

Products & Tools 0 views

LeanGuard uses Lean4 policies to block forbidden Qwen tool calls, reduce prompt injection, and repair some denied calls via proof-guided edits.

Key Takeaways

  • LeanGuard is a runtime guard that checks each proposed tool call against Lean4 policies before execution, preventing forbidden actions instead of relying on the model to self-correct.
  • In Tau-Bench tests with five Qwen models, unguarded agents made at least 33 forbidden tool calls, while LeanGuard allowed none.
  • LeanGuard policies use state predicates and past-time temporal operators over execution history, are evaluated fail-closed, and are formally proved equivalent to LeanLTL semantics.
  • Denied calls can be handled through feedback or proof-guided repair; repair proved an admissible edit for 88 of 252 argument-value denials, with a median time of 2 ms.
  • LeanGuard reduced direct prompt-injection success from 57.9% to 5.9% in DTap tests and preserved benign telecom success, while feedback improved repeated blocked calls and task success for four of five models.

Meta description: LeanGuard checks Qwen tool calls against Lean4 policies, blocks at least 33 forbidden actions, cuts prompt injection to 5.9%, and repairs 88 of 252 denials.

Tags: LeanGuard, Qwen, Lean4, tool calls, prompt injection

Featured image: Abstract technology style with policy gates around an agent workflow, no real people, no company logos, no text.

When a language-model agent uses tools, it can still take actions that the rules for its domain do not allow. LeanGuard is a runtime guard that inspects each proposed tool call before the environment receives it, using a policy expressed in Lean4. In Tau-Bench tests with five Qwen models, unguarded agents make at least 33 calls that the Lean policy forbids, while LeanGuard makes none. The result matters because agent systems need a way to block rule-breaking actions without relying only on the model to self-correct.

Background: the gap between a proposed call and an allowed action

The problem begins at the moment a model selects a tool call. The call may look useful for the task, but the domain rules can still disallow it. LeanGuard treats the interval between proposal and execution as a safety boundary. It checks the call first, then allows or denies it, instead of letting the environment act and then trying to undo harm.

Development: Lean4 rules are evaluated before execution

LeanGuard policies are written in Lean4. Each policy mixes state predicates with scoped past-time temporal operators over the execution history. State predicates describe what should be true at the current point in a run. Past-time operators let a rule look back at earlier events. Evaluation is fail-closed, so the guard does not treat an unclear or unsupported case as safe. The decision procedure is proved equivalent to a LeanLTL semantics, a formal meaning for those policy checks.

If a call is denied, two correction paths exist. In the feedback path, the violated rule and a hint are returned to the agent. In the proof-guided repair path, Lean metaprogramming looks for a nearby call that keeps the user's intent and proves the policy admits that call without asking the model.

Latest results: Tau-Bench, DTap, telecom, and repair

Tau-Bench tests use five Qwen models spanning 0.8B-27B. Without guards, these agents make at least 33 calls that the Lean policy forbids. With LeanGuard, no such forbidden calls are executed. When feedback is used, task success does not change significantly.

LeanGuard lowers direct prompt-injection success from 57.9% to 5.9% in DTap tests. In telecom, benign tasks require no writes, and benign success is unchanged. Compared with a bare denial, feedback lowers repeated blocked calls and improves task success for four of five models.

When denials are replayed, repair proves an admissible edit for 88 of 252 argument-value denials, with a median of 2ms.

Current stage: checked enforcement with partial repair

The reported numbers place LeanGuard at an enforcement stage. It stops forbidden tool calls in the tested settings, reduces direct prompt-injection success, and keeps benign telecom success unchanged. The repair results also show a boundary: feedback helps four of five models after denial, while proof-guided repair proves an admissible edit for 88 of 252 argument-value denials in a median of 2ms. The current evidence describes a system that checks and blocks first, then repairs selected failures second.

Tags: Qwenprompt injectionLeanGuardLean4AI agent guardrails

Comments

No comments yet. Be the first to comment.

Leave a comment