Metraipolis › archive › dc_225d602f7485
No More Import Errors: Constrained Decoding for Guaranteed Valid Imports in LLM-Generated Tests — arXiv:2610.41878
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2610.41878
- License (as archived)
- CC0-1.0
- Archived
- 2026-11-03T05:42:19.471Z
- SHA-256 of the archived text
3f7f0f4ce56187acf2786c66b86b76d3b7b33f51cc474b66810805e70b4a88dd- Stable URL of this page
https://metraipolis.com/documento/dc_225d602f7485
How to cite
No More Import Errors: Constrained Decoding for Guaranteed Valid Imports in LLM-Generated Tests — arXiv:2610.41878 — arXiv (en), https://arxiv.org/abs/2610.41878 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_225d602f7485 (Metraipolis archive dc_225d602f7485, sha256 3f7f0f4ce56187acf2786c66b86b76d3b7b33f51cc474b66810805e70b4a88dd)
BibTeX
@misc{dc225d602f7485,
title = {No More Import Errors: Constrained Decoding for Guaranteed Valid Imports in LLM-Generated Tests — arXiv:2610.41878},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2610.41878},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_225d602f7485; sha256 3f7f0f4ce56187acf2786c66b86b76d3b7b33f51cc474b66810805e70b4a88dd},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2610.41878. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
One of the most common failure reasons of LLM-based test generation pipelines is import errors. Grammar constrained decoding can modify the probabilities of the LLM's final layer during token generation to guarantee valid imports. However, we find that it can lead to degenerate solutions, i.e., repetitive valid imports (import streaks) that exhaust the token budget before a test is generated. We propose Constrained Beam Decoding with Lookup (CBDL), a novel method that guarantees import validity while addressing import streaks by avoiding premature commitment to tokens that lead to repetitive imports. Because it operates at the decoding stage, CBDL can be integrated into existing LLM-based test generation pipelines. We implement CBDL for Python and Java and evaluate it on two test generation tasks, showing that generated tests have 100% valid imports, outperforming both static (RAG and LIBRO) and dynamic (Agentic Repair) import-validity approaches that leave 45%, 10%, and 43% of import errors unresolved. CBDL converts on average 14% of initial import errors into functionally correct tests, increasing overall test correctness by 1-4 percentage points over unconstrained generation. Even when import validity does not directly lead to a correct test, it allows agentic repair pipelines to allocate the repair budget to remaining errors, increasing correct tests by 2-7 percentage points for Python and 1-6 for Java. Finally, we show that a hybrid pipeline, where a small local model equipped with CBDL generates imports while the frontier GPT-5.2 model generates the test body, outperforms generating both with GPT-5.2 alone by 1-3 percentage points. Overall, CBDL removes a major bottleneck in LLM-based test generation: by guaranteeing import validity with a small overhead (16-21 seconds per test), it improves test correctness and enables cost-effective hybrid generation. Tema degli esploratori: calcolo e infrastrutture (elenco arXiv cs.SE, nuovi lavori del giorno). Categorie arXiv: Software Engineering (cs.SE). Pagina del lavoro: https://arxiv.org/abs/2610.41878 — 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-11-03T05:26:33.220Z dalla pagina https://arxiv.org/list/cs.SE/new (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).