prebuilt.tldr2.agent¶

News Research Agent implementation.

This module implements the main NewsResearchAgent class that orchestrates the entire news research workflow using the Haive framework.

The agent follows a multi-stage workflow: 1. Generate search parameters 2. Search for articles 3. Extract article content 4. Select relevant articles 5. Summarize articles 6. Analyze findings 7. Generate report

Example

>>> from news_research.agent import NewsResearchAgent
>>> agent = NewsResearchAgent()
>>> state = NewsResearchState(research_topic="AI in healthcare")
>>> result = agent.invoke(state)
>>> print(result.report.to_markdown())

Note

The agent uses declarative configuration with engines handling all LLM interactions and state management.

Classes¶

NewsResearchAgent

News Research Agent for comprehensive article research and analysis.

Functions¶

research_topic(topic[, max_sources, max_search_iterations])

Convenience function to research a topic.

Module Contents¶

class prebuilt.tldr2.agent.NewsResearchAgent¶

Bases: haive.agents.base.agent.Agent

News Research Agent for comprehensive article research and analysis.

This agent implements a complete news research workflow that finds, analyzes, and reports on news articles for any given topic.

The agent uses multiple specialized engines for different tasks: - Search engine: Generates NewsAPI search parameters - Extraction engine: Coordinates content extraction - Selection engine: Chooses most relevant articles - Summary engine: Creates article summaries - Decision engine: Controls workflow logic - Analysis engine: Synthesizes findings - Report engine: Generates final report

engines¶

Dictionary of specialized engines

state_schema¶

NewsResearchState for workflow data

max_search_iterations¶

Maximum search attempts

min_articles_for_analysis¶

Minimum articles needed

Example

>>> agent = NewsResearchAgent()
>>> state = NewsResearchState(
...     research_topic="Impact of AI on healthcare",
...     max_sources=20
... )
>>> result = agent.invoke(state)
>>> print(f"Report: {result.report.title}")
>>> print(f"Analyzed {result.report.sources_count} sources")
build_graph()¶

Build the news research workflow graph.

Creates a graph that orchestrates the research workflow through multiple stages with conditional routing based on results.

Returns:

Configured workflow graph

Return type:

BaseGraph

Workflow:
START -> search -> extract -> select -> summarize -> decide

<——————————————–|

v

analyze -> report -> END

get_research_summary(state)¶

Get a summary of the research process.

Parameters:

state (haive.prebuilt.tldr2.state.NewsResearchState) – Final workflow state

Returns:

Dictionary with research summary statistics

Return type:

Dict[str, Any]

Example

>>> summary = agent.get_research_summary(result_state)
>>> print(f"Analyzed {summary['articles_analyzed']} articles")
prebuilt.tldr2.agent.research_topic(topic, max_sources=10, max_search_iterations=3)¶

Convenience function to research a topic.

Parameters:
  • topic (str) – Research topic

  • max_sources (int) – Maximum sources to check

  • max_search_iterations (int) – Maximum search attempts

Returns:

NewsResearchState with complete results

Return type:

haive.prebuilt.tldr2.state.NewsResearchState

Example

>>> result = research_topic("AI in healthcare", max_sources=15)
>>> print(result.report.to_markdown())