一句话:首次系统研究环境感知代码生成,发布多包可执行基准 VersiBCB,并提出数据、参数、缓存三类适配策略。
现有大语言模型(LLM)代码生成评测多聚焦默认或未指定软件环境下的孤立小规模代码单元,难以判断其能否为特定用户环境生成可直接执行的代码。本文首次系统研究环境感知代码生成(EACG),要求生成代码在功能正确的同时,能在任意软件配置下直接执行。为支持贴近实际的评测,作者提出 VersiBCB 基准,具备多包、可执行验证与感知弃用等特点,反映复杂且持续演化的软件环境。基于该基准,作者从数据、参数和缓存三个正交方向探索适配策略并给出代表性方法。结果表明,现有 LLM 在环境特定代码生成上仍面临困难,但所提适配策略可改善环境兼容性与可执行性,揭示了 LLM 部署于实际软件工程流程中的关键挑战与机遇。
Recent progress in large language models (LLMs) has led to impressive code generation capabilities. However, existing evaluations of LLMs primarily focus on generating isolated, small-scale code units (e.g., single functions or statements) under default or unspecified software environments. As a result, it remains unclear whether LLMs can reliably generate executable code tailored to specific user environments. To fill this knowledge gap, we make the first systematic study of Environment-Aware Code Generation (EACG), which requires generating code that is both functionally correct and directly executable under arbitrary software configurations. To support realistic evaluation, we introduce VersiBCB, a benchmark featuring multi-package, executable-verified, and deprecation-aware, reflecting complex and evolving software environments that are often overlooked in prior datasets. Building on this benchmark, we explore three orthogonal adaptation axes: data, parameters, and cache, and further develop representative strategies for each. Our results reveal that existing LLMs struggle with environment-specific code generation, but our adaptation strategies yield improvements in environment compatibility and executability. These findings highlight critical challenges and opportunities for deploying LLMs in practical software engineering workflows.
@inproceedings{abs-2601-12262,
title = {Environment-Aware Code Generation: How far are We?},
author = {Tongtong Wu and Rongyi Chen and Wenjie Du and Suyu Ma and Guilin Qi and Zhenchang Xing and Shahram Khadivi and Ramesh Periyathambi and Gholamreza Haffari},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3744916.3787784}
}