Documentation Index
Fetch the complete documentation index at: https://mintlify.com/IconDean/research-agent/llms.txt
Use this file to discover all available pages before exploring further.
AgentRunner is the central entry point for Deep Research Agent. It manages the full research lifecycle — from planning and multi-phase web search to gap analysis and final report synthesis — using Google Gemini as the underlying language model. Once instantiated, a single call to research() is all that is needed to produce a structured, cited markdown report from a natural-language question.
Constructor
api_key is omitted, the constructor reads from the GEMINI_API_KEY environment variable. Raises ValueError if no key is available.
Your Google Gemini API key. Defaults to the
GEMINI_API_KEY environment
variable when not supplied. Raise ValueError is thrown if neither is set.The LLM provider to use. Currently only
"gemini" is supported; this
parameter is reserved for future extensibility. Defaults to "gemini".Methods
research()
- Plan —
plan_research()breaks the question into typed sub-queries. - Primary search — Tool-use loop performs web searches and page fetches.
- Gap analysis —
find_gaps()identifies unanswered areas. - Follow-up search — A second tool-use loop covers the identified gaps.
- Synthesis —
ReportGeneratorassembles the final cited report.
The natural-language research question. Recommended length is 3–2 000
characters. For example:
"What are the environmental impacts of deep-sea lithium mining?".Optional callback invoked throughout execution. Receives two string
arguments:
event_type and detail. See the progress event table below.str — A complete markdown research report with inline citations.
Raises: ValueError if GEMINI_API_KEY is not set.
Progress Events
Theon_progress callback fires with the following (event_type, detail) pairs in order:
event_type | detail example | When fired |
|---|---|---|
"start" | The original question string | Research begins |
"thinking" | "Creating research plan..." | Before plan generation |
"plan" | "Type: factual, Strategy: breadth-first, Queries: Q1, Q2" | Plan created |
"thinking" | "Iteration 1" | Each tool-use iteration |
"search" | The query string sent to DuckDuckGo | Each web search |
"fetch" | The URL being retrieved | Each page fetch |
"block" | "https://example.com (score: 0.32)" | A URL blocked by credibility filter |
"gaps" | "Gaps found: 2, Follow-up queries: ..." | After gap analysis |
"thinking" | "Synthesizing final research report..." | Before synthesis |
"done" | "Research complete." | Pipeline finished |
Usage Example
plan_research()
research() during Stage 1, but also available for direct use when you want to inspect or customize the plan before executing it.
The research question to plan for.
dict with the following keys:
| Key | Type | Description |
|---|---|---|
question_type | str | One of "factual", "comparative", "exploratory", or "technical" |
search_strategy | str | Textual description of the search approach, e.g. "breadth-first" |
prioritized_sub_queries | list[dict] | Ordered sub-queries, each with query (str), priority ("High" | "Medium" | "Low"), and reasoning (str) |
find_gaps()
The original research question.
A string summary of the intermediate findings accumulated in the primary
search phase — typically the output of the first
run_tool_use_loop() call.dict with the following keys:
| Key | Type | Description |
|---|---|---|
gaps | list[str] | Descriptions of unanswered areas or missing information |
follow_up_queries | list[str] | New search query strings to fill those gaps |
{"gaps": ["Unclear findings"], "follow_up_queries": []} if parsing fails.
run_tool_use_loop()
search_web, fetch_page, score_source), and feeding results back until Gemini returns a plain-text response or max_iterations is reached. The research() method calls this twice: once for the primary search phase and once for the follow-up gap-filling phase.
The active session memory object. Caches fetched pages, tracks credibility
scores, and accumulates source metadata across iterations.
The Gemini system prompt for this research phase. Controls the model’s
role and research behavior during the loop.
The user-facing prompt for this phase, typically constructed from the
original question and the current set of sub-queries.
Optional progress callback forwarded to
search_web and fetch_page
during tool execution. Same signature as in research().Maximum number of tool-call iterations before the loop terminates.
Defaults to
5 (equivalent to MAX_ITERATIONS // 2). Increasing this
allows deeper exploration at the cost of latency and token usage.str — The final plain-text output from Gemini, representing an intermediate findings summary for this phase.
ResearchAgent
ResearchAgent is a subclass of AgentRunner provided for backward compatibility. It exposes an identical interface and can be used as a drop-in replacement wherever AgentRunner is referenced.
ResearchAgent exists solely to avoid breaking existing integrations. New
code should use AgentRunner directly. Both classes share 100% of their
implementation — there is no behavioral difference.