AutoRagAgent
AutoRagAgent is an agent wrapper that automatically decides when to retrieve context from knowledge bases versus direct chat, based on query heuristics.
Overview
AutoRagAgent wraps an existingAgent and adds intelligent retrieval decision-making:
- auto policy: Decides based on query keywords, length, and question marks
- always policy: Always retrieves context before responding
- never policy: Never retrieves, direct chat only
When to Use
Installation
Quick Start
API Reference
AutoRagAgent
Parameters
chat()
Parameters
RetrievalPolicy
AutoRagConfig
Examples
Basic Usage
Force/Skip Retrieval
Different Policies
With Hybrid Retrieval and Reranking
Async Usage
CLI Usage
Decision Heuristics
AutoRagAgent uses simple, local heuristics (no ML classifier) to decide when to retrieve:- Minimum length: Queries shorter than 10 characters skip retrieval
- Keywords: Queries containing keywords like “what”, “how”, “why”, “explain”, “find”, “search” trigger retrieval
- Question marks: Queries ending with ”?” trigger retrieval
Performance
- Import overhead: ~1.6ms (lazy loaded)
- Decision overhead: less than 1ms (local heuristics only)
- No ML classifier: Zero additional dependencies

