Organizations: The Chinese University of Hong Kong, Shenzhen · Aalto University · Lero, the Research Ireland Centre for Software · University of Limerick · University of Ottawa
As coding agents become more capable, tests remain the primary evidence for judging whether their code is correct. Yet passing available tests does not establish that an implementation satisfies its natural language specification. Reliable validation requires checks that faithfully capture the specification and scenarios that thoroughly exercise the code, but current benchmarks provide limited insight into whether agents can construct such evidence themselves. We introduce SpecGuardBench, a benchmark of 291 tasks from 13 real-world repositories, covering 8 types of verification logic such as functional postconditions and interaction protocols. Given a natural language specification, repository context, and a reference implementation, an agent constructs a validation harness comprising executable checks and test scenarios. The checks should reject implementations that violate the specification while accepting those that satisfy it, and the scenarios should thoroughly exercise the code. Across four proprietary and open-weight coding agents, none constructs a harness scored as faithful on the benchmark's implementations for more than 63% of the tasks. The bottleneck lies less in exploring test scenarios than in constructing checks that faithfully reflect the specification. Specifically, the agents show a clear tendency to write checks that mirror the reference implementation rather than the specification, and therefore reject implementations that the specification permits.
Figures & tables
Figure 1: Overview of SpecGuardBench task. Given a natural language specification, the repository, and a reference implementation, an agent constructs a validation harness of test scenarios and executable checks; the harness is judged on whether it accepts implementations that satisfy the specification, rejects those that violate it, and how thoroughly the scenarios exercise the relevant code.
Figure 2: Construction of a SpecGuardBench task. An LLM decomposes the FeatureBench specification into atomic specifications (a) and, for each, writes a candidate violating implementation with a differential witness (b). The candidate must pass the instance’s original test suite and diverge from the gold implementation on its witness (c), and the witnesses of neighboring specifications are run against it (d). A candidate is kept only when a second LLM confirms from these divergences that it violates the targeted specification alone.
Figure 3
Agent
Detection ↑
False Alarm ↓
Faithfulness ↑
Edge Cov. ↑
Cost
Codex / GPT-5.6-sol
81.8%
23.0%
61.9%
82.0%
$0.74
Claude Code / Claude Opus 5
65.3%
20.6%
50.2%
72.4%
$1.79
OpenCode / DeepSeek-V4-Pro
66.7%
26.8%
45.0%
75.1%
$0.43
OpenCode / GLM-5.3
74.2%
15.1%
62.9%
84.3%
$1.48
Table 1: Performance of four baseline coding agents on the 291 validation tasks of SpecGuardBench . Cost denotes the average cost per task in U.S. dollars.
Figure 5: False alarms make up 42–60% of each agent’s failures (a), and for three of the four agents, most missed violations persist even on scenarios proven to expose the violation (b). A failure is attributed to scenarios only when replacing them with witness scenarios makes the checks reject the violating implementation and accept the gold one; the remaining missed violations are attributed to the checks.
Gold reference → violating reference (%)
Agent
Detection ↑
False Alarm ↓
Gold Rejection ↓
Faithfulness ↑
Codex / GPT-5.6-sol
83 → 78
21 → 37
0 4 → 29
65 → 46
Claude Code / Claude Opus 5
66 → 33
19 → 38
0 4 → 31
52 → 21
OpenCode / DeepSeek-V4-Pro
70 → 67
23 → 48
15 → 41
52 → 28
OpenCode / GLM-5.3
75 → 44
12 → 24
0 0 → 12
68 → 39
Table 2: On the Lite Set, every agent shown the violating implementation as the reference loses 19 to 31 points of faithfulness and rejects the unseen gold implementation on 12–41% of the tasks. The gold-reference values are the main experiment restricted to these 100 tasks. Gold Rejection is the part of False Alarm on the gold implementation.
Figure 6: Submission rate, detection rate, false alarm rate, and faithfulness rate on the Lite Set under the gold reference, at step budgets of 30, 50, and 80 steps.
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
Type
A check must establish that
Counterpart
n (%)
Functional postcondition
the return value satisfies a predicate over the inputs
postconditions ( ensures in JML, ACSL, and Dafny)
143
(49.1%)
Input validation
for inputs meeting a stated condition, the call raises a specified exception, returns a specified error value, emits a specified message or warning, or emits none of these
the function calls specified collaborators with specified arguments and multiplicity, or reads a value from a specified source
I/O specifications in separation logic, flow contracts (SPARK Depends )
32
(11.0%)
Call order
events within one execution occur in a specified order
temporal logic (LTL), typestate
2
(0.7%)
Appendix
Table 3: The eight types of verification logic, with the counterpart of each type in established verification logics and the number and percentage of the 291 specifications of SpecGuardBench that belong to each type.
Agent
Detection ↑
False Alarm ↓
Faithfulness ↑
Edge Cov. ↑
Cost
Codex / GPT-5.6-sol
83.0%
24.3%
63.4%
82.4%
$0.73
Claude Code / Claude Opus 5
62.6%
19.9%
50.5%
73.9%
$1.76
OpenCode / DeepSeek-V4-Pro
64.7%
25.5%
45.1%
73.7%
$0.43
OpenCode / GLM-5.3
75.5%
17.2%
62.5%
84.4%
$1.41
Appendix
Table 4: Performance of the four coding agents on the 291 validation tasks of SpecGuardBench , averaged over the 30 features instead of over tasks. Each metric is defined as in Section 3.1 , computed within each feature, and then averaged over the features with equal weight. Cost denotes the average cost per task in U.S. dollars.
Gold reference → violating reference (%)
Agent
Detection ↑
False Alarm ↓
Gold Rejection ↓
Faithfulness ↑
Codex / GPT-5.6-sol
86.5 → 78.3
24.8 → 31.7
0 1.5 → 24.1
66.2 → 51.5
Claude Code / Claude Opus 5
64.3 → 40.6
19.8 → 35.8
0 5.3 → 28.7
49.6 → 25.2
OpenCode / DeepSeek-V4-Pro
75.7 → 72.2
22.2 → 51.6
16.4 → 43.1
57.3 → 30.6
OpenCode / GLM-5.3
80.5 → 49.2
14.2 → 29.2
0 0.0 → 13.3
70.9 → 42.1
Appendix
Table 5: Table 2 averaged over the 30 features of the Lite Set instead of over its 100 tasks. Each metric is computed within each feature and then averaged over the features with equal weight.
Agent
Detection
False Alarm
Faithfulness
Edge Cov.
Codex / GPT-5.6-sol
81.8 ± 5.9
23.0 ± 5.7
61.9 ± 8.0
82.0 ± 6.4
Claude Code / Claude Opus 5
65.3 ± 5.4
20.6 ± 4.5
50.2 ± 6.3
72.4 ± 6.6
OpenCode / DeepSeek-V4-Pro
66.7 ± 5.8
26.8 ± 7.1
45.0 ± 6.1
75.1 ± 7.7
OpenCode / GLM-5.3
74.2 ± 5.8
15.1 ± 4.6
62.9 ± 6.9
84.3 ± 4.7
GPT-5.6-sol − GLM-5.3
+ 7.6 ± 6.6
+ 7.9 ± 4.4
− 1.0 ± 6.8
− 2.3 ± 4.1
DeepSeek-V4-Pro − Claude Opus 5
+ 1.4 ± 5.4
+ 6.2 ± 5.4
− 5.2 ± 5.5
+ 2.7 ± 4.2
Appendix
Table 6: Table 1 with 95% confidence intervals clustered by feature. The last three rows give the differences between the agents that Section 4.2 compares.
In the contracts
In the paper
certificate
validation harness
build_cases() , coverage cases
scenario generator, test scenarios
check_case(case)
executable checks
case
test scenario
target
the callable the scenarios invoke
gold implementation, gold patch
gold implementation
Appendix
Table 7: Names used inside the pipeline and the corresponding terms of the paper.