HackerNews Team
Build a team that aggregates, curates, and analyzes trending HackerNews stories. This example combines multiple specialized agents to research topics, read articles, and generate comprehensive summaries with structured output.
What You'll Learn
By building this team, you'll understand:
- How to integrate multiple data sources (HackerNews API, web search, article readers)
- How to define structured output schemas using Pydantic models
- How to coordinate agents with specific instructions for complex workflows
- How to combine real-time data with web research for comprehensive analysis
Use Cases
Build news aggregation platforms, trend analysis systems, content curation tools, or automated newsletter generators.
How It Works
The team coordinates three specialized agents to create detailed articles:
- Discover: HackerNews researcher finds trending stories from HackerNews
- Read: Article reader extracts full content from story URLs
- Research: Web searcher finds additional context and related information
- Synthesize: Team combines all findings into structured articles with summaries and references
The team outputs structured data following a defined schema with title, summary, and reference links.
Code
1from typing import List23from kern.agent import Agent4from kern.models.openai import OpenAIResponses5from kern.team import Team6from kern.tools.duckduckgo import DuckDuckGoTools7from kern.tools.hackernews import HackerNewsTools8from kern.tools.newspaper4k import Newspaper4kTools9from pydantic import BaseModel101112class Article(BaseModel):13 title: str14 summary: str15 reference_links: List[str]161718hn_researcher = Agent(19 name="HackerNews Researcher",20 model=OpenAIResponses(id="gpt-5.2"),21 role="Gets top stories from hackernews.",22 tools=[HackerNewsTools()],23)2425web_searcher = Agent(26 name="Web Searcher",27 model=OpenAIResponses(id="gpt-5.2"),28 role="Searches the web for information on a topic",29 tools=[DuckDuckGoTools()],30 add_datetime_to_context=True,31)3233article_reader = Agent(34 name="Article Reader",35 role="Reads articles from URLs.",36 tools=[Newspaper4kTools()],37)3839hn_team = Team(40 name="HackerNews Team",41 model=OpenAIResponses(id="gpt-5.2"),42 members=[hn_researcher, web_searcher, article_reader],43 instructions=[44 "First, search hackernews for what the user is asking about.",45 "Then, ask the article reader to read the links for the stories to get more information.",46 "Important: you must provide the article reader with the links to read.",47 "Then, ask the web searcher to search for each story to get more information.",48 "Finally, provide a thoughtful and engaging summary.",49 ],50 output_schema=Article,51 markdown=True,52 show_members_responses=True,53)5455hn_team.print_response("Write an article about the top 2 stories on hackernews")What to Expect
The team will research HackerNews stories, read the full articles, and search for additional context. Each agent contributes their specialized capability: finding stories, extracting article content, and web research.
The output is a structured Article object with a title, comprehensive summary, and reference links. You'll see responses from all team members showing how they collaborate to gather and synthesize information.
Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export OPENAI_API_KEY=xxxInstall dependencies
1uv pip install -U kern-ai openai ddgs newspaper4k lxml_html_cleanRun Team
1python hackernews_team.py1python hackernews_team.pyNext Steps
- Modify the query to track specific topics or keywords on HackerNews
- Adjust the
Articleschema to include additional fields like categories or sentiment - Change the number of stories analyzed in the prompt
- Explore Input & Output for custom data schemas