What You’ll Build
A research agent that merges your internal data (from a vector store, database, or any retrieval system) with live web research from Tavily. You provide a simple RAG function — the agent identifies gaps in your internal knowledge and fills them with web data, producing a comprehensive report with citations.View Source on GitHub
Why Hybrid Research?
Your internal data is your competitive edge — customer records, product specs, domain expertise. But it’s never complete. Markets shift, competitors launch products, and your knowledge base can’t keep up. The hybrid approach gives you:- Grounded answers rooted in your proprietary data
- Complete coverage with real-time web context
- Enrichment opportunities by storing relevant web findings back into your knowledge base
Modes
- Fast Mode
- Multi-Agent Mode
Best for quick answers, lower latency, and cost-sensitive applications.
- Query your internal RAG
- Generate subqueries based on what’s missing
- Parallel web search with deduplication
- Synthesize everything into a report
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Tavily API key |
query | str | Required | The research question |
model_config | ModelConfig | Required | Your LLM configuration |
internal_rag_function | Callable | Required | Function that takes a query string and returns relevant context |
mode | str | "fast" | "fast" or "multi_agent" |
output_schema | OutputSchema | None | Pydantic model for structured output |
research_synthesis_prompt | str | None | Custom instructions for how the report is structured |
Return Value
Structured Output
Useoutput_schema to get consistent, parseable results:
Custom Synthesis
Guide how the report is structured withresearch_synthesis_prompt:
Data Enrichment Pattern
When your agent searches the web to fill knowledge gaps, those results are relevant to your users — otherwise the agent wouldn’t have needed them. This creates a flywheel:- Agent queries internal data and finds gaps
- Agent searches the web to fill gaps
- Web results get synthesized into the answer
- Store those web results internally for future queries
Implementing Your RAG Function
Theinternal_rag_function is simple: take a query, return relevant context as a string.
- Return 3-10 relevant chunks — enough context without overwhelming
- Include source metadata (file names, URLs, doc IDs) for traceability
- The hybrid researcher handles the rest: gap detection, web search, synthesis
Next Steps
Tools Reference
Deep dive into search_and_answer, search_dedup, and the other retrieval primitives.
Chatbot
See how the chatbot routes between quick search and deep research.