How It Works
Quick Start
1
Simple Usage
Enable reranking on the agent’s knowledge config:
2
With Configuration
Use
KnowledgeConfig for chunking, vector store, and rerank model:How It Works
Strategy selection scales with corpus size — see Retrieval Strategies.
Advanced: SmartRetriever
For direct control over retrieval strategy and filters, useSmartRetriever with a Knowledge instance:
Detect Retrieval Failures
An empty result can mean two very different things: the store is healthy but nothing matched, or the store is unreachable and the agent is about to answer from memory alone.RetrievalResult carries two fields that make the difference visible:
chunks stays [] on failure, so nothing downstream breaks — these two fields are the only way to tell “nothing matched” from “the store is down”.
The retriever logs at
ERROR on praisonaiagents.rag.retriever the first time a store call fails, so operators see it in application logs even when the caller only reads chunks. A later successful call clears the previous error.CLI Usage
Best Practices
Enable rerank for large corpora
Enable rerank for large corpora
Reranking adds latency but improves relevance once you have hundreds of chunks. Start with
rerank=True when answers feel noisy.Tune retrieval_k before reranking
Tune retrieval_k before reranking
Fetch more candidates (
retrieval_k=10–20) so the reranker has enough to choose from, then let the agent inject the top results.Use hybrid strategies at scale
Use hybrid strategies at scale
For technical docs with exact terms, rely on automatic strategy selection — hybrid and reranked modes combine keyword and semantic signals.
Scope by user or agent
Scope by user or agent
Pass
user_id or agent_id to SmartRetriever.retrieve() when isolating knowledge per tenant or sub-agent.Handle retrieval failure explicitly
Handle retrieval failure explicitly
Check
result.retrieval_failed before answering. When it’s True, tell the user the answer is not grounded in the knowledge base — or refuse — because a confidently wrong answer with no signal is exactly the failure this guards against.Related
Retrieval Strategies
Automatic strategy selection by corpus size
Retrieval Configuration
Configure retrieval behaviour on agents

