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:
- Early code-generation models had only recently become good enough to consider for real developer workflows.
- The product needed to fit into IDE interaction rather than a static chatbot modality.
- Prompt context had to improve completions without blindly sending excessive or irrelevant code.
- Quality measurement depended on whether developers accepted and kept suggestions, not just offline benchmark scores.
- The team had limited ability to debug a statistical model in the normal engineering way.
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
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
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
Models used: GPT-3 · Codex · Python-only OpenAI model · JavaScript OpenAI model · multilingual Codex model
Scale
- The earliest GPT-3 evaluation solved about half of the crowdsourced coding problems.“In the beginning, the model could solve about half of the problems it was posed with”article, stated
- The same style of test soon rose to more than 90 percent solved.“soon enough, it was solving upwards of 90 percent of the problems.”article, stated
- Codex was trained on billions of lines of public code.“it was trained on billions of lines of public code”article, stated
- The Codex model had upwards of 170 billion parameters.“train a model like Codex that contains upwards of 170 billion parameters.”article, stated
- One model deployment produced a noticeable improvement within the first 24 hours for F# use.“In the first 24 hours, we evidently had the old model for GitHub Copilot, but then BOOM! Magic happened”article, stated
- The article covers roughly three years of Copilot work with generative AI models.“After working with generative AI models and LLMs over the past three years, we’ve seen their transformative value up close.”article, stated
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
Send only the current file as model context.
Rejected because: Neighboring tabs and other IDE context gave the model stronger hints and improved acceptance.
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
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
Patterns
prompt-chaining (llmops)
Copilot turns IDE state into a carefully crafted pseudo-document before asking the model for code completion.
retrieval-ranking (context-engineering)
Copilot retrieves similar text from neighboring editor tabs and other open files to give the model more relevant local context.
fine-tuning-adaptation (model-development)
GitHub adapts Codex toward user-specific codebases and code-completion behavior through fine-tuning.
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
data-quality-loop (feedback)
The Model Improvements team studies why users accept or reject suggestions and what served context caused helpful or unhelpful output.
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.
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.
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
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
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.
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.
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
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
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
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.
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.
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
Outcomes
- GitHub pivoted from a coding chatbot prototype to IDE-integrated completion.
- Initial crowdsourced coding-task solve rates rose from about half to upwards of 90 percent.
- Neighboring-tab context produced a huge lift in acceptance rate and characters retained.
- Adding file paths solved wrong-language suggestions and improved quality by a surprising margin.
- A component that scanned other open IDE files gave Copilot awareness beyond the current file and boosted code acceptance.
- The third Codex iteration produced a user-visible quality jump, especially for languages outside the top five.
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.