Advanced RAG expert covering agentic, graph, and multi-modal retrieval patterns, chunking strategies, hybrid search with re-ranking, evaluation metrics, and production optimization.
Ships in frootai-deploy-infra-skills. Installing the plugin adds it to Claude Code.
Advanced RAG expert covering agentic RAG, graph RAG, multi-modal patterns, chunking strategies, hybrid search with re-ranking, evaluation metrics, and production optimization.
| Pattern | When to Use | Complexity |
|---|---|---|
| Naive RAG | Simple Q&A, single source | Low |
| Advanced RAG | Hybrid search + re-rank + grounding | Medium |
| Agentic RAG | Multi-source, iterative, complex queries | High |
| Graph RAG | "What are the main themes?" global queries | High |
| Multi-Modal | Documents with images, charts, diagrams | High |
| Mistake | Why Wrong | Correct Approach |
|---|---|---|
| Same chunking for all content | Tables split, code broken, context lost | Adaptive: prose=semantic, tables=preserve, code=by function |
| Retrieves 20 chunks "for coverage" | Token waste, context dilution, LLM confused | Top 3-5 high-quality chunks > 20 mediocre ones — less is more |
| No re-ranking after retrieval | Initial retrieval is approximate, wrong order | Cross-encoder re-rank on top-50 → return top-5 precise results |
| Uses RAG for every question | "What is 2+2?" doesn't need retrieval | Agent classifies: retrieval-required vs direct-answer vs calculation |
| Evaluates only final answer | Can't tell if retrieval or generation failed | Evaluate separately: retrieval recall@K AND generation groundedness |
| Ignores "I don't know" | Forces answer from insufficient context | Abstention: "I don't have enough information" when confidence < 0.5 |
class AgenticRAG:
async def answer(self, query: str) -> str:
# Step 1: Classify query intent
intent = await self.classify_intent(query)
# "retrieval_required", "direct_answer", "calculation", "clarification_needed"
if intent == "direct_answer":
return await self.direct_answer(query)
if intent == "clarification_needed":
return "Could you clarify? Are you asking about {option_a} or {option_b}?"
# Step 2: Multi-source retrieval
sources = await self.select_sources(query) # ["docs", "api_reference", "faq"]
results = []
for source in sources:
chunks = await self.retrieve(query, source, top_k=3)
results.extend(chunks)
# Step 3: Re-rank across sources
ranked = await self.rerank(query, results, top_k=5)
# Step 4: Generate with grounding check
answer = await self.generate(query, ranked)
groundedness = await self.check_groundedness(answer, ranked)
# Step 5: Self-reflection — is answer sufficient?
if groundedness < 0.7:
# Iterative refinement: reformulate and retry
refined_query = await self.reformulate(query, answer)
return await self.answer(refined_query) # Recursive, max 2 iterations
return answer
from sentence_transformers import CrossEncoder
reranker = CrossEncoder("cross-encoder/ms-marco-MiniLM-L-6-v2")
def rerank(query: str, documents: list[str], top_k: int = 5) -> list[tuple[str, float]]:
"""Cross-encoder re-ranking for precise relevance scoring."""
pairs = [(query, doc) for doc in documents]
scores = reranker.predict(pairs)
ranked = sorted(zip(documents, scores), key=lambda x: x[1], reverse=True)
return ranked[:top_k]
# Pipeline: BM25 (1000) → Vector (100) → RRF Fusion (50) → Re-rank (5)
def evaluate_rag(test_cases: list[dict]) -> dict:
retrieval_metrics = []
generation_metrics = []
for case in test_cases:
# Evaluate retrieval quality
retrieved = retrieve(case["query"], top_k=5)
recall = len(set(retrieved) & set(case["relevant_docs"])) / len(case["relevant_docs"])
retrieval_metrics.append(recall)
# Evaluate generation quality (independent of retrieval)
answer = generate(case["query"], retrieved)
groundedness = evaluate_groundedness(answer, retrieved)
generation_metrics.append(groundedness)
return {
"retrieval_recall@5": sum(retrieval_metrics) / len(retrieval_metrics),
"generation_groundedness": sum(generation_metrics) / len(generation_metrics),
"diagnosis": "retrieval" if retrieval_metrics < 0.7 else "generation"
}
| Strategy | Token Size | Overlap | Best For |
|----------|-----------|---------|----------|
| Fixed-size | 512 | 128 | General prose, fast
| Semantic | Variable | Auto | Structured docs with headings |
| Sentence-window | 1 sentence | 3 surrounding | High-precision retrieval |
| Parent-child | 512 child, 2048 parent | None | Retrieve child, send parent as context |
| Late chunking | Full doc → embed → chunk | N/A | Maximum context preservation |
| Scenario | Use This Agent | Don't Use |
|---|---|---|
| Advanced RAG pattern design | ✅ | |
| Chunking strategy selection | ✅ | |
| Azure AI Search configuration | ❌ Use fai-azure-ai-search-expert | |
| RAG infrastructure (Bicep) | ❌ Use fai-rag-architect | |
| Embedding model selection | ❌ Use fai-embedding-expert |
| Play | How This Agent Helps |
|---|---|
| 01 — Enterprise RAG | Chunking, hybrid search, re-ranking, evaluation |
| 21 — Agentic RAG | Multi-source routing, iterative retrieval |
| 28 — Knowledge Graph | Graph RAG patterns, community detection |
What the agent file sets; muted values are Claude Code's defaults
rag, agentic-rag, graph-rag, chunking, re-ranking, evaluation
7-day visitors to each agent page
@agent-frootai-deploy-infra-skills:FAI RAG Expertfrom frootai-deploy-infra-skills
npx claudepluginhub frootai/frootai --plugin frootai-deploy-infra-skills327 agents in this plugin
AGENTSAGENTS.md — FrootAI Standalone Agents (Auto-Generated Catalog)> **GENERATED FILE — DO NOT EDIT BY HAND.** Re-run `node scripts/generate-agents-md.js` to refresh.FAI A2A ExpertAgent-to-Agent (A2A) protocol specialist — Google's agent interop standard, AgentCard discovery, task lifecycle, streaming artifacts, push notifications, and multi-agent communication patterns.FAI Accessibility ExpertAccessibility specialist — WCAG 2.2 AA/AAA compliance, ARIA 1.2 patterns, screen reader optimization, keyboard navigation, focus management, and inclusive design for AI chatbots and dashboards.FAI ADR WriterADR writer — documents architecture decisions with MADR 3.0 template, context, alternatives, trade-off matrices, consequences, and WAF pillar impact analysis.FAI Agentic RetrieverAgentic retrieval specialist — autonomous source selection, iterative refinement with relevance scoring, multi-hop reasoning, query decomposition, and grounded answer synthesis with inline citations.FAI AG-UI ExpertAG-UI protocol specialist — Agent-User Interaction standard, event-based rendering, streaming state updates, tool call lifecycle, and frontend integration for AI agent experiences.Other plugins' agents for the same job