SpecGuard: Proving a Task Is Broken Before the Agent Cheats

Param Biyani, Krishnamurthy Dvijotham
10/6/2026
cs.AIcs.LOcs.SE

Official code: prmbiy/specguard (1 star, Python, Apache-2.0, last commit 2026-10-09).

Abstract

As autonomous coding agents get increasingly deployed, the risk that accidental or adversarially injected misspecifications in tasks lead to dangerous agent behavior is critical to address. Prior work has shown that agents given such tasks rarely flag the conflict and instead cheat, editing tests or hard-coding expected outputs, and the actions taken to cheat can cause real damage, such as deleting a security defense to make a corrupted test pass.

Show full abstract

It remains unclear whether such conflicts can be established with independently verifiable evidence before the agent acts. We present SpecGuard, which detects and formally certifies these conflicts between task intent and tests. Given only the task description and codebase, SpecGuard autoformalizes the intended behaviour into a Lean 4 specification. The tests are formalized independently, and the Lean kernel checks whether any implementation could satisfy both formalizations, producing a machine-checked certificate when none can. On conflicted SWE-bench tasks, SpecGuard detects up to 72.8% of conflicts and formally certifies up to 51.1%, with a nearly five-fold lower conflict miss rate than model-based judgment. SpecGuard provides a pre-execution safety check that identifies reward-hacking opportunities through formal certification of task-level conflicts, before any agent behavior is observed. Our code is available at https://github.com/prmbiy/specguard.

View on arXivView PDF

Code Implementations(1)

prmbiy/specguardOfficial100%
Apache-2.0
10Python, DockerfileOct 6, 20261 months agoApache-2.0

Similar Papers

Cite this paper

@article{biyani2026specguard,
  title  = {SpecGuard: Proving a Task Is Broken Before the Agent Cheats},
  author = {Param Biyani and Krishnamurthy Dvijotham},
  year   = {2026},
  eprint = {2610.09159},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.09159v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.09159.svg)](https://codeofpaper.com/paper/2610.09159)

Discussion