Session

We Cut 94% of Our AI Coding Tokens With a Local Code Index. Here's the Architecture.

Every AI coding agent we've used does the same thing: reads your entire file for context. On our production codebase, that's 45,000 tokens per query. The agent only needed about 4,900. We didn't notice until the bill landed.

We built a local retrieval layer that sits between the codebase and the agent. Tree-sitter parses code into AST-aware chunks at function boundaries, not arbitrary token windows. Embeddings go into sqlite-vec. Retrieval combines vector similarity with BM25 keyword matching through Reciprocal Rank Fusion, because neither alone was good enough for code. A small knowledge graph tracks CALLS and IMPORTS edges so the agent can follow execution across files.

The part that took the longest to get right: confidence scoring. The system needs to know when its chunks are sufficient vs. when the agent should fall back to reading the full file. We tried threshold tuning, tried LLM-based judgment, and landed on a simple heuristic that outperformed both.

Everything runs locally. No cloud calls for indexing, no data leaving your machine. The embedding cache hits 96% on re-indexes. Secret redaction strips credentials before anything reaches the embedding model. One index serves Claude Code, Cursor, Gemini CLI, and Codex simultaneously through the Model Context Protocol.

I'll show live benchmarks, the architecture diagram, and the specific decisions we got wrong along the way, including why LLM-based chunk summarisation was slower and less accurate than simple truncation.

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