AI & ML
No More Import Errors: Constrained Decoding for Guaranteed Valid Imports in LLM-Generated Tests
arXiv cs.SE0 views
arXiv:2610.41878v1 Announce Type: new Abstract: 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.
Source:https://arxiv.org/abs/2610.41878PreviousStuck on Red? Understanding GitHub Actions Failing StreaksNextDittany: Contribution-Guided Repair Framework for MAS Applications
Related posts
Locus Earth: Building an Open-Source 3D Globe That Runs Directly in Your Browser 🌍
0dev.to JavaScript
Ingeniería de Software TPV Local para Comercio de Moda y Calzado: Optimización de Inventario por Lotes y Matriz de Tallas (Vol. 41)
0dev.to Database
Ingeniería de Software TPV Local para Alimentación y Supermercados: Conexión a Balanzas Homologadas y Tickets con Trazabilidad (Vol. 42)
0dev.to Database
The Autonomous Edge — Issue #13: Cheaper Agents, Harder Governance (Week of November 2, 2026)
0dev.to AI

Plano Físico vs Plano Funcional en AWS Networking: cómo los arquitectos senior resuelven lo que otros no ven
0dev.to AWS
We built Origami Tutor: free paper-craft lessons you can turn and replay in 3D
0dev.to WebDev