When AI Is Wrong on Purpose: How Students Respond to Buggy GenAI Code
2026-07-06 • Software Engineering
Software EngineeringComputers and Society
AI summaryⓘ
The authors studied how computer science students work with AI-generated code that sometimes has hidden bugs. They introduced purposely buggy code to help students practice finding and fixing errors, instead of just trusting the AI output. They found that students fix injected bugs by editing code directly, while failures caused by unclear prompts lead students to improve their instructions. These activities help students learn to review, debug, and better understand both code and AI limitations. The authors suggest this combined approach improves programming education with AI tools.
Generative AIprompt engineeringcode debuggingsoftware verificationCS1 educationcode reviewprogramming pedagogynatural language promptsbug injectionAI-assisted programming
Authors
Victor-Alexandru Pădurean, Kaitlin Riegel, Alkis Gotovos, Jyotika Mahapatra, Ahana Ghosh, Paul Denny, Juho Leinonen, James Prather, Adish Singla
Abstract
As Generative AI (GenAI) becomes increasingly central to software development, CS education is integrating prompt-centered workflows where students describe intended program behavior in natural language to elicit code. However, professional practice requires careful review and verification of GenAI-generated code that may appear correct while containing subtle faults. This creates a challenge for CS1-level activities, where current models often solve tasks correctly and reduce students' incentive to closely inspect generated outputs. We investigate how prompt-centered programming activities can be adapted to better foster these practices. Specifically, we explore an approach where realistic, runnable bugs are injected into otherwise correct solutions, thus requiring students to read and repair generated outputs. We analyzed 2,636 sessions from 917 students, and examined behavior across instances of naturally occurring prompt-related failures and deliberately injected bugs within each session. Our findings show that students responded differently across bug sources. Deliberately injected bugs more often led to direct code edits and higher next-attempt success, suggesting localized repair of near-miss solutions. Prompt-related failures instead more often led students to refine prompts by clarifying constraints, updating function signatures, adding edge cases, or reframing the task. Student reflections reinforce the emphasis on review and repair, describing useful practice in code understanding, code review, and debugging, as well as a more careful verification mindset and greater awareness of GenAI limitations. Ultimately, prompt-related failures and injected bugs together support a pedagogically useful GenAI workflow, where students practice both specification refinement through prompts and debugging through code editing.