repo-rag
Enables conversational queries about a GitHub user's profile, using lazy indexing and tool calls to retrieve repository info and file contents, with cached results for efficiency.
README
repo-rag
A chat agent over my own GitHub profile — ask it "has Aman used Kotlin?" or "is CareerSpire finished?" and it answers in synthesized prose with citations, backed by a tool-calling loop that decides for itself what to look up.
The interesting decision
Most personal-profile RAG demos batch-embed every repo upfront, then do plain vector search over the embeddings. This doesn't do that. At the scale of one person's GitHub account, pre-embedding everything is wasted work — most repos never get asked about, and the ones that do only need a few files read, not a full-repo index.
Instead, the LLM is given the responsibility of deciding what to explore:
- Tier 1 (always available, no embeddings needed): every repo's name, language, and a short description, loaded once per session.
- Tier 2 (on demand): the agent calls
search_indexfirst (checks a Postgrespgvectorcache — free, no API cost). If the cache is empty or thin, it falls back to live GitHub calls (list_repo_files/read_repo_file). Whatever gets read live is chunked, embedded, and written into the cache as a deterministic side effect — not something the LLM decides to do — so the next question about that repo is cheaper.
This is a cache-augmented, lazy-indexing agent, not classic batch RAG and not pure live
browsing either. Full reasoning: docs/LEARNINGS.md (§8-9), diagram in
docs/ARCHITECTURE.md.
Try it
CLI (streaming, human-in-the-loop confirmations, model routing all live here):
docker-compose up -d # Postgres + pgvector
uv sync
GROQ_MODEL=openai/gpt-oss-120b uv run repo-rag # interactive session
Renders live as it streams: tool calls as they happen (with args/latency), the
answer's tokens as they generate, and citations — not a wall of JSON. Any live GitHub
API call (list_repo_files/read_repo_file) pauses for a y/n/always confirmation
first — a human-in-the-loop gate; search_index/get_repo_status never pause,
they're cache-only. Structured logs go to repo-rag.log, not the terminal.
Web: docker-compose up --build runs the FastAPI app too, serving a minimal chat
UI at http://localhost:8000 (POST /ask non-streaming, POST /ask/stream for SSE —
the frontend uses the streaming one). No HITL here — pausing a live HTTP request for
out-of-band approval needs a different mechanism than the CLI's synchronous prompt;
accepted gap, not solved.
MCP: uv run repo-rag-mcp exposes the same four tools over the Model Context
Protocol (stdio transport) — usable from Claude Desktop, Claude Code, or any other
MCP client, independent of the Groq-specific agent loop above.
Does it actually work?
docs/eval/results.md — a golden set of real questions run against the live agent,
scored for correctness and groundedness (not vibes). Methodology and the deliberate
choice not to use an LLM judge: docs/eval/README.md.
What actually broke building this
docs/INCIDENTS.md — the real failures hit getting this running: a Postgres type-cast
bug, a Groq client rejecting a parameter it shouldn't have, a model that
deterministically mis-formats tool calls (not a flake — three different fix attempts
produced the identical failure before the real cause was found: the model, not the
prompt), and a token-budget collision that took several iterations to actually solve.
One of these — an error class the graceful-degradation handler didn't catch — was
found by running the eval harness, not by manual testing.
What's built, with a named limit
- Cache invalidation is SHA-based, not proactive. Every cached chunk stores the
GitHub blob SHA it was fetched at.
list_repo_filesreuses the tree listing it already has to compare live SHAs against cached ones and drops anything stale — no extra API calls, since GitHub returns blob SHAs for free. The limit: this only fires when the agent decides to list a repo's files again, not on every cachedsearch_indexhit. A repo that's re-committed but never getslist_repo_filescalled on it again keeps serving stale cached chunks. Renamed/deleted files also aren't caught — only SHA mismatches on paths that still exist.docs/INCIDENTS.md,PgVectorStore.invalidate_stale. - Rate-limit handling is tiered by wait length, not a queue. Groq returns a real
retry-afterheader. A short wait (its per-minute limit, resets in seconds) gets one bounded automatic retry. A long wait (its per-day quota, resets in minutes to hours — seedocs/INCIDENTS.md#10) fails fast with the actual wait time surfaced to the user, instead of either hanging the CLI for 20 minutes or pretending "try rephrasing" would help. What's still missing: no persistent retry queue across restarts. - Multi-provider fallback is an abstraction, not a wired second provider.
FallbackLLMClient(infrastructure/llm/fallback_client.py) tries a list of clients in order, falling through only on the long-waitRateLimitErrorcase above — no second provider's API key was available to actually wire one in, so it's ready-to-plug-in, tested against fakes, not proven against a real second provider. - Model routing is a two-tier cascade, not a learned router. The first turn of
every question uses a cheap/fast model (
llama-3.1-8b-instant); any turn after that (meaning a tool call was actually needed) escalates to the capable model. A real question mix showed a good fraction resolve with zero tool calls, i.e. cheaply. No complexity classifier, no cost tracking dashboard — just this one cascade point. - Human-in-the-loop only exists on the CLI. Live GitHub tool calls
(
list_repo_files/read_repo_file) pause for a synchronous y/n/always prompt there. The streaming HTTP route has no equivalent — pausing a request mid-stream for an out-of-band approval is a different, harder mechanism that wasn't built. - Streaming doesn't retry.
GroqLLMClient.chat_stream()skips the tool-use-failed/short-rate-limit retry logic the non-streamingchat()has, since retrying would mean discarding partially-streamed text. Accepted gap.
What's deliberately not built
- No hybrid search or reranking. Flat cosine similarity only. Fine at single-profile scale; would need revisiting at more repos or more ambiguous queries.
- No LLM-as-judge eval. Deterministic fact-presence scoring instead, to keep eval runs cheap and reproducible on a free-tier account. Trade-off: can't catch a confidently wrong answer that happens to contain the right keywords.
Docs
docs/PRD.md/docs/TRD.md— product and technical requirementsdocs/ARCHITECTURE.md— module map, data flowdocs/LEARNINGS.md— design reasoning for the cache-augmented approachdocs/INCIDENTS.md— real bugs, symptom → diagnosis → fixdocs/eval/— eval harness, methodology, resultsdocs/AI_ENGINEER_ROADMAP.md— what this project covers against the AI Engineer curriculum, and what's genuinely leftdocs/STATUS_AND_NEXT_STEPS.md— what's working (verified, not assumed), what's left to close the zero-to-AI-engineer roadmap, what comes after
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。