Every coding agent has to answer one question before it can edit anything: where is the relevant code? Model selection gets the headlines, but retrieval decides whether the model ever sees the function it needs. In late 2026, the major tools answer that question in four structurally different ways: a pre-built embedding index, a live agentic search loop, a static structural map, or symbol-level language server tools. Each has a different bill attached, in latency, tokens, freshness and privacy.

Strategy one: build an index before you ask
Cursor treats codebase understanding as a semantic search problem. When you open a project it splits changed files into syntactic chunks, embeds them in the background, and stores the vectors remotely so queries return ranked file paths and line ranges. Raw source is not kept in the vector database; the client reads the matched chunks locally and sends them up only when needed.
The engineering effort goes into keeping that index fresh and cheap. Cursor syncs against a Merkle tree of file hashes, so only edited files are reprocessed, and it caches embeddings by chunk content. Because clones of the same repo inside a company average 92% similarity, Cursor finds a teammate's near-identical index via a similarity hash and copies it, cutting time-to-first-query at the 99th percentile from 4.03 hours to 21 seconds. Cursor claims its semantic search raises agent response accuracy by 12.5% on average. That is the vendor's own evaluation, but it is the clearest published quantification of what indexing buys.
GitHub Copilot runs the same category of system. GitHub builds a per-repository semantic index from the default branch, shared by everyone with repo access, and in September 2025 disclosed a custom code-tuned embedding model behind it, claiming a 37.6% lift in retrieval quality, roughly 2x throughput, and an 8x smaller index. The known limitation is staleness by design: the remote index tracks the default branch, so code that exists only in your uncommitted working tree is found through a separate, shallower local path.
Windsurf, now under Cognition, also shipped a RAG-based context engine. More interesting is what Cognition did on top of it. The company observed that agent trajectories were often spending more than 60% of the first turn just retrieving context. Its answer, SWE-grep, is a small retrieval model fine-tuned with reinforcement learning on real agentic trajectories, served as a "Fast Context" subagent that Cognition says returns relevant code chunks up to 20x faster than the frontier model searching by itself.
Strategy two: no index, just grep
Claude Code takes the opposite position. Boris Cherny, one of its creators, said on the Latent Space podcast in May 2025 that an early version indexed the codebase with Voyage embeddings, and after trying several retrieval setups the team settled on "agentic search": the model calls glob, grep and read repeatedly until it finds what it needs. The argument, echoed by practitioners who compared the approaches, is that code search is mostly exact-symbol search. Grep returns every match instead of a top-K guess, always queries the latest bytes on disk so there is no index to keep in sync, and keeps the repo on your machine.
There is now a peer-reviewed version of that claim. An Amazon Science team (paper "Keyword search is all you need", accepted at AAAI 2026, arXiv 2602.23368) compared tool-augmented agents using only keyword search against a conventional vector-DB RAG pipeline and found the agent approach attains over 90% of RAG's performance without a standing vector database. Note the scope: document question-answering, Claude 3 Sonnet as the model, and a tradeoff the authors acknowledge, namely that the agent spends more inference calls on retrieval.
That tradeoff is the grep camp's weak spot. Zilliz, which sells a vector-search MCP plugin called Claude Context, argues grep-only search "burns too many tokens", and claims its semantic layer cuts token usage by 40% or more. Vendor numbers again, but the direction is real: multi-turn search loops consume context and time that a pre-computed index does not. Cognition's 60%-of-first-turn figure is evidence for the same point from inside the agent camp.
Strategy three: map the structure, skip retrieval
Aider never builds a query-time retrieval system. Its "repo map" parses every file with tree-sitter, extracts definitions and references, builds a dependency graph, and runs a PageRank-style ranking to pick the most central symbols that fit a token budget, 1,000 tokens by default, expanded dynamically when the chat needs a wider view. The model sees signatures and key lines from across the whole repo on every turn, and asks for specific files when it needs bodies. Tree-sitter's incremental parsing keeps this cheap, and its error-tolerant ASTs mean half-written files still get mapped. This is neither search nor embeddings: it is a standing structural summary, strong for orientation, weak when the answer is deep inside an unmapped function body.
Strategy four: hand the agent an IDE's brain
Serena, an open-source MCP toolkit, wires the language server protocol into the agent loop. Instead of text matching or similarity search, the agent calls IDE-grade operations: find symbol, find references, rename, replace symbol body, backed by real compilers' front ends for 40+ languages. The retrieval is exact and structure-aware by construction, and editing at symbol level avoids the brittle line-number math that text search-replace depends on. The cost is operational: a language server per language must be installed, running, and kept warm, and the approach buys nothing for prose, configs or unfamiliar languages without a good LSP.
What actually differs

Read across the four designs and the real axes are:
- Freshness. Grep, LSP and repo maps see the working tree as it is. Remote indexes lag by design (Copilot's default branch, Cursor's background chunking).
- Query type. Exact symbols favor grep and LSP. Conceptual questions ("where is auth handled") favor embeddings. Aider's map splits the difference by showing everything shallowly.
- Cost locus. Indexes pay upfront in compute and sync; agentic search pays at inference in tokens and turns. The Amazon paper found the agent recovers most RAG accuracy but spends more calls doing it.
- Privacy surface. Embeddings and obfuscated paths leave the machine in the hosted-index designs; the grep and LSP lanes keep content local.
- Multi-hop reasoning. Only loops (agentic search, LSP tool calls) follow a reference chain three hops deep in one task; one-shot retrieval cannot.
The market is converging on hybrids rather than picking a winner: Cursor publishes a bespoke regex engine for its agent's search tool alongside its semantic index; Cognition wraps agentic-style retrieval in dedicated small models; Claude users bolt vector search on via MCP while Anthropic ships agentic search natively. For a working rule of thumb: if the repo churns hourly and tokens are cheap to you, grep-based agents are hard to beat; if you live on conceptual questions over a stable large codebase, an index earns its sync bill; if your agent edits across files routinely, give it symbol-level tools regardless of which retriever it already has.
Sources
- Cursor: Securely indexing large codebases
- Cursor: Fast regex search, indexing text for agent tools
- GitHub Blog: Copilot gets smarter at finding your code
- Cognition: Introducing SWE-grep and SWE-grep-mini
- Devin Docs: Fast Context
- arXiv 2602.23368: Keyword search is all you need
- Amazon Science publication page
- Milvus blog: Why I'm Against Claude Code's Grep-Only Retrieval
- labuladong: Why Don't Coding Agents Use RAG to Search Code?
- Aider docs: Repository map
- Anish Gandhi: How Aider's repomap uses PageRank
- oraios/serena on GitHub
