Metraipolis › archive › dc_e4bbe621d71e
Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generation — arXiv:2608.17177
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2608.17177
- License (as archived)
- CC0-1.0
- Archived
- 2026-10-18T14:55:26.764Z
- SHA-256 of the archived text
3634d0224a5df7f0d45940c4b56763e181c4832233da6847808762d80365a1e5- Stable URL of this page
https://metraipolis.com/documento/dc_e4bbe621d71e
How to cite
Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generation — arXiv:2608.17177 — arXiv (en), https://arxiv.org/abs/2608.17177 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_e4bbe621d71e (Metraipolis archive dc_e4bbe621d71e, sha256 3634d0224a5df7f0d45940c4b56763e181c4832233da6847808762d80365a1e5)
BibTeX
@misc{dce4bbe621d71e,
title = {Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generation — arXiv:2608.17177},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2608.17177},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_e4bbe621d71e; sha256 3634d0224a5df7f0d45940c4b56763e181c4832233da6847808762d80365a1e5},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2608.17177. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
LLM-based agents are increasingly used for coding tasks, where they have outperformed many classical approaches and scaled to repository-level tasks, such as test generation. However, when directly prompted to generate tests, these agents can fail to reason about the code and its underlying contracts, thereby missing edge cases and behavioral boundaries that affect test quality. To address this limitation, we propose Spec-Driven Test Generation, where we instruct an agent to first reason about -- and explicitly document -- code pre-conditions, post-conditions, and undefined behaviors. This intermediate semi-formal specification acts as a cognitive scaffold to guide subsequent test generation. Our evaluation on production bugs from Google shows that the spec-driven agent can deliver a 9.8 percentage points ($p = 0.0352$) improvement in bug detection rate and a 2.5 percentage point ($p = 0.0034$) improvement in branch coverage, compared to a traditional test generation agent baseline. Using LLM-as-a-Judge, we further show that test suites generated by the spec-driven agent are superior to the baseline and human-authored tests in 77.8% and 56.7% of the cases, respectively, and demonstrated improvements on following best practices, readability, and edge-case coverage. Tema degli esploratori: calcolo e infrastrutture (retro-catalogo arXiv: annunci del 2026-08-19 in cs.SE). Categorie arXiv: Software Engineering (cs.SE). Pagina del lavoro: https://arxiv.org/abs/2608.17177 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito). Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina. Letto il 2026-10-18T14:48:24.128Z dalla pagina https://arxiv.org/catchup/cs.SE/2026-08-19?abs=True (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).