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.
ResearchContext is the shared memory object threaded through every stage of a research session. It accumulates the search queries that have been run, the credibility scores of discovered sources, the cleaned text of fetched pages, and the gap analysis results. Passing a single ResearchContext instance to search_web, fetch_page, and run_tool_use_loop ensures that work is never duplicated — cached pages are returned instantly, scored sources are stored once, and follow-up queries build on the same knowledge base as the primary search.
Constructor
The original research question for this session. Stored as
context.question and used by add_search_results to score incoming
sources for relevance to this specific query.Attributes
The following public attributes are available on everyResearchContext instance. They are populated progressively as the pipeline advances.
| Attribute | Type | Description |
|---|---|---|
question | str | The original research question passed to the constructor |
queries_made | list[str] | Deduplicated list of all search queries run in this session |
source_metadata | dict[str, dict] | URL → {title, snippet, score, fetched} for every discovered source |
sources_fetched | dict[str, str] | URL → cleaned page text for every successfully fetched page |
established_facts | list[str] | Deduplicated list of facts stored during the session |
plan | dict | None | The research plan from plan_research(), or None before planning |
gaps | list[str] | Gap descriptions from find_gaps(), populated after the primary search phase |
follow_up_queries | list[str] | Follow-up query strings from find_gaps(), used in the secondary search phase |
source_metadata entry shape
Each value in source_metadata is a dict with these keys:
| Key | Type | Description |
|---|---|---|
title | str | Page title from the DuckDuckGo result |
snippet | str | DuckDuckGo-provided text excerpt |
score | float | Credibility score [0.0, 1.0] computed by score_source() |
fetched | bool | True once add_fetched_page has been called for this URL |
Pipeline Flow
ResearchContext is populated in stages that mirror the research pipeline:
Methods
add_query()
queries_made. Duplicates are silently ignored, so it is safe to call this multiple times with the same string.
The search query string to record.
add_search_results()
source_metadata, scoring each URL with score_source(). URLs already present in source_metadata are skipped to avoid overwriting existing scores.
A list of result dicts as returned by
search_web(), each containing
title, url, and snippet keys.The research question used to compute relevance scores. Pass
context.question to score against the original session question.add_fetched_page()
source_metadata[url]["fetched"] as True. Called automatically by fetch_page() after a successful retrieval.
The URL of the fetched page.
The cleaned, truncated text content of the page.
is_fetched()
True if url has already been fetched and cached in this session. Used by fetch_page() to short-circuit redundant network requests.
The URL to check.
bool
get_fetched_content()
url, or an empty string if the URL has not been fetched yet.
The URL whose content to retrieve.
str — Cleaned page text, or "" if not in cache.
get_score()
source_metadata, the stored score is returned immediately. Otherwise, score_source() is called with an empty snippet to compute and cache the score.
The URL to score.
float — Credibility score in [0.0, 1.0].
add_established_fact()
established_facts. Duplicates are silently ignored.
A concise statement of an established finding from the research session.
get_all_sources()
format_citations() or for building a sources section in a custom report.
Returns: list[dict] — Each entry contains:
| Key | Type | Description |
|---|---|---|
url | str | The source URL |
title | str | Page title |
score | float | Credibility score |
fetched | bool | Whether the page content was retrieved |