Session

From Code to Graph: How CALLS/IMPORTS Edges Power 94% Token Savings in AI Coding

AI coding agents re-read entire files every time they need to understand your code. On a medium project, that is 45,000 tokens per query when the agent only needs 4,900. We built Code Context Engine, an open-source tool that uses a code knowledge graph with CALLS and IMPORTS edges to serve only the relevant code chunks.

The graph is central to retrieval quality. When a developer asks about a payment flow, the system finds the top-ranked chunks via hybrid vector and BM25 search, then walks CALLS/IMPORTS edges to pull in related functions from other files automatically. This graph expansion consistently surfaces code the vector search alone would miss.

The pipeline: tree-sitter AST parsing creates semantic chunks (functions, classes, modules). Each chunk becomes a node. Static analysis extracts edges (function calls, imports). Hybrid retrieval combines vector similarity with BM25 keyword matching via Reciprocal Rank Fusion. A confidence scorer blends vector distance, keyword match, and recency. File diversity filtering prevents one large file from dominating results.

Everything is stored in SQLite: sqlite-vec for vector search, FTS5 for keyword search, and a graph table for CALLS/IMPORTS edges. We chose SQLite over a dedicated graph database for simplicity (three files, zero infrastructure, 2 MB install vs 217 MB for LanceDB alone).

Benchmarked on FastAPI (53 files, 20 real queries): 94% token savings, 0.90 Recall@10, 0.4ms query latency. The graph expansion step alone improves recall by surfacing related files that pure vector search misses.

Attendees will learn how to model code as a graph, how graph edges improve retrieval beyond vector similarity, and practical trade-offs between SQLite graph tables and dedicated graph databases for developer tooling.

MIT-licensed: github.com/elara-labs/code-context-engine

Rajkumar Sakthivel

AI Systems Engineer | Building LLM Applications and Private Cloud at Scale | International Conference Speaker | Oxford

London, United Kingdom

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top