CodeSage: Code Intelligence for AI Agents, and Why I Rebuilt Its Models
Описание и применение
CodeSage ускорил индексацию больших репозиториев, сократив время с 30 минут до 6 минут, за счёт пересборки ONNX‑графов, оптимизации SQLite‑удалений и улучшения чанкинга.
Задача
Indexing large codebases for AI agents was slow, causing stale answers and long wait times.
Результат
Indexing time cut by ~80 % across multiple repos; recall@10 unchanged or improved; agent queries now faster and more accurate.
Рабочий процесс
- Rebuild ONNX graphs for Jina embedder and ms‑marco reranker to fuse operations and use fp16.
- Add a sidecar table to index file paths for efficient deletes.
- Skip embedding of numeric‑heavy chunks and batch‑sort by length.
- Enable incremental indexing on git hooks to avoid full re‑index on every commit.
- Expose tools such as find_symbol, impact_analysis, search, from_trace, edit_check via MCP.
- Measure performance improvements and recall metrics.
- Publish rebuilt models on Hugging Face with byte‑for‑byte scripts.
- Update config.toml to pin derived models.
- Deploy updated CodeSage binary.
- Monitor agent usage and index freshness.
Доказательства
Full index of php-src took 1,782 seconds, just under half an hour, and I got tired of waiting.
CodeSage 0.38 does the same full index in 373 seconds.
The biggest single win wasn't a model. Most of the half hour was SQLite.
The fix is a small sidecar table, <chunk_table>_paths(id, file_path). Deletes now resolve the path to rowids and remove by rowid: 3.2 ms per file.
Measured on an RTX 4080 Laptop GPU with ONNX Runtime 1.24.4, 2,048 real chunks per corpus of up to 512 tokens each, compared against upstream fp32 with pooling done on the host.
- Дата записи: 2026-10-02T12:55:57.652Z