Agentic AI
How AI Coding Agents Learn From Proof Failures to Write Correct Code
A new approach turns diagnostic insights from failed verification checks into reusable templates that guide AI agents toward provably correct code.
Ensuring that AI-generated code not only runs but also provably meets its specification remains a hard problem. A new arXiv paper presents a framework for converting the lessons learned when formal verification fails into structured guidance that AI agents can apply to future coding tasks.
The Core Challenge#
Coding agents face a dual problem: they must verify that a program correctly implements its intended behavior, and they must confirm that the specification itself accurately reflects what users actually want. When formal proofs fail, the diagnostic information from those failures—what the specification missed, how the code deviated, where the reasoning broke down—often gets thrown away. The research explores how to capture and reuse that expert knowledge.
The Approach and Method#
The team combined executable language definitions built using the K framework with a toolkit for three key operations:
- constructing formal specifications
- repairing broken proofs
- auditing whether proofs are truly adequate
They tested the approach on HumanEval, a benchmark of 164 Python programming tasks. With human guidance, the system achieved a perfect 164/164 success rate, where an AI auditor confirmed each solution's correctness after two targeted repair cycles.
Validation Against Real Problems#
To test whether the audit process catches genuine issues that passing proofs might miss, researchers created 12 carefully reviewed pairs of clean code and intentionally defective variants. Despite all packages passing their formal K proofs, the auditing step identified every defect in the flawed packages and accepted all clean ones—suggesting the verification process provides real assurance.
The team also tested their methods on KleverBench, a set of 31 programs where operator meanings were deliberately changed. Comparing their learned guidance against generic advice and complete acceptance rules produced mixed results across different model configurations and resource budgets, pointing to the need for smarter selection of which guidance matters most when resources are tight.
Implications and Next Steps#
The work demonstrates concrete progress toward agents that produce not just working code but code accompanied by checkable correctness arguments. The researchers note both advances—such as human-reviewed proofs confirming expected behavior under blockchain semantics—and ongoing challenges, particularly in deciding which diagnostic insights to prioritize when computational budgets are limited.

