Sourcegraph has launched the Cody Context Engine, a major upgrade to its AI coding assistant that indexes entire codebases into a persistent semantic graph. The system lets AI models answer questions across millions of lines of code without hitting context window limits — solving one of the biggest pain points in AI-assisted development.
The Problem It Solves
Every AI code assistant faces the same fundamental constraint: context windows. Even with Claude's 200K tokens or Gemini's 1M tokens, large enterprise codebases simply don't fit. Developers end up manually selecting which files to include, and the AI misses critical context from the rest of the codebase.
The Cody Context Engine takes a different approach. Instead of stuffing code into a prompt, it pre-indexes the entire repository into a semantic graph that maps code structure, function call chains, type hierarchies, dependency relationships, and usage patterns. When a developer asks a question, Cody queries the graph to retrieve exactly the relevant context — then passes only that context to the underlying LLM.
How It Works
The indexing pipeline runs in three stages:
- Structural indexing: Parses every file to extract symbols, types, function signatures, imports, and module boundaries
- Semantic embedding: Embeds code chunks and documentation into a vector space for similarity search
- Graph construction: Builds a dependency graph linking callers to callees, types to implementations, and tests to the code they cover
The graph updates incrementally on every commit, keeping the index current without full re-indexing.
Benchmarks
Sourcegraph tested the Context Engine against standard RAG-based retrieval (the approach used by most competitors) on three enterprise codebases:
| Codebase | Size | Context Engine Accuracy | Standard RAG |
|---|---|---|---|
| Stripe (monorepo) | 12M lines | 84% | 51% |
| Shopify (Ruby/TS) | 28M lines | 79% | 43% |
| Internal test repo | 50M lines | 72% | 38% |
Accuracy was measured as the percentage of developer questions answered correctly without manual file selection.
Pricing and Availability
The Context Engine is available today for Sourcegraph Enterprise customers and in beta for Cody Pro users ($19/month). It supports Claude Sonnet 4.5, GPT-5, and Gemini 3.1 Pro as backend models. The free tier of Cody includes graph-based context for repositories under 100,000 lines.
Why It Matters
The launch signals a broader shift in AI-assisted development: from "give the model more context" to "give the model better context." As codebases grow and AI models plateau on raw context length, intelligent retrieval systems like the Context Engine may prove more valuable than longer context windows.
Competitors are watching. GitHub confirmed that Copilot is "exploring similar graph-based approaches" for enterprise customers, and JetBrains said its AI Assistant would add codebase-wide indexing later this year.



