Building RAG on Infino.

code-context is a RAG application built on Infino. The Claude MCP plugin handles chunking, model selection, ingestion, hybrid retrieval, and query formulation over a codebase. Use it to reduce your token costs, or point your agent at the repo to see how Infino's hybrid search makes it easy to build performant RAG apps.

CODE-CONTEXT VS. STOCK FILE TOOLS · BLENDED, 16Q tokens -32% 2.80M → 1.90M tool calls -53% 171 → 81 wall time -32% 1295s → 882s claude-sonnet-4-6 · same prompt · only the toolset differs github.com/infino-ai/code-context · docs/benchmark.md

infino explain rag # one sentence, five clauses

The question, in pieces

A coding agent might ask “How many files under src/ retry a failed request, by directory?”. The sentence combines retrieval, filtering, and aggregation.

  • How many is an aggregate: COUNT(DISTINCT path).
  • By directory is a GROUP BY. The result is a table of counts, not a hit list.
  • Under src/ is a prefix filter on path.
  • Retry is a token. BM25 ranks files that say it. Files that only say backoff will not appear.
  • A failed request is meaning. Vector search finds “try again”, “transient failure”, “exponential backoff”.
FIVE CLAUSES how many COUNT by directory GROUP BY under src/ prefix retry BM25 a failed request vector

infino explain stack # what each tool is for

Why that is three tools today

A conventional stack splits this question across a search engine, a vector database, and SQL.

  • The warehouse is for how many and by directory: COUNT and GROUP BY over files. That is the table of counts.
  • The search engine is for retry and under src/: a keyword query plus a prefix on path.
  • The vector database is for a failed request: files about the same idea even if they say backoff or “try again”.
SEPARATE SYSTEMS vector db failed request search engine retry + prefix warehouse GROUP BY dir 3 queries · 3 responses · merge WITH INFINO infino one SQL statement

With separate systems, the agent writes three queries, reads three responses, and merges the results. Infino expresses the same work in one SQL statement.

cx sql # search is a relation

Search as a table

BM25, vector search, and SQL share one query. Search runs as a table-valued function, so its results can be filtered, counted, joined, and grouped.

hybrid_search returns the chunk columns plus score. The query filters paths under src/, groups by directory, and uses a large candidate set because the search feeds an aggregate rather than a result page.

cx sql
-- How many files under src/ retry a failed request, by directory?
SELECT   split_part(path, '/', 2) AS dir,
         count(DISTINCT path) AS files          -- how many
FROM     hybrid_search('chunks', 'content',
                       'retry failed request',
                       'embedding', :q, 5000)     -- BM25 + vector, fused
WHERE    path LIKE 'src/%'                     -- prefix: under src/
GROUP BY dir                                     -- by directory
ORDER BY files DESC;

-- → one snapshot, one pass, one table of counts
  • hybrid_search runs BM25 and vector search concurrently over the same chunks table, then fuses the two ranked lists with reciprocal rank fusion.
  • WHERE path LIKE 'src/%' keeps the hits under src/. GROUP BY dir then counts distinct files in each directory.
  • The last argument, k = 5000, is the candidate-set size for that aggregate.

Why both retrievers →  ·  The full query surface →

cat code-context/README.md # the repo

code-context

The implementation, benchmark method, and raw results are in the repository.

code-context on GitHub →

cat FAQ.md

Why not grep and count?

Grep works for a known token. This question also needs a semantic match for “failed request”, a path filter, and a count grouped by directory. An agent can assemble that from repeated grep and read steps; one SQL query computes it over a single snapshot.

What is a table-valued search function?

hybrid_search (and bm25_search, vector_search) are relations. They take a table name, return that table’s columns plus a score, and belong in FROM. COUNT, WHERE, JOIN, and GROUP BY are ordinary SQL on top. k is recall, not page size.

Where do the embeddings come from?

Infino can embed text on ingest using the model selected for the table. You can also send vectors from your own model. code-context uses a local embedding model, so a coding agent does not need an external model key. Keyword search and SQL need no embeddings.

Does the benchmark hold up on other models?

The published benchmark uses claude-sonnet-4-6. The corpus, prompts, tool lanes, and raw results are documented in the code-context repository so the run can be reproduced on other models.

→ index created on s3://your-bucket · apache-2.0

Product analytics teams: agent observability →