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.
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
backoffwill not appear. - A failed request is meaning. Vector search finds “try again”, “transient failure”, “exponential backoff”.
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:
COUNTandGROUP BYover 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”.
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.
-- 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_searchruns 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 undersrc/.GROUP BY dirthen counts distinct files in each directory.- The last argument,
k = 5000, is the candidate-set size for that aggregate.
cat code-context/README.md # the repo
code-context
The implementation, benchmark method, and raw results are in the repository.
ls agents/
- hybrid-search/ Why neither retriever is right on its own, and how rank fusion recovers what each one drops.
- queries/ The table-valued functions, and real queries: joins, full outer joins, and window functions over search results.
- object-storage/ The usual three-copy stack against one engine reading the files in place.
- patterns/ More retrieval patterns: scoped filters, CASE-routed verification, pinned snapshots.
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 →