Building GitHub Copilot: Working with OpenAI's LLMs in Production

github · Tech · 2023 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production code completion

GitHub needed to turn OpenAI's general large language models into a developer-facing code completion product that worked inside IDEs. The system had to choose an interaction modality, construct prompts with enough project context, track whether suggestions helped users, adapt models to codebases, and fix quality failures such as language confusion in new files.

Constraints:

Architecture

GitHub Copilot integrates IDE context with OpenAI's Codex-family models through a prompt-construction and model-improvement loop. The IDE sends the current file plus selected context such as language headers, file paths, neighboring tabs, and similar snippets from open files. The Model Improvements team monitors completion quality, experiments with prompt crafting and fine-tuning, and works with successive OpenAI model drops from Python-only to JavaScript to multilingual Codex. User acceptance and retained characters guide which context signals and model changes actually improve the product.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  developer-ide[Developer IDE] --> copilot-context-builder[Copilot context builder]
  copilot-context-builder --> neighboring-tab-retriever[Neighboring-tab retriever]
  copilot-context-builder --> file-path-enricher[File path enricher]
  copilot-context-builder --> openai-codex-model[OpenAI Codex model]
  neighboring-tab-retriever --> copilot-context-builder
  file-path-enricher --> copilot-context-builder
  openai-codex-model --> completion-suggestion[Completion suggestion]
  completion-suggestion --> developer-ide
  completion-suggestion --> completion-telemetry[Completion telemetry]
  completion-telemetry --> model-improvements-team[Model Improvements team]
  model-improvements-team --> prompt-crafting-experiments[Prompt crafting experiments]
  model-improvements-team --> fine-tuning-pipeline[Fine-tuning pipeline]
  prompt-crafting-experiments --> copilot-context-builder
  fine-tuning-pipeline --> openai-codex-model
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Developer IDE Editing environment where the developer writes code and receives Copilot suggestions. Copilot context builder
Copilot context builder Constructs the pseudo-document sent to the model from current-file and IDE context. OpenAI Codex model, Neighboring-tab retriever, File path enricher
Neighboring-tab retriever Pulls similar text from other open editor tabs or files to improve suggestion relevance. Copilot context builder
File path enricher Adds language and file-path cues to the prompt so the model understands file type and likely domain. Copilot context builder
OpenAI Codex model Large language model that generates code suggestions from the constructed pseudo-document. Completion suggestion
Completion suggestion Generated code shown to the developer for acceptance, retention, edit, or rejection. Developer IDE, Completion telemetry
Completion telemetry Acceptance and retained-character signals used to judge whether Copilot suggestions helped users. Model Improvements team
Model Improvements team Team responsible for monitoring quality and improving completions through prompt crafting and fine-tuning. Prompt crafting experiments, Fine-tuning pipeline
Prompt crafting experiments Experiments that change the pseudo-document construction to improve completion quality. Copilot context builder
Fine-tuning pipeline Adapts the pre-trained Codex model on more specific datasets or user codebase context. OpenAI Codex model

Data flow

A developer edits code in an IDE. Copilot's context builder starts from the current file, enriches the pseudo-document with signals such as language, file path, neighboring tabs, and similar text from other open files, and sends that prompt to an OpenAI model. The model returns a code suggestion. The user accepts, keeps, edits, or rejects it, and those completion signals inform model-improvement work such as prompt-crafting experiments and fine-tuning on more specific codebase data.

4 supporting quotes
“The secret is that we don’t just have to provide the model with the original file that the GitHub Copilot user is currently editing”article, stated
“we look for additional pieces of context inside the IDE that can hint the model towards better completions.” He continues, “There have been several changes that helped get GitHub Copilot where it is today, but one of my favorite tricks was when we pulled”article, stated
“we pulled similar texts in from the user’s neighboring editor tabs. That was a huge lift in our acceptance rate and characters retained.”article, stated
“the Model Improvements team became responsible for monitoring and improving GitHub Copilot’s quality through communicating with the underlying LLM.”article, stated

Why this architecture

GitHub moved from a chatbot prototype to IDE integration because code completion was more interactive and broadly useful. Prompt crafting fits the way LLMs complete partial documents, so Copilot's architecture focuses on creating better pseudo-documents from IDE context. Acceptance telemetry gives the Model Improvements team a product-aligned quality signal, while fine-tuning and successive Codex drops address model-level capability gaps.

4 supporting quotes
“We built a prototype, but it turned out there was a better modality for this technology available,” Ziegler says. “We thought, ‘Let’s try to put this in the IDE.’” “The moment we did that and saw how well it worked, the whole static question-and-answer”article, stated
“question-and-answer modality was forgotten,” he says. “This new approach was interactive and it was useful in almost every situation.” And with that, the development of GitHub Copilot began. ## Exploring model improvements”article, stated
“the art of prompt crafting is really all about creating a ‘pseudo-document’ that will lead the model to a completion that benefits the customer”article, stated
“Completion refers to when users accept and keep GitHub Copilot suggestions in their code, and there are several different levers that the Model Improvements team works on to increase completion, including prompt crafting and fine tuning. ![An example of”article, stated

Models used: GPT-3 · Codex · Python-only OpenAI model · JavaScript OpenAI model · multilingual Codex model

Scale

Alternatives considered (roads not taken)

Keep code generation as a static coding-question chatbot.

Rejected because: The team found IDE integration more interactive and useful across situations.

3 supporting quotes
“they began to conceptualize an AI-powered chatbot for developers to ask coding questions and receive immediate, runnable code snippets.”article, stated
“We built a prototype, but it turned out there was a better modality for this technology available,” Ziegler says. “We thought, ‘Let’s try to put this in the IDE.’” “The moment we did that and saw how well it worked, the whole static question-and-answer”article, stated
“The moment we did that and saw how well it worked, the whole static question-and-answer modality was forgotten”article, stated

Send only the current file as model context.

Rejected because: Neighboring tabs and other IDE context gave the model stronger hints and improved acceptance.

“we don’t just have to provide the model with the original file that the GitHub Copilot user is currently editing”article, stated
“we look for additional pieces of context inside the IDE that can hint the model towards better completions.” He continues, “There have been several changes that helped get GitHub Copilot where it is today, but one of my favorite tricks was when we pulled”article, stated

Use language name alone to disambiguate new files.

Rejected because: File paths conveyed both language and domain cues, solving language confusion and improving quality more than a simple header.

3 supporting quotes
“would suggest Python code,” Rosenkilde explains. So, the team added a headline to the prompt which listed the language you were working in. “Now this had no impact when you were deep down in the file because Copilot could understand which language you were in. But at the top of the file, there could”article, stated
“About a month following that improvement, the team discovered that it was much more powerful to put the path of the file at the top of the document.”article, stated
“that not only solved the language problem, but it also improved the quality and user experience by a surprising margin”article, stated

Assume single-language model specialization would be best.

Rejected because: The JavaScript-specific model had problems that the multilingual model avoided, surprising the team.

3 supporting quotes
“models. “The first model that OpenAI gave us was a Python-only model,” Ziegler remembers. “Next we were delivered a JavaScript model and a multilingual model, and it turned out that the Javascript model had particular problems that the multilingual model did not. It actually came”article, stated
“model and a multilingual model, and it turned out that the Javascript model had particular problems that the multilingual model did not. It actually came as a surprise to us that the multilingual model could perform so well. But each time, the models were just getting better and better, which was”article, stated
“It actually came as a surprise to us that the multilingual model could perform so well. But each time, the models were just getting better and better, which was really exciting for GitHub Copilot’s progress.” In 2021, OpenAI released the multilingual [Codex”article, stated

Patterns

prompt-chaining (llmops)

Copilot turns IDE state into a carefully crafted pseudo-document before asking the model for code completion.

“the art of prompt crafting is really all about creating a ‘pseudo-document’ that will lead the model to a completion that benefits the customer”article, stated
“if the partial document is code, then this completion capability lends itself well to code completion”article, stated

retrieval-ranking (context-engineering)

Copilot retrieves similar text from neighboring editor tabs and other open files to give the model more relevant local context.

“we pulled similar texts in from the user’s neighboring editor tabs.”article, stated
“looked at other files you have open in the IDE at that moment in time and scanned through those files for similar text to what’s in your current cursor”article, stated

fine-tuning-adaptation (model-development)

GitHub adapts Codex toward user-specific codebases and code-completion behavior through fine-tuning.

“Fine-tuning is a technique used in AI to adapt and improve a pre-trained model for a specific task or domain.”article, stated
“we’re training the underlying Codex model on a user’s specific codebase to provide more focused, customized completions”article, stated

eval-driven-development (quality)

Copilot improvements are evaluated through coding-task tests, acceptance/completion rates, retained characters, and real user experience changes.

3 supporting quotes
“We assessed it by giving it coding-like tasks and evaluated it in two different forms.”article, stated
“Completion refers to when users accept and keep GitHub Copilot suggestions in their code”article, stated
“That was a huge lift in our acceptance rate and characters retained.”article, stated

data-quality-loop (feedback)

The Model Improvements team studies why users accept or reject suggestions and what served context caused helpful or unhelpful output.

“Our greatest challenge right now is to consider why the user rejects or accepts a suggestion”article, stated
“what context, or information, that we served to the model caused the model to output something that was either helpful or not helpful”article, stated

latency-optimization (product)

Copilot uses compact context signals such as paths and neighboring snippets to improve completion quality without requiring the user to manually search across tabs.

“Where the developer might flip back and forth between tabs to reference code, we just can do that for them”article, stated
““The end of the file name would give away the language in most cases, and in fact the file name could provide crucial, additional information,” Rosenkilde says.”article, stated

Tradeoffs

Integrate into IDEs rather than stay as a chatbot.

Chose interactive IDE completion over static question-answer chatbot.

Rationale: IDE integration made the product useful in many situations and aligned with the developer's live coding workflow.

“We built a prototype, but it turned out there was a better modality for this technology available”article, stated
“The moment we did that and saw how well it worked, the whole static question-and-answer modality was forgotten”article, stated

Use neighboring editor tabs as prompt context.

Chose IDE-local context enrichment over current-file-only prompting.

Rationale: The neighboring-tab context mirrors how developers manually reference code and produced a large lift in acceptance and retained characters.

3 supporting quotes
“one of my favorite tricks was when we pulled similar texts in from the user’s neighboring editor tabs”article, stated
“That was a huge lift in our acceptance rate and characters retained.”article, stated
“Where the developer might flip back and forth between tabs to reference code, we just can do that for them”article, stated

Put the file path at the top of the prompt.

Chose file path cue over language-only prompt headline.

Rationale: The path supplied both language and semantic hints about the file's likely domain, improving quality beyond just preventing wrong-language output.

3 supporting quotes
“the team discovered that it was much more powerful to put the path of the file at the top of the document.”article, stated
““The end of the file name would give away the language in most cases, and in fact the file name could provide crucial, additional information,” Rosenkilde says.”article, stated
“that not only solved the language problem, but it also improved the quality and user experience by a surprising margin”article, stated

Fine-tune for specific codebases.

Chose codebase-adapted Codex behavior over only generic pre-trained completions.

Rationale: More specific datasets let the pre-trained model adapt to the nuances of a user's code and produce more focused completions.

“training it on a smaller, more specific dataset that is relevant to a particular use case.”article, stated
“we’re training the underlying Codex model on a user’s specific codebase to provide more focused, customized completions”article, stated

Track acceptance as a product-quality signal.

Chose completion and retained-character metrics over only offline model accuracy tests.

Rationale: Whether users accept and keep suggestions is closer to production usefulness than the initial self-contained task tests.

“Completion refers to when users accept and keep GitHub Copilot suggestions in their code”article, stated
“there are several different levers that the Model Improvements team works on to increase completion”article, stated

Gotchas (what bit them)

Static Q&A was the wrong modality for code generation.

Root cause: Runnable snippets in a chatbot did not match how developers continuously write and refine code.

Resolution: The team moved the product into the IDE, where completion was interactive and useful in almost every situation.

3 supporting quotes
“they began to conceptualize an AI-powered chatbot for developers to ask coding questions and receive immediate, runnable code snippets.”article, stated
““We thought, ‘Let’s try to put this in the IDE.’” “The moment we did that and saw how well it worked, the whole static question-and-answer modality was forgotten,” he says.”article, stated
“This new approach was interactive and it was useful in almost every situation.”article, stated

Early prompts could produce code in the wrong programming language.

Root cause: At the top of a file, there was not enough context, so early models defaulted toward popular languages.

Resolution: The team added language headlines and later file paths to provide stronger language and domain cues.

3 supporting quotes
““You could be working in a C# project, then all of the sudden at the top of a new file, it would suggest Python code,” Rosenkilde explains.”article, stated
“at the top of the file, there could be some ambiguity, and those early models just defaulted to the top popular languages.”article, stated
““The end of the file name would give away the language in most cases, and in fact the file name could provide crucial, additional information,” Rosenkilde says.”article, stated

LLM quality is hard to debug with normal engineering traces.

Root cause: Helpfulness depends on statistical model behavior and the context served to a model with hundreds of billions of parameters.

Resolution: The team reframed debugging as asking the right questions and measuring accept/reject behavior against served context.

3 supporting quotes
“it’s hard to statistically define what constitutes a “good” response.”article, stated
“There’s no way for us to really troubleshoot in the typical engineering way”article, stated
“what we can do is figure out how to ask the right questions to get the output we desire.”article, stated

Specialized language models were not automatically better.

Root cause: The JavaScript-specific model had issues that the multilingual model avoided.

Resolution: GitHub adopted the multilingual Codex direction and kept working with successive OpenAI model drops.

“the Javascript model had particular problems that the multilingual model did not.”article, stated
“It actually came as a surprise to us that the multilingual model could perform so well.”article, stated

Offline coding-task tests became less useful as models improved.

Root cause: The models outgrew the initial crowdsourced self-contained problem set.

Resolution: The team shifted toward product metrics such as completion, acceptance rate, retained characters, and end-user quality improvements.

“The reason we don’t do this anymore is because the models just got too good”article, stated
“Completion refers to when users accept and keep GitHub Copilot suggestions in their code”article, stated

Evaluation

GitHub evaluated early model feasibility with crowdsourced self-contained coding problems, then evolved toward production completion metrics. The Model Improvements team monitors Copilot quality by watching whether users accept and keep suggestions, acceptance-rate lift, characters retained, model-drop effects, wrong-language failures, and whether prompt/fine-tuning changes improve real developer experience.

Metrics: self-contained coding problem solve rate · completion rate · acceptance rate · characters retained · wrong-language suggestions · user-visible quality changes after model drops · accept/reject analysis by served context

5 supporting quotes
“For the first form of evaluation, the GitHub Next team crowdsourced self-contained problems to help test the model.”article, stated
“In the beginning, the model could solve about half of the problems it was posed with, but soon enough, it was solving upwards of 90 percent”article, stated
“Completion refers to when users accept and keep GitHub Copilot suggestions in their code”article, stated
“That was a huge lift in our acceptance rate and characters retained.”article, stated
“Our greatest challenge right now is to consider why the user rejects or accepts a suggestion”article, stated

Outcomes

The case describes June 2020 GPT-3 exploration, a 2021 multilingual Codex model trained on billions of lines of public code, Codex with upwards of 170 billion parameters, solve-rate movement from about half to over 90 percent, a 24-hour model-drop experience, and three years of LLM/Copilot development.

5 supporting quotes
“But GPT-3 changed all that—suddenly the model was good enough to begin considering how a code generation tool might work.”article, stated
“The moment we did that and saw how well it worked, the whole static question-and-answer modality was forgotten”article, stated
“That was a huge lift in our acceptance rate and characters retained.”article, implied
“This was a huge boost in code acceptance because suddenly, GitHub Copilot knew about other files.”article, stated
“When the third iteration of Codex dropped, you could feel it, especially when you were working with programming languages that are not one of the top five languages”article, stated