Source Code:
src/gaia/code_index/ and src/gaia/agents/code_index/tools/mixin.pyLooking for the API? See the Code Index SDK Reference for
CodeIndexSDK, CodeIndexConfig, and CodeIndexToolsMixin.- Tool mixin —
CodeIndexToolsMixinpowers the flagship GAIA agent’scodingskill and is available to any custom agent that opts in viaKNOWN_TOOLS["code_index"]. - Python SDK —
CodeIndexSDKfor direct programmatic use.
gh is not required — the index covers source files only.
Overview
Setup
Install the[rag] extras (FAISS + numpy live there):
gaia init installs the server and pulls the model — gaia daemon starts and supervises it from there.
The embedder is
user.embeddinggemma-300m-GGUF (EmbeddingGemma 300M). A cached index (under ~/.gaia/code_index/) records the model it was built with, so an index built before v0.22.0 with nomic-embed-text-v2-moe-GGUF fails loudly with a model-mismatch error naming both models. Re-index to rebuild it with EmbeddingGemma.Using it from the flagship agent
Thecoding skill is what puts the code index in front of the flagship GAIA agent — it lists search_code_index among the tools a coding task needs, and directs the agent to run index_codebase once per repo before relying on semantic search. Ask the agent to work on a codebase and it calls these tools autonomously:
You don’t have to call
index_codebase first: the first search_code_index
in a repository with no index builds it, then searches. That first search is
slow on a large repository; a task that never searches never pays for the
embedding pass. Set GAIA_PROJECT_MAP_AUTO_INDEX=1 to build it in the
background at task start instead.
Example interaction
CodeIndexToolsMixin directly in their class declaration; it’s also registered in KNOWN_TOOLS["code_index"] (src/gaia/agents/registry.py) for dynamic resolution. For SDK-level composition see the SDK reference.
Using it from Python
For direct programmatic use (no agent), callCodeIndexSDK yourself:
CodeIndexConfig, CodeIndexSDK, and data-type reference.
Cache layout
Privacy
All processing is local. No source code is sent to external services. Sensitive filenames are skipped automatically:.env, .env.*, .htpasswd, SSH private keys (id_rsa, id_ed25519, …), and any *.pem, *.key, *.pfx, *.p12, *.jks, *.keystore.
Testing
The code-index stack has unit-test coverage intests/unit/test_code_index*.py — 64 tests spanning the SDK (cache layout, incremental re-index, atomic writes), the parsers (Python AST + the regex backends for JS/TS/Go/Rust/Java/C/C++), and the CodeIndexToolsMixin tool surface.
Run them with:
Real-world benchmark
Indexing the gaia repo itself against Lemonade Server’suser.embeddinggemma-300m-GGUF embedding model: