The increasing use of large language model (LLM)-powered code generation tools, such as GitHub Copilot, is transforming software engineering practices. This paper investigates how developers validate and repair code generated by Copilot and examines the impact of code provenance awareness during these processes. We conducted a lab study with 28 participants, who were tasked with validating and repairing Copilot-generated code in three software projects. Participants were randomly divided into two groups: one informed about the provenance of LLM-generated code and the other not. We collected data on IDE interactions, eye-tracking, cognitive workload assessments, and conducted semi-structured interviews. Our results indicate that, without explicit information, developers often fail to identify the LLM origin of the code. Developers generally employ similar validation and repair strategies for LLM-generated code, but exhibit behaviors such as frequent switching between code and comments, different attentional focus, and a tendency to delete and rewrite code. Being aware of the code's provenance led to improved performance, increased search efforts, more frequent Copilot usage, and higher cognitive workload. These findings enhance our understanding of how developers interact with LLM-generated code and carry implications for designing tools that facilitate effective human-LLM collaboration in software development.
翻译:随着GitHub Copilot等大型语言模型(LLM)驱动的代码生成工具的日益普及,软件工程实践正在发生变革。本文研究了开发者如何验证与修复Copilot生成的代码,并探讨了在此过程中代码来源认知所产生的影响。我们开展了一项包含28名参与者的实验室研究,要求参与者在三个软件项目中验证并修复Copilot生成的代码。参与者被随机分为两组:一组被告知代码由LLM生成,另一组则未获知此信息。我们收集了IDE交互数据、眼动追踪数据、认知负荷评估数据,并进行了半结构化访谈。研究结果表明,在缺乏明确信息的情况下,开发者通常无法识别代码的LLM来源。开发者对LLM生成代码普遍采用相似的验证与修复策略,但表现出特定行为模式,例如频繁在代码与注释间切换、注意力焦点分布差异、以及倾向于删除并重写代码。知晓代码来源会提升任务表现、增加检索努力、更频繁地使用Copilot,同时导致更高的认知负荷。这些发现深化了我们对开发者与LLM生成代码交互机制的理解,并为设计促进软件开发中高效人机协作的工具提供了重要启示。