ModelRefs / Code Completion — AI Glossary

Code Completion — AI Glossary

Real-time suggestions of the next token, line, or function body as a developer types, integrated into IDEs. Also called autocomplete or code autocomplete.

Overview

Code completion is the core feature of AI coding assistants (GitHub Copilot, Codeium, Tabnine). Powered by code-specialized LLMs (StarCoder2, DeepSeek-Coder, Claude, GPT-4o) using FIM (fill-in-the-middle) for infilling. Latency target: <200ms for token-level, <1s for multi-line. Evaluated by acceptance rate and downstream developer productivity.

Reference details

Topicapplications
Also known asautocomplete, code autocomplete
Last reviewed2026-06-24

How it works

  1. The editor sends surrounding context on each trigger — the current file, the cursor position, and usually related open files or retrieved repository snippets.
  2. Because the cursor normally has code after it as well as before, the request is framed as fill-in-the-middle: prefix and suffix are both supplied and the model completes between them.
  3. A short, aggressively cached generation runs under a latency budget, since a suggestion arriving after the developer has typed past it is worthless however good it is.
  4. The output is truncated at a syntactic boundary and filtered — discarded if it duplicates what follows the cursor, fails to parse, or merely restates the suffix.
  5. Acceptance and near-immediate deletion are both recorded, because acceptance alone overstates value when developers accept and then undo.

Example: Why the latency budget shapes the model choice

A developer types around 5 characters a second, so roughly 200ms per character. A suggestion taking 800ms arrives about four characters after the context it was computed for, by which time the prefix has changed and it is often stale. That is the whole reason inline completion runs small specialised models rather than frontier ones: a weaker suggestion in 150ms is accepted more often than a better one in 900ms, and the trade is set by typing speed rather than by model quality.

Commonly confused with

Used interchangeably with code generation, and the unit of work differs. Completion predicts the next fragment from surrounding code with no stated intent, triggered by typing and measured in milliseconds. Generation takes an explicit instruction and produces a block, with a budget in seconds. A coding agent is further still: a goal, many steps, and its own test-and-fix loop. The three have different latency ceilings and different evaluation methods — acceptance rate for the first, correctness for the second, task resolution for the third — and treating them as one product is how teams end up measuring the wrong thing.

When to use it

Reach for it when:

  • Reducing keystrokes on predictable code — boilerplate, signatures, repeated patterns.
  • Surfacing an API shape in the flow of typing rather than in documentation.

Reach for something else when:

  • Work requiring a design decision, where the hard part is choosing rather than typing.
  • Changes spanning files, which the cursor's surrounding context cannot see.
  • Unfamiliar code where a plausible completion discourages the reading the developer needed to do.

Continue your research

Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Code Completion — AI Glossary.

Frequently asked questions

What is Code Completion?

Real-time suggestions of the next token, line, or function body as a developer types, integrated into IDEs.

Is Code Completion the same as autocomplete?

Yes — autocomplete, code autocomplete are common aliases for Code Completion.

What concepts are related to Code Completion?

Closely related concepts include fim, code generation, coding assistant.