pub struct DeepResearchAgent<M: BaseChatModel> { /* private fields */ }Expand description
Multi-round deep research agent.
Decomposes a topic into sub-topics, searches in parallel, synthesizes a comprehensive report with citations, and iterates if gaps remain.
Implementations§
Source§impl<M: BaseChatModel> DeepResearchAgent<M>
impl<M: BaseChatModel> DeepResearchAgent<M>
Sourcepub fn new(llm: M) -> Self
pub fn new(llm: M) -> Self
Creates a new DeepResearchAgent with the given LLM.
At least one search tool must be added via with_searcher before
calling research.
Sourcepub fn with_searcher(self, tool: Box<dyn BaseTool>) -> Self
pub fn with_searcher(self, tool: Box<dyn BaseTool>) -> Self
Adds a search tool to the agent.
Multiple search tools can be added; all are queried in parallel.
Sourcepub fn with_max_rounds(self, n: usize) -> Self
pub fn with_max_rounds(self, n: usize) -> Self
Sets the maximum number of research rounds (default: 2).
Sourcepub fn with_max_subtopics(self, n: usize) -> Self
pub fn with_max_subtopics(self, n: usize) -> Self
Sets the maximum number of sub-topics to decompose (default: 5).
Sourcepub fn with_max_source_tokens(self, tokens: usize) -> Self
pub fn with_max_source_tokens(self, tokens: usize) -> Self
Sets the maximum number of tokens for source text in synthesis prompts.
When set, source snippets are truncated to fit within this budget.
Sourcepub async fn research(
&self,
topic: &str,
) -> Result<ResearchReport, ResearchError>
pub async fn research( &self, topic: &str, ) -> Result<ResearchReport, ResearchError>
Runs the full deep research pipeline on the given topic.
Returns a ResearchReport containing the markdown report,
citations, sub-topics, and round count.
Sourcepub async fn stream_research(
&self,
topic: &str,
) -> Result<Pin<Box<dyn Stream<Item = AgentStreamEvent> + Send>>, ResearchError>
pub async fn stream_research( &self, topic: &str, ) -> Result<Pin<Box<dyn Stream<Item = AgentStreamEvent> + Send>>, ResearchError>
Streams the deep research execution, emitting pipeline step events.
Emits AgentStreamEvent::PipelineStep events for planning, searching,
and synthesizing, and AgentStreamEvent::FinalAnswer when the report is ready.