Skip to main content

Real architecture · Senior

GitHub Copilot: context assembly

Real production architecture. Key points: prompt under a token budget, FIM, and acceptance rate.

17 min read · Source: GitHub Copilot · Content reviewed on October 23, 2026

Short answer

Real production architecture. Key points: prompt under a token budget, FIM, and acceptance rate. The GitHub blog describes GitHub Copilot as an AI pair programmer. It entered technical preview in June 2021 and became generally available in June 2022. The model behind it is Codex, a descendant of GPT-3.

01 · CONTEXT

An assistant that has to guess the context

The GitHub blog describes GitHub Copilot as an AI pair programmer. It entered technical preview in June 2021 and became generally available in June 2022. The model behind it is Codex, a descendant of GPT-3.

The central point of the case is context. The models fast enough for Copilot processed, at the time of the text, about 6,000 characters at a time, so not all of a person's code fits as context. The challenge, in the source's words, is deciding which data to send to the model and in what order to send it.

02 · PROMPT ASSEMBLY

The prompt is an assembly under a budget

According to the source, prompts are compilations of IDE code and relevant context sent to the model, generated by algorithms in the background at any point while typing.

  1. At any point while typing, the IDE triggers the assembly of a new prompt.

    Architecture diagram: Copilot: prompt assembly
    CLDeveloper IDEaciona
    CPPrompt library
    CHCache
    CPCode model
  2. The prompt library selects snippets of code and comments from the current file and from other sources.

    Architecture diagram: Copilot: prompt assembly
    CLDeveloper IDE
    CPPrompt libraryseleciona
    CHCache
    CPCode model
  3. The snippets are prioritized, filtered, and assembled into the final prompt, which must fit in the model's limited window.

    Architecture diagram: Copilot: prompt assembly
    CLDeveloper IDE
    CPPrompt libraryprioritizes and assembles
    CHCache
    CPCode model
  4. Optimized use of caching lets the assembly run in the background without extra latency.

    Architecture diagram: Copilot: prompt assembly
    CLDeveloper IDE
    CPPrompt library
    CHCacheavoids extra latency
    CPCode model
  5. The assembled prompt goes to the model, which generates the suggestion.

    Architecture diagram: Copilot: prompt assembly
    CLDeveloper IDE
    CPPrompt library
    CHCache
    CPCode modelgenerates the suggestion

Most of this work happens in what GitHub calls the prompt library, where ML experts and algorithms extract and prioritize the sources of information about the person's context. The first version considered only the file the person was working on.

03 · NEIGHBORING TABS AND FIM

Two techniques that expand the context

Neighboring tabs lets the system process all the files open in the IDE, not just the current file: it searches those files for snippets that match the code around the cursor and adds them to the prompt.

In A/B tests, a very low threshold for including a match gave the best suggestions. According to engineer Albert Ziegler, quoted in the text, including the best match found, even if not perfect, was better than including nothing.

Before FIM, only the code before the cursor, the prefix, went into the prompt. The code after the cursor, the suffix, was left out. With FIM, the prompt tells the model which part is the prefix and which is the suffix, and the suggestion becomes the code that should go between the two.

TechniqueWhat changes in the promptMeasured effect
Neighboring tabsSnippets from open files that match the code around the cursor are included5% relative increase in suggestion acceptance
FIMThe prompt marks what is the prefix and what is the suffix10% more completions accepted among those shown

According to the source, thanks to the optimized use of caching, both techniques run in the background without extra latency.

04 · SEMANTIC RETRIEVAL

The next step, still experimental: repository embeddings

The text describes experiments with vector databases for a personalized experience in private repositories or with proprietary code. Generative code tools use embeddings to retrieve information of this kind from such a database.

  1. In the proposed design, the indexer generates embeddings of all the repository's snippets, potentially billions.

    Architecture diagram: Copilot: semantic retrieval (experimental)
    DBRepository code
    CPIndexadorindexa
    CPEmbedding service
    DBVector database
    CLDeveloper IDE
    CPPrompt library
  2. The vectors are stored in the vector database.

    Architecture diagram: Copilot: semantic retrieval (experimental)
    DBRepository code
    CPIndexador
    CPEmbedding service
    DBVector databasestores the vectors
    CLDeveloper IDE
    CPPrompt library
  3. While programming, the IDE snippets also become embeddings.

    Architecture diagram: Copilot: semantic retrieval (experimental)
    DBRepository code
    CPIndexador
    CPEmbedding service
    DBVector database
    CLDeveloper IDEsends snippets
    CPPrompt library
  4. The vector database looks for approximate matches, not just exact ones, even with billions of stored snippets.

    Architecture diagram: Copilot: semantic retrieval (experimental)
    DBRepository code
    CPIndexador
    CPEmbedding service
    DBVector databaseapproximate search
    CLDeveloper IDE
    CPPrompt library
  5. In the diagram, the search result goes on to the prompt library.

    Architecture diagram: Copilot: semantic retrieval (experimental)
    DBRepository code
    CPIndexador
    CPEmbedding service
    DBVector database
    CLDeveloper IDE
    CPPrompt libraryreceives the result

The feature is designed for enterprise customers with private repositories who would explicitly opt in to use it. The source uses the conditional, and ZenML's analysis notes that it is described as experimental, with no performance data.

05 · LESSONS

What to take to a similar design

The source shows recurring practices: accepting weak matches rather than nothing, validating each technique by A/B testing suggestion acceptance, and sustaining low latency with cache.

Frequently asked questions

What is GitHub Copilot: context assembly?

Real production architecture. Key points: prompt under a token budget, FIM, and acceptance rate.

What does the GitHub Copilot: context assembly design cover?

It is organized in these sections: An assistant that has to guess the context, The prompt is an assembly under a budget, Two techniques that expand the context, The next step, still experimental: repository embeddings, and What to take to a similar design.

How long is GitHub Copilot: context assembly and what level is it?

It takes about 17 minutes to read and is rated Senior level.

Now design it yourself

Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.