Code retrieval for AI agents: Why vector embeddings fail and per-file LLM graphs win

A year-long experiment building a code indexing system for AI coding tools yielded clear results: vector embeddings on code chunks and Tree-sitter AST parsing both have critical flaws, while per-file LLM analysis stored in a Neo4j graph with semantic fulltext search works best. The findings echo recent papers like RepoGraph (ICLR 2025) and Code-Craft.
Approaches tested
- Vector embeddings on code chunks – discarded entirely. A function named
process()in a payments service and one in an image pipeline embed to similar vectors, despite having nothing to do with each other. Vectors flatten call graphs, inheritance, imports — all structural relationships. Retrieval precision was unacceptable. - Tree-sitter AST parsing – precise and fast, but structural-only. It can tell you a function exists and what it calls, but cannot answer the question “this function handles webhook retries for failed Stripe payments.” Falls short when developers phrase questions in business language.
- Per-file LLM analysis → graph – works. Every file gets an LLM call generating
purpose,summary, andbusinessContext, stored as nodes in Neo4j with edges to classes, functions, keywords, and imports. Retrieval uses fulltext search across those semantic fields instead of vector similarity. SHA-256 diffing limits reindexing to changed files, making the upfront cost manageable.
Benchmarks from literature
RepoGraph (ICLR 2025) showed +32.8% improvement on SWE-bench with graph approaches. Code-Craft achieved +82% top-1 retrieval precision using bottom-up LLM summaries from code graphs.
Comparison to existing tools
The team published a side-by-side in comparison.md. Key differences:
- Bytebell: per-file LLM → purpose + summary + businessContext + entities; Neo4j + MongoDB storage; SHA-256 diff-aware reindex.
- PageIndex: TOC reasoning tree for long PDFs/docs; no code-specific semantics.
- GitNexus: Tree-sitter AST + community detection; optional per-symbol semantics; uses LadybugDB.
- GraphRAG: per-chunk LLM entities + community clustering for general text, not code.
- Sourcegraph/Cody: LSIF/SCIP search index; no per-node semantics; deployment is self-hosted or SaaS.
- Augment: proprietary semantic index with embeddings; SaaS-only; continuous indexing managed.
Open source
The system is open source at github.com/ByteBell/bytebell-oss.
📖 Read the full source: r/LocalLLaMA
👀 See Also

SpruceChat Runs 0.5B LLM On-Device on Miyoo Handhelds via llama.cpp
SpruceChat runs Qwen2.5-0.5B entirely on-device on handheld gaming devices using llama.cpp, with no cloud or WiFi required. On a Miyoo A30 (Cortex-A7 quad-core), it loads in ~60 seconds and generates at ~1-2 tokens/second.

Reflect MCP Server Implements Reflexion Paper for Persistent Coding Agent Memory
A developer implemented the Reflexion paper (Shinn et al., NeurIPS 2023) as an MCP server to give local coding agents persistent memory of their mistakes. The system uses regex-based pattern matching on error messages and stores lessons in SQLite with FTS5.

Proactive Context-Rot Detection in Claude Code: A Feature Suggestion from r/ClaudeAI
A Reddit feature suggestion proposes that Claude Code proactively detect context rot and offer a structured task-scoped handoff, generating a handoff file and spawning a new session automatically.

Local Trello-Style Project Manager for OpenClaw Agents
A developer built a local Trello-like project management tool that runs on the same machine as their OpenClaw agent, storing cards as markdown files with YAML frontmatter. The system uses Node.js/Express for the API, React for the UI, and allows the AI agent to read/write files directly on the filesystem.