TL;DR
CodeNib is a novel multi-view data system designed to efficiently serve repository context—such as lexical, semantic, and structural code details—to AI coding agents. By treating repository commits as immutable base data and using incremental updates alongside smart history compaction, CodeNib slashes agent token usage by 50–87% and accelerates context updates by up to $25\times$ without sacrificing code localization quality.
What Problem Does This Paper Address?
AI coding agents (like Devin or SWE-agent) spend a significant amount of time searching, navigating, and reading code within large, evolving repositories. However, existing agent runtimes rely on disconnected tools: standalone vector databases for semantic search, raw grep for lexical search, and live Language Server Protocol (LSP) instances for symbol navigation.
This fragmentation creates a major data-lifecycle coordination problem. Every time a repository changes, re-indexing the entire codebase becomes prohibitively expensive. Furthermore, agents often pass their entire messy, step-by-step exploration history back into the LLM prompt at every turn, leading to massive token bloat, high latencies, and soaring API costs.
Methods
CodeNib approaches repository context as a unified data-systems problem. Instead of collapsing all context into a single representation, it compiles three distinct, heterogeneous views for each repository commit:
- Lexical View: Text indexes (BM25 or Zoekt) for keyword and regex matching.
- Dense View: Code embeddings stored in FAISS for semantic retrieval.
- Structural View: Symbol containment and dependency graphs built using tree-sitter and SCIP.
All three views are linked via a central Repository Manifest ($M_c$) and mapped to a shared, repository-relative source range address space.
Incremental Maintenance
When a developer or agent modifies the code, CodeNib avoids full rebuilds. Instead, it uses Git diffs to perform view-specific delta maintenance:
- Vectors: Reuses content-addressed embeddings for unchanged files and only updates mutated chunks.
- Graphs: Employs LSP-assisted graph repair to delete invalid nodes/edges and re-wire modified symbols rather than parsing the whole repository from scratch.
Agent Runtime & Context Policies
CodeNib exposes these views to agents via standard Model Context Protocol (MCP) tools. Crucially, it introduces a Compact Context Policy. When an agent successfully reads a file, CodeNib deterministically rewrites the LLM's interaction history—pruning out the verbose intermediate search transcripts while preserving the core discovered code blocks and a small "direction cue."
Datasets
The authors evaluated CodeNib using two primary configurations:
- CodeNib Base: A dataset of 100 repository snapshots from 25 distinct repositories across five programming languages (C/C++, Go, Python, Rust, TypeScript/JavaScript), sampled from SWE-bench Verified and SWE-bench Multilingual.
- CodeNib Synthesis: A second-stage evaluation workload consisting of 500 tasks (25 snapshots $\times$ 20 queries each) evaluated across five prominent LLMs (including Claude 4.5 Haiku, Qwen3.5, Gemma, and Gemini) to generate 7,500 interaction trajectories.
Key Insights and Ideas
- Commits as Immutable Base Data: By treating a specific commit as immutable, CodeNib can safely materialize and cache diverse indexes behind a single manifest, allowing a query composer to execute optimized, hybrid retrieval plans.
- History Compaction is a Free Lunch: Agents don't need to remember how they found a file, only what they found. Deterministically cleaning up the prompt history after a successful file read maintains the agent's localization accuracy while drastically lowering token costs.
- The Language-Fidelity Tradeoff in Graph Repair: While incremental vector updates are robust across all languages, incremental graph repair is highly dependent on compiler/LSP determinism. Languages like Go and Python achieved perfect match rates, whereas Rust and TypeScript graphs occasionally diverged from a full rebuild due to subtle live-server state variations.
Key Results
- Drastic Update Speedups: Compared to rebuilding indexes from scratch, CodeNib’s incremental maintenance updates graphs $8.7\times$ faster and vectors $25.4\times$ faster at the median.
- Sub-Millisecond Navigation: For symbol navigation requests where static and live server outputs matched, CodeNib's static graph provider achieved a median $4.7\times$ latency reduction over a live JSON-RPC language server.
- Massive Token Savings: Across five different LLMs, CodeNib’s context delivery policies preserved code localization quality while using 50–87% fewer trajectory tokens compared to standard agent exploration (
grep/read).
Limitations and Future Work
While CodeNib excels at serving context for code localization, the authors note several boundaries:
- Scope Limits: The system focuses purely on context serving and localization; it does not generate patches or run test suites.
- Static vs. Live Discrepancies: Static navigation reproduced live server locations perfectly on 63.2% of requests but fell short on complex cross-file references (matching only 39% of the time). Runtimes requiring strict workspace semantics must still maintain a live LSP fallback.
- Future Directions: The authors plan to extend CodeNib into a full database service supporting concurrent agent writes, atomic cross-view version publication, and learned online query routing to automatically balance latency and quality budgets.
Summary updated