Agentic AI
SpIDER Method Boosts Code Search for AI-Powered Bug Fixing by Exploiting Codebase Structure
A new graph-aware retrieval technique helps LLM-based coding agents find relevant functions and files more effectively by leveraging the structural relationships within codebases.
When large language models try to fix bugs or add features to real-world software, they need to quickly pinpoint which functions and files matter for the task. Current retrieval strategies—whether keyword-based or vector-based—largely overlook how code is actually organized. Researchers have now developed a way to improve this process.
The Core Problem#
Finding the right code snippets within massive repositories is fundamental to LLM-assisted development workflows. Traditional methods like BM25 (keyword matching) and modern dense embeddings (semantic vector search) can each succeed on different queries, but both treat the codebase as a flat list rather than a structured graph. This means they miss important contextual clues about which pieces of code relate to one another.
SpIDER: Structure-Aware Search#
The new approach, called SpIDER (Spatially Informed Dense Embedding Retrieval), combines semantic search with explicit graph navigation. Rather than returning results based purely on similarity scores, it expands the candidate set by following edges in the code's dependency graph—such as function calls and class containment relationships. Each retrieved item comes with an audit trail showing why it was included: which piece of code led to it, and what type of relationship connects them.
The technique builds its graph on-the-fly from each repository's syntax tree, avoiding the need for expensive precomputation. This makes it practical for real development sessions.
Benchmark Results#
The researchers introduced SpIDER-Bench, a curated test suite drawn from multiple existing benchmarks and spanning Python, Java, JavaScript, and TypeScript projects. Across all languages and benchmarks, SpIDER improved retrieval recall (the fraction of relevant results found) by at least 13% when following containment relationships, and by at least 27% when also exploring function calls. In absolute terms, this meant increases of 0.05–0.12 in recall when staying within container edges, rising to 0.11–0.19 when traversing call-graph edges.
Implications#
By linking semantic similarity to structural reasoning, SpIDER makes code retrieval both more accurate and more interpretable. The auditable nature of results—showing why each candidate was included—may help developers understand and debug AI-assisted coding decisions, while the consistent gains across multiple languages suggest the approach generalizes well to different codebases and programming styles.

