Grounded Copilot: How Programmers Interact with Code-Generating Models
Introduction. The dream of an “AI assistant” working alongside the programmer has captured our imagination for several decades now, giving rise to a rich body of work from both the programming languages [Ferdowsifard et al. 2020; Miltner et al. 2019; Ni et al. 2021; Raychev et al. 2014] and the machine learning [Guo et al. 2021; Kalyan et al. 2018; Xu et al. 2020] communities. Thanks to recent breakthroughs in large language models (LLMs) [Li et al. 2022; Vaswani et al. 2017] this dream finally seems within reach. OpenAI’s Codex model [Chen et al. 2021], which contains 12 billion model parameters and is trained on 54 million software repositories on GitHub, is able to correctly solve 30–70% of novel Python problems, while DeepMind’s AlphaCode [Li et al. 2022] ranked in the top 54.3% among 5000 human programmers on the competitive programming platform Codeforces. With this impressive performance, large code-generating models are quickly escaping research labs to power industrial programming assistant tools, such as Github Copilot [Friedman 2021]. The growing adoption of these tools gives rise to questions about the nature of AI-assisted programming: What kinds of tasks do programmers need assistance with? How do programmers prefer to communicate their intent to the tool? How do they validate the generated code to determine its correctness and how do they cope with errors? It is clear that the design of programming assistants should be informed by the answers to these questions, yet research on these topics is currently scarce. Specifically, we are aware of only one usability study of Copilot, by Vaithilingam et al. [2022]; although their work makes several interesting observations about human behavior (which we discuss in more detail in Sec. 7), ultimately it has a narrow goal of measuring whether Copilot helps programmers in solving stand-alone Python programming tasks. To complement this study and to obtain more generalizable insights that can inform the design of future tools, our work sets out to explore how programmers interact with Copilot in a broader setting.
Summary of findings. The main thesis of our theory (Sec. 4) is that user interactions with Copilot can be classified into two modes—acceleration and exploration—akin to the two systems of thought in dual-process theories of cognition [Carlston 2013; Milli et al. 2021], popularized by Daniel Kahneman’s “Thinking, Fast and Slow” [Kahneman 2011]. In acceleration mode, the programmer already knows what they want to do next, and Copilot helps them get there quicker; interactions in this mode are fast and do not break programmer’s flow. In exploration mode, the programmer is not sure how to proceed and uses Copilot to explore their options or get a starting point for the solution; interactions in this mode are slow and deliberate, and include explicit prompting and more extensive validation.
Sec. 5 describes two kinds of further analysis of our theory. First, we performed a quantitative analysis of the data collected during the study, comparing prompting and validation behaviors across modes, and quantifying the factors that influence the relative prevalence of each mode. Second, to reinforce our findings, we gathered additional data from five livestream videos we found on YouTube and Twitch, and confirmed that the streamers’ behavior was consistent with our theory. Based on our theory, we provide design recommendations for future programming assistants (Sec. 6). For example, if the tool is aware that the programmer is currently in acceleration mode, it could avoid breaking their flow by sticking with only short and high-confidence code suggestions. On the other hand, to aid exploration, the IDE could provide better affordances to compare and contrast alternative code suggestions, or simplify validation of generated code via automated testing or live programming.
Related work. Usability of Copilot. The closest to our work is the study by Vaithilingam et al. [2022], which also evaluates Copilot. The main differences are: (1) their study is on stand-alone tasks, whereas ours includes tasks that require contributing to an existing codebase; (2) their study is comparative and focuses on the rate and time of task completion with and without Copilot’s help; (3) their study only used Python, whereas we used several programming languages. In our study, we explicitly stepped away from the common comparative setting, where participants are given well-defined stand-alone tasks, and the goal is to collect quantitative data on how well and quickly they complete the tasks, with and without the tool under evaluation. Instead, we chose more open-ended tasks in the context of an existing codebase, which we believe is closer to the real-world use case. Further, instead of skewing quantitative answers to predefined research questions, we chose the grounded theory approach, with the general goal of finding patters in programmers’ behavior when they interact with Copilot; we believe this approach is complementary to the quantitative studies. Finally, our usage of multiple languages enables inter-language comparisons and more generalizable conclusions. On the other hand, Vaithilingam et al. [2022] also report several qualitative findings. Most of them agree with ours, such as: that Copilot often provides a good starting point for programmers who do not know how to approach the task, that programmers are generally willing to repair code suggestions, but Copilot-generated code is harder to debug. There are also some differences; fore example, half of their participants (12/24) said they had trouble understanding and modifying Copilot-generated code, whereas our participants did not seem to share this difficulty; this might be because our study is with more experiences developers: only one participant in our study was an undergraduate student, whereas 10/24 in their study were undergraduates.
Usability of other LLM tools. Beyond Copilot, Jiang et al. [2022] conducted a user study to analyse the interaction of developers with a natural language to code tool called GenLine. GenLine is similar to Copilot but involves explicitly invoking a command within a text editor. Similar to our findings, developers in their study were willing to rewrite the natural language prompt to clarify their intent and expressed the need for a syntax to communicate with the model more clearly. However, their findings were mainly centered around prompting strategies whereas we did a more comprehensive analysis of developer interactions with Copilot. Moreover, the tool was not integrated in the participant’s daily workflow like in our study. In a similar vein, Xu et al.
Method. Participants. We developed our theory through a user study with 20 participants (15 from academia and 5 from industry). We recruited these participants through personal contacts, Twitter, and Reddit. Nine of the participants had used Copilot to varying degrees prior to the study. Participants were not paid, but those without access to Copilot were provided access to the technical preview for continued use after the study concluded. Tab. 1 lists relevant information about each participant. We asked each participant to select a statement best describing their level of experience with possible target languages, with options ranging from “I have never used Python”, to “I use Python professionally” (from least-to-most, used in Tab. 1: Never, Occasional, Regular, and Professional). We screened out participants who had never used the target language. We choose a qualitative selfassignment of experience as other common metrics, such as years-of-experience, can be misleading. For example, a professor having used Rust occasionally over eight years is arguably less experienced than as a software engineer using Rust all day for a year. User protocol. To study participants using Copilot, we gave them a programming task to attempt with Copilot’s help. Over the course of an hour a participant was given a small training task to familiarize them with Copilot’s various usage models (i.e. code completion, natural language prompt, and the multi-suggestion pane). During the core task—about 20-40 minutes—a participant was asked to talk through their interactions with Copilot. They were encouraged to work Copilot into their usual workflow, but they were not required to use Copilot. After the task, the interviewer asked them questions through a semi-structured interview; these questions as well as the tasks are available in our supplementary package. The entire session was recorded and transcribed to use as data in our grounded theory.
Grounded Theory Process. Grounded Theory (GT) takes qualitative data and produces a theory in an iterative process, first pioneered by [Glaser and Strauss 1967]. As opposed to evaluating fixed, a priori hypotheses, a study using the GT methodology seeks to generate new hypotheses in an overarching theory developed without prior theoretical knowledge on the topic. A researcher produces this theory by constantly interleaving data collection and data analysis. GT has diversified into three primary styles over the past half-century. We follow the framework laid out by Strauss and Corbin [Strauss and Corbin 1990], commonly called Straussian Grounded Theory [Stol et al. 2016]. We describe our process below. We began our study with the blank slate question: “How do programmers interact with Copilot?” Our bimodal theory of acceleration and exploration was not yet formed. During each session, we took notes to guide our semi-structured interview. After each session, we tagged any portion of the recording relevant to Copilot with a note. We took into account what the participant said, what they did, and their body language. For example, we initially tagged an instance where P2 was carefully examining and highlighting part of a large Copilot suggestion as “validating subexpression”. Tagging the data in this way is called (qualitative) coding; and doing so without a set of predefined codes is called open coding in Straussian GT. The first two authors coded the first two videos together, to agree on a coding-style, but later data were coded by one and discussed by both.
1:6 Shraddha Barke, Michael B. James, and Nadia Polikarpova By the end of the eighth session, we began to see patterns emerging in our data. We noticed two distinct patterns in our codes which eventually crystallized into our acceleration and exploration modes. During this phase of analysis, we aggregated our codes to understand the conditions when a participant would enter acceleration or exploration, and the strategies a participant deployed in that mode. For example, we realized that if a programer can decompose a problem, then they often ended up in acceleration (details in Sec. 4.1.1).
Discussion. 4 THEORY Through our grounded theory analysis, we identified two main modes of developer interactions with Copilot: acceleration and exploration. In acceleration mode, a programmer uses Copilot to execute their planned code actions, by completing a logical unit of code or a comment. Acceleration works within user’s sense of flow. For example, recall how in Sec. 2.1 Axel accepted Copilot’s suggestion of rule.split(" => "), knowing it was what he wanted to type anyways. This is a characteristic example of acceleration, where Copilot was helping him program faster. In exploration mode, a programmer relies on Copilot to help them plan their code actions. A programmer may use Copilot to assist with unfamiliar syntax, to look up the appropriate API, or to discover the right algorithm. In Sec. 2.2, when Emily was searching for the right set of matplotlib calls, she was considering alternatives, gaining confidence in the API, and simply trying to learn how to finish her task. All of these intentions are part of the exploration mode when using Copilot. We found that programmers alternate between these two modes as they complete their task, fluidly switching from one mode to the other. In this section, we systematize our observation of each mode: acceleration (Sec. 4.1) and exploration (Sec. 4.2). For each mode, we start with identifying the conditions that lead the participant to end up in that mode, and then proceed to describe common strategies (i.e. behavioral patterns) we observed in that mode. Each numbered subsection (e.g. Sec. 4.1.3) is a hypothesis deriving from our top-level bimodal theory. Each named paragraph heading is an aspect of that hypothesis.
Acceleration is characterized by the programmer being “in the zone” and actively “driving” the development, while occasionally relying on Copilot to complete their thought process. A programmer will often accept a Copilot suggestion without much comment and keep on going without losing focus. In this interaction mode, programmers tend to think of Copilot as an intelligent autocomplete that just needs to complete their line of thought. This idea was well put by P13 who said:
4.1.1 Programmers use acceleration after decomposing the task. We found that the main causal condition for a participant to end up in acceleration mode is being able to decompose the programming task into microtasks. We define a microtask to be a participant-defined task with a well-understood and well-defined job. For example, when P16 was working on the Advent of Code task, they created two separate microtasks to parse the input and to compute the output. Because they understood these microtasks well, they wrote a type signature and used descriptive names for each of them; as a result, Copilot was adept at completing these microtasks for them. Another illustrative example is our Benford’s Law task, which was explicitly designed to have a familiar and an unfamiliar subtask. In the first subtask, participants were asked to implement a fast Fibonacci function. All four participants were familiar with the Fibonacci sequence and knew how to make it efficient. As a result, all of them were able to use Copilot to accelerate through this familiar microtask. P14 explicitly noted:
4.1.3 Long suggestions break flow. In acceleration mode, long, multi-line suggestions are at best dismissed out of hand and at worst distract the programmer away from their flow. Upon getting a 16-line suggestion and after just four seconds of review P6 uttered: “Oh God, no. Absolutely not”. When P6 got other large suggestions, they would exclaim, “Stop it!”, and continue 4.1.4 Programmers validate suggestions by “pattern matching”.
Conclusion. 6 RECOMMENDATIONS Control over the context. There was general confusion among participants about how Copilot uses their code to provide suggestions. Some participants were unsure how much code Copilot can take into context, for example, P8 theorized a hard limit to the input length: “I think the README is too long and complicated for it to actually extract [helpful information]”. Other participants (P8, P10, P15, P18) mentioned they were unsure about which pieces of information Copilot had extracted about their local codebase. Specifically, there appeared to be a broad misconception that commenting out code made it invisible to Copilot, despite those same participants using comment prompts. P20 “assumed it wouldn’t be aware of code if [they] commented it out”. We also observed participants (P2, P3, P4 P6) comment out code generated by Copilot in an attempt to get it to generate an alternative suggestion. Participants that were aware of Copilot’s sensitivity to context wanted to have more control over that context. Some participants wanted to give Copilot specific context: in describing their work outside of the study, P15 mentioned poor suggestions from Copilot and wished they could emphasize a subset of their code (i.e. niche libraries they imported), so they could feel more confident that the suggestions were relevant to their code. Others, P4 and P12, wished to query Copilot with a natural-language prompt without any code context, just as they would query StackOverflow. In order to achieve this control, participants wanted Copilot to provide dedicated syntax. For example, P2 wanted Copilot to use a specific function, and tried to achieve this by “using the function name in backquotes”. P18 asked: “Is there a way to prompt Copilot into suggesting a data structure?” Finally, P4, when looking for examples of using the del operation in Python, wanted to explicitly ask Copilot to show only “syntax examples”. Based on these observations, future tools could give programmers ways to customize the context. For example, a future tool could provide a scratchpad to isolate general, StackOverflow-style prompts from the rest of the codebase.
Limitations. AND THREATS TO VALIDITY Our participants worked on tasks of our design, as opposed to their own projects. If they were working in a more familiar codebase and without the time pressure of a study, their interactions could have been different. Moreover, our tasks focused only on code authorship, as opposed to refactoring, testing, debugging, or other common aspects of software engineering. We consider these beyond the scope of this study, although our participants did occasionally get a chance to test or debug their code. We recruited 20 participants, with a skew towards those in academia, hardly a representative sample of all programmers. Similarly, although we tried to diversify the type of tasks our participants were solving and the programming languages they were using, other kinds of tasks and languages could have lead to different interactions. 11 of our participants had not used Copilot before the study, and hence might not be representative of regular users of the tool. We gave all participants a 5-minute training task so they could familiarize themselves with Copilot, and yet we observed that first-time users were sometimes over-reliant on Copilot, in a way that prior users were not. We chose to include new users in our study since the majority of programmers in the wild have never used a code-generating model.
Lines of inquiry this paper opens 24
Research framings built by reading the notes related to this paper — the questions it feeds into.
Why does AI assistance boost immediate performance but reduce learning transfer? Do AI coding tools meaningfully improve developer productivity and quality?- Do misconceptions about AI context actually degrade code suggestion quality?
- Why do long multi-line code suggestions disrupt programmer flow?
- Does orchestration layer design matter as much as base model capability in coding?
- How does design-system onboarding from code differ across AI design tools?
- How do programmers alternate between acceleration and exploration modes with AI?
- Do programmers prefer partial hints or complete code solutions from AI?
- Do self-selected heavy Copilot users show different task shifts than randomized users?
- Why did freed email time not spill over into other work activities?
- How do workers define meaningful versus pointless tasks across different occupations?
- Why do workers perceive some workplace tasks as disconnected from meaningful outcomes?
- Does completing complex tasks cause satisfaction or does satisfaction attract complex tasks?
- How do task shifts precede any wage or employment changes?
- How do different divisions of labor change what augmentation actually means?
- Does removing entry-level tasks increase expertise demands on remaining work?
- Does removing tasks from workers require higher or lower expertise for remaining work?