Skip to main content

Lightweight semantic code search and distillation utility for AI coding agents. It solves the API knowledge gap via real-time local signature extraction and intent analysis without PyTorch. Optimized for token efficiency, it compresses codebase context into compact semantic summaries stored in a local DuckDB vector similarity index.

Project description

Agent-CodeRAG: Semantic Intelligence for AI Coding Agents

Fast. Local. Agent-First. Token-Efficient.

Python 3.10+ License: MIT No PyTorch PRs Welcome


📖 Table of Contents


🧠 The Problem: The API Knowledge Gap

AI coding agents often hallucinate when calling library APIs because their training data is static. This leads to a "Fail-Fix-Fail" cycle:

  1. Broken Code: Agents use deprecated parameters or non-existent methods from outdated versions.
  2. Token Waste: You provide the error, the agent tries to fix it using more outdated data, consuming thousands of tokens in a loop.
  3. Environment Mismatch: The agent knows the API for version 1.0, but your environment has 2.0.

Real-world Example (The Pydantic Gap)

  • Agent's Knowledge: Knows Pydantic v1 (model.dict()).
  • Your Environment: Uses Pydantic v2 (model.model_dump()).
  • The Result: The agent writes dict(), the code fails, and it wastes 5000+ tokens trying to "fix" a problem it doesn't understand.

🚀 The Solution: Real-Time Contextual Truth

Agent-CodeRAG acts as a lightweight semantic bridge between your local environment and the LLM.

  • API Discovery: Extracts actual signatures from your installed libraries.
  • Semantic Retrieval: Provides the LLM with the exact Intent of your code units, indexed locally via ONNX.
  • Token Efficiency: Instead of sending whole files, Agent-CodeRAG distills code into compact semantic summaries, saving up to 80% of context window tokens.

🛠 How it Works

graph TD
    A[Local Python Code] --> B[AST Parser]
    B --> C{Delta-Sync}
    C -- Changed/New --> D[LLM Distiller]
    C -- Unchanged --> E[Local Cache]
    D --> F[Semantic Summary]
    E --> F
    F --> G[ONNX Embedder]
    G --> H[(DuckDB VSS)]
    H --> I[Semantic Search / JSON API]

✨ Key Features

  • ⚡ No PyTorch: Uses onnxruntime and tokenizers (Rust) for a tiny footprint and instant startup.
  • 💾 DuckDB VSS: High-performance vector similarity search stored in a single local file.
  • 🔄 Delta-Sync: Uses SHA-256 hashing to only re-distill changed code, saving your API budget.
  • 🔌 Hybrid Intelligence: Works offline using name-based embeddings; adds AI-distilled reasoning when an LLM is connected.

📡 API Discovery

To help your agent understand a specific library version installed in your environment:

agent-coderag api pydantic

Returns the live public API, methods, and signatures.


🏃 Quick Start

1. Install

pip install agent-coderag

2. Setup AI Models

Download the lightweight paraphrase-multilingual-MiniLM ONNX model to your global cache:

agent-coderag setup

3. Configure your LLM (For Distillation)

Option A: Cloud (OpenAI)

agent-coderag config --url "https://api.openai.com/v1" --model "gpt-4o-mini" --key "sk-..."

Option B: Local (Ollama) - Recommended

agent-coderag config --url "http://localhost:11434" --provider "ollama" --model "qwen2.5-coder:7b"

We recommend using qwen2.5-coder or llama3.2 for fast and private local distillation.

4. Index your Project

agent-coderag sync --all

5. Search

  • Human Mode (Compact): agent-coderag search "how to handle errors"
  • Agent Mode (JSON): agent-coderag --json search "data storage" --limit 1

🐳 Docker (Alternative)

docker build -t agent-coderag .
docker run -v ~/.cache/agent-coderag:/root/.cache/agent-coderag agent-coderag setup

🤖 For AI Agents

Agent-CodeRAG is built specifically for programmatic consumption.

Agent Strategy

  1. Search First: Use agent-coderag --json search "topic" to find relevant code units before reading files.
  2. Use Intent: The summary field provides technical intent, allowing you to skip reading complex implementation details.

🔧 Development

Running Tests

pytest tests/
pytest e2e_tests/

Pre-commit Hooks

We use pre-commit to maintain high code standards:

pip install pre-commit
pre-commit install

📄 License

MIT © 2026 Igor Boloban

🙏 Acknowledgments

This project stands on the shoulders of giants. See THIRD_PARTY_LICENSES.md for a full list of open-source libraries used in Agent-CodeRAG.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_coderag-1.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_coderag-1.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file agent_coderag-1.1.0.tar.gz.

File metadata

  • Download URL: agent_coderag-1.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_coderag-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fc715c957c21f7403a74d6704a52d645cdca7469f6e90d03e467c9466203e562
MD5 116b455e4035b49ed29cdfadd84294af
BLAKE2b-256 5590c2732e2daa8a02d284b5b135762b9273befbcebed6f9b3070c3f9c4f374b

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_coderag-1.1.0.tar.gz:

Publisher: release.yml on naranor/agent-coderag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_coderag-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_coderag-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_coderag-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3235487d5b20d314a25b997636e2a9c76c86f6bfcba729e2f67881da836dab2e
MD5 25f3741796e417ab6663571be748906f
BLAKE2b-256 7c3dae9ec472d88153122bf64906bc83ef3d96c7e5b9e915aa1213cc1f2c67f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_coderag-1.1.0-py3-none-any.whl:

Publisher: release.yml on naranor/agent-coderag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page