CodeSage: Code Intelligence for AI Agents, and Why I Rebuilt Its Models
说明与用途
CodeSage 通过重建 ONNX 图、添加侧车表加速删除、改进分块, 将大型仓库索引时间从约30分钟降至约6分钟,提升 AI 代理查询速度与准确性。
问题
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