Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:1ay1 Agentty rag cpp Runtime

From Leeroopedia
Knowledge Sources
Domains RAG, Information_Retrieval
Last Updated 2026-10-28 14:00 GMT

Overview

Retrieval pipeline runtime built on the rag-cpp submodule providing structure-aware chunking (tree-sitter), hybrid BM25+HNSW retrieval, reranking, MMR diversification, and sentence-level compression.

Description

This environment provides the rag-cpp external submodule's retrieval engine. The engine implements the full pipeline: structure-aware chunking via tree-sitter parsers (skip node_modules/.git), hybrid BM25 + HNSW vector search fused together, deterministic feature reranking, Maximal Marginal Relevance (MMR) diversification, near-duplicate removal, chunk stitching, and sentence-level compression to a byte budget. The adapter layer in `src/rag/adapter.cpp` wraps this behind agentty's `search_code` and `search_docs` tool interface.

= Usage

Use this environment for any Local_RAG_Retrieval workflow — both model-initiated search (the model calls search_code/search_docs) and proactive pre-turn retrieval (RagMode::On or FirstTurnOnly). It is the mandatory prerequisite for the rag_adapter implementation.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows Cross-platform via rag-cpp submodule
Hardware Any CPU Embedding model inference may benefit from SIMD
Disk Workspace-sized storage for index Index built from workspace source + docs

Dependencies

System Packages

  • tree-sitter (vendored via rag-cpp submodule)
  • No external system packages beyond C++ toolchain

Library Packages

  • `rag-cpp` submodule (vendored, compiled in-tree)
  • tree-sitter grammars (bundled with rag-cpp)
  • BM25 implementation (part of rag-cpp)
  • HNSW vector index (part of rag-cpp)
  • Embedding model (configured at runtime; local or remote)

Python Packages

None — rag-cpp is a C++ library compiled into the agentty binary.

Credentials

No environment variables required for the rag-cpp runtime itself. If using a remote embedding model endpoint, the relevant provider credential (e.g., `ANTHROPIC_API_KEY`) applies.

Quick Install

# rag-cpp is a vendored git submodule — no separate install needed.
# Ensure submodules are initialized:
git submodule update --init --recursive third_party/rag-cpp

# Build agentty (rag-cpp compiles in):
cmake -B build && cmake --build build -j$(nproc)

Code Evidence

Adapter interface from `src/rag/adapter.cpp` (search_code/search_docs):

namespace agentty::rag {

// search_code tool: run the full retrieval pipeline against the
// codebase index. Returns source-tagged snippets for model consumption.
ToolOutput search_code(std::string_view query);

// search_docs tool: same pipeline against documentation.
ToolOutput search_docs(std::string_view query);

} // namespace agentty::rag

Proactive retrieval mode from `include/agentty/domain/rag_mode.hpp:21-25`:

enum class RagMode : std::uint8_t {
    On = 0,        // proactive pre-turn retrieval on every turn
    FirstTurnOnly, // proactive retrieval only on a thread's first turn
    Off,           // no automatic retrieval (search_docs/search_code still work)
};

Pipeline stages (from adapter documentation):

// 1. Structure-aware chunking (tree-sitter, skip node_modules/.git)
// 2. Hybrid retrieval (BM25 + HNSW vector search, fused)
// 3. Deterministic feature reranking
// 4. MMR diversification + near-duplicate removal + chunk stitching
// 5. Sentence-level compression to byte budget
// 6. Format as ToolOutput with source tags

Common Errors

Error Message Cause Solution
`search_code returned no results` Index not built or empty workspace Ensure workspace has source files; index builds on first search
Submodule init failure rag-cpp submodule not initialized `git submodule update --init --recursive`
Embedding model timeout Remote embedding endpoint unreachable Check network connectivity or configure a local embedding model

Compatibility Notes

  • Tree-sitter grammars: Bundled with rag-cpp; no system tree-sitter installation required.
  • Index storage: Built in-memory or on disk depending on workspace size; no external database required.
  • Cross-platform: rag-cpp compiles on Linux, macOS, and Windows alongside agentty.
  • RagMode::Off: Search tools still work even when proactive retrieval is off — only automatic pre-turn injection is disabled.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment