cd /news/developer-tools/why-ai-coding-agents-get-lost-in-lar… · home topics developer-tools article
[ARTICLE · art-86511] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Why AI Coding Agents Get Lost in Large Codebases

Developer Siddhartha Katiyar built ContextOS, a local-first context engine that indexes software repositories using Tree-sitter and SQLite FTS5 to improve AI coding assistants' retrieval accuracy. In benchmarks against the Redis 7.x codebase, it achieved 98% file-level recall for exact-function queries while averaging just 589 tokens per query, and for React/Next.js frameworks it averaged ~280 tokens with 100% accuracy. The tool operates as a Model Context Protocol (MCP) server, compatible with Cursor and Claude Desktop.

read3 min views1 publishedAug 4, 2026

Modern large language models are becoming dramatically better at reasoning about code. Context windows are expanding from a few thousand tokens to millions. Yet, developers still struggle to get consistent, accurate answers from AI coding assistants when working on large, real-world repositories.

If you've ever watched an agent like Claude Desktop or Cursor try to debug a complex issue in a new repository, you've likely witnessed the "Grep Loop of Despair": grep -r "AuthService" .

cat

on three random files.The prevailing assumption has been that simply feeding more files into larger context windows will solve the problem. It hasn't.

This is not a model reasoning problem. It is a retrieval problem.

The standard architecture used by most AI retrieval systems today (RAG) follows a predictable pipeline: read the text, chunk it arbitrarily by character count, generate vector embeddings, and search via cosine similarity.

This architecture works remarkably well for documentation and corporate wikis. However, it degrades rapidly on software repositories.

When code is chunked by character count, function boundaries are destroyed. When retrieval relies solely on embeddings, deterministic symbol lookups become probabilistic guesses.

If a developer asks an AI assistant: "Where is the AuthMiddleware implemented?" they do not want AuthMiddleware

class. Immediately. Deterministically.I built ContextOS to solve this exact problem. It is a local-first context engine designed specifically to index and retrieve software structures for AI agents.

Instead of blindly chunking by characters, ContextOS parses the repository using Tree-sitter. It extracts functions, classes, interfaces, and methods as discrete, logical chunks. A 50-line function becomes a single chunk. The structural integrity of the code is preserved.

While embeddings are great at finding conceptual similarities, they struggle with exact symbol lookups. ContextOS flips the standard paradigm: it uses SQLite FTS5 (BM25) as the primary retrieval mechanism for deterministic lexical search, and falls back to a local MiniLM ONNX model for semantic matching only when necessary. Retrieving the right context is only half the problem. If you send 50 relevant chunks to an LLM, you dilute its attention. ContextOS implements a query-aware compiler that compresses context: the most important nodes are sent in full, while lower-scoring nodes are compressed into single-line stubs (e.g., interface User — path/types.ts:12-40

).

In a 100-query benchmark against the Redis 7.x C codebase, ContextOS achieved a 98% file-level recall for exact-function queries. Crucially, it did this while averaging just 589 tokens per query.

For modern web frameworks like React and Next.js, the context footprint drops even further—averaging just ~280 tokens per query with 100% accuracy. Token efficiency directly translates to lower latency, reduced API costs, and significantly less model confusion. A model analyzing ~300 highly relevant tokens will consistently outperform a model drowning in 40,000 tokens of noisy, full-file context.

ContextOS operates as a Model Context Protocol (MCP) server, meaning you can plug it directly into Cursor, Claude Desktop, and any other MCP-compliant client today.

Stop letting your AI drown in grep output. Give it the context engine it deserves.

Check out the repository on GitHub. Cover Photo by Fotis Fotopoulos on Unsplash

── more in #developer-tools 4 stories · sorted by recency
── more on @siddhartha katiyar 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-ai-coding-agents…] indexed:0 read:3min 2026-08-04 ·