Research Agent
The Research agent searches stored documents and synthesizes answers with citations. It is typically invoked standalone for ad-hoc queries, or conditionally after QA failure.
Tools
| Tool | API | Description |
|---|---|---|
search_store | Store.search() | Semantic similarity search |
get_document_info | Store.get_document() | Retrieve document metadata |
get_store_stats | Store.stats() | Aggregate store statistics |
Output: ResearchResult
class ResearchResult(BaseModel):
query: str
answer: str
citations: list[Citation]
documents_searched: int
reasoning: str
class Citation(BaseModel):
document_id: str
source_filename: str
chunk_index: int
text_snippet: str
score: floatHow It Works
- Receives a research query (either from QA failure context or direct user query)
- Calls
search_storewith the query embedding to find relevant chunks - Calls
get_document_infoto enrich results with document metadata - Optionally calls
get_store_statsfor context on corpus size - Synthesizes an answer grounded in the retrieved chunks
- Returns the answer with full citation chain
Standalone Usage
async with Orchestrator() as orch:
result = await orch.research("What are the payment terms in our contracts?")
print(result.answer)
for cite in result.citations:
print(f" [{cite.source_filename}] p.{cite.chunk_index}: {cite.text_snippet[:80]}")