Give AutoGen Agents Real-Time News Intelligence (Python, 2025)
2026-05-19 ยท 8 min read
Tutorial: wire wpnews into a Microsoft AutoGen multi-agent system. One tool registration gives every agent in your group chat live access to 70 pre-built news tools โ no prompt engineering required.
What you'll build
A Microsoft AutoGen multi-agent group chat where:
- A NewsAgent calls wpnews to fetch breaking stories, trending entities, and topic digests
- An AnalystAgent interprets the news and identifies business implications
- A SummarizerAgent produces a formatted briefing ready to send via Slack or email
One tool registration. No manual HTTP calls in your agents. 69 pre-built schemas auto-discovered.
Why AutoGen + wpnews?
AutoGen agents are stateless by default โ they don't know what happened in the news since their training cut-off. wpnews gives every agent in your group chat live access to AI and tech news through a single tool registration. The key insight: AutoGen's function calling means you register the tool once, and every agent in the group can use it.
The get_morning_briefing() call is especially useful โ it returns velocity status, hot articles, and trending entities in a single call, so your NewsAgent can make one call and hand structured context to the rest of the group.
Step 1 โ Install
pip install pyautogen wpnews
Get a free wpnews API key at wpnews.pro/api#get-key (1,000 calls/day free, no credit card).
Step 2 โ Define wpnews tools for AutoGen
import os
from wpnews import WPNews
client = WPNews(api_key=os.environ.get("WPNEWS_API_KEY", ""))
# โโ Tool functions โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def get_morning_briefing(hours: int = 6) -> dict:
"""Agent morning briefing: velocity status + breaking stories + trending entities."""
return client.get_morning_briefing(hours=hours)
def search_news(query: str, limit: int = 5) -> list:
"""Search AI and tech news by keyword."""
return client.search(q=query, limit=limit)
def get_topic_digest(topic: str, hours: int = 24) -> dict:
"""Get article digest for a specific topic (e.g. 'artificial-intelligence')."""
return client.get_agent_digest(lang="en", hours=hours)
def get_trending_entities(days: int = 7) -> list:
"""Get companies and people surging in AI news coverage."""
return client.get_trending_entities(days=days, limit=15)
# โโ AutoGen tool schema โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
WPNEWS_FUNCTIONS = [
{
"name": "get_morning_briefing",
"description": "Get today's AI news situational awareness: velocity (burst/normal/quiet), top breaking stories, and trending entities. Call this first.",
"parameters": {
"type": "object",
"properties": {
"hours": {"type": "integer", "description": "Look-back window in hours", "default": 6}
}
}
},
{
"name": "search_news",
"description": "Search recent AI and tech news by keyword or topic.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"},
"limit": {"type": "integer", "default": 5}
},
"required": ["query"]
}
},
{
"name": "get_trending_entities",
"description": "Get companies and people trending in AI news coverage this week.",
"parameters": {
"type": "object",
"properties": {
"days": {"type": "integer", "default": 7}
}
}
}
]
FUNCTION_MAP = {
"get_morning_briefing": get_morning_briefing,
"search_news": search_news,
"get_trending_entities": get_trending_entities,
}
Step 3 โ Create the agents
import autogen
LLM_CONFIG = {
"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}],
"functions": WPNEWS_FUNCTIONS,
}
# NewsAgent: calls wpnews tools to gather intelligence
news_agent = autogen.AssistantAgent(
name="NewsAgent",
llm_config=LLM_CONFIG,
system_message=(
"You are a news intelligence agent. When the group starts a briefing, "
"call get_morning_briefing() first to understand the current news climate. "
"If velocity is 'burst', search for the specific breaking stories. "
"Pass structured findings to AnalystAgent."
),
)
# AnalystAgent: interprets the news
analyst = autogen.AssistantAgent(
name="AnalystAgent",
llm_config={"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]},
system_message=(
"You are a business analyst. Receive news intelligence from NewsAgent "
"and identify the top 2-3 business implications. Be concise."
),
)
# UserProxy: executes function calls and manages the conversation
user_proxy = autogen.UserProxyAgent(
name="Coordinator",
human_input_mode="NEVER",
max_consecutive_auto_reply=5,
function_map=FUNCTION_MAP,
code_execution_config=False,
)
Step 4 โ Run the group chat
group_chat = autogen.GroupChat(
agents=[user_proxy, news_agent, analyst],
messages=[],
max_round=8,
)
manager = autogen.GroupChatManager(
groupchat=group_chat,
llm_config={"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]},
)
# Kick off the daily briefing
user_proxy.initiate_chat(
manager,
message="Run today's AI news briefing. Start with the morning briefing, then identify any breaking stories worth investigating.",
)
The group chat runs 8 rounds: NewsAgent fetches the data, AnalystAgent interprets it, and the Coordinator returns a structured briefing.
Full working script (under 100 lines)
"""
AutoGen + wpnews daily briefing agent
Run: OPENAI_API_KEY=... WPNEWS_API_KEY=... python autogen_news.py
"""
import os, autogen
from wpnews import WPNews
news = WPNews(api_key=os.environ.get("WPNEWS_API_KEY", ""))
def get_morning_briefing(hours: int = 6) -> dict:
return news.get_morning_briefing(hours=hours)
def search_news(query: str, limit: int = 5) -> list:
return news.search(q=query, limit=limit)
def get_trending_entities(days: int = 7) -> list:
return news.get_trending_entities(days=days, limit=15)
FUNCTIONS = [
{"name": "get_morning_briefing",
"description": "Daily AI news briefing: velocity + breaking stories + trending entities.",
"parameters": {"type": "object", "properties": {"hours": {"type": "integer", "default": 6}}}},
{"name": "search_news",
"description": "Search recent AI/tech news.",
"parameters": {"type": "object", "properties": {"query": {"type": "string"}, "limit": {"type": "integer", "default": 5}}, "required": ["query"]}},
{"name": "get_trending_entities",
"description": "Companies/people trending in AI news.",
"parameters": {"type": "object", "properties": {"days": {"type": "integer", "default": 7}}}},
]
LLM = {"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}], "functions": FUNCTIONS}
news_agent = autogen.AssistantAgent("NewsAgent", llm_config=LLM,
system_message="Call get_morning_briefing() first. If burst, search for breaking stories.")
analyst = autogen.AssistantAgent("AnalystAgent",
llm_config={"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]},
system_message="Identify the top 2-3 business implications from the news.")
proxy = autogen.UserProxyAgent("Coordinator", human_input_mode="NEVER",
max_consecutive_auto_reply=5,
function_map={"get_morning_briefing": get_morning_briefing,
"search_news": search_news,
"get_trending_entities": get_trending_entities},
code_execution_config=False)
gc = autogen.GroupChat(agents=[proxy, news_agent, analyst], messages=[], max_round=8)
mgr = autogen.GroupChatManager(groupchat=gc,
llm_config={"config_list": [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]})
proxy.initiate_chat(mgr,
message="Run today's AI news briefing. Start with morning briefing, then find breaking stories.")
Use all 69 tools automatically
Instead of defining tools manually, fetch all 69 pre-built schemas from the API:
import requests
# Fetch all 69 wpnews OpenAI-compatible schemas
all_tools = requests.get(
"https://api.wpnews.pro/api/v1/openai-tools.json",
headers={"X-API-Key": os.environ.get("WPNEWS_API_KEY", "")}
).json()
# Convert to AutoGen "functions" format
FUNCTIONS_ALL = [t["function"] for t in all_tools]
# Execute via the API tool resolver โ no local function stubs needed
def call_wpnews_tool(name: str, **kwargs) -> dict:
url_resp = requests.post(
f"https://api.wpnews.pro/api/v1/openai-tools/{name}/call",
json=kwargs,
headers={"X-API-Key": os.environ.get("WPNEWS_API_KEY", "")}
)
return url_resp.json()
Scheduling the briefing
To run this every morning automatically:
# crontab -e
0 8 * * 1-5 OPENAI_API_KEY=... WPNEWS_API_KEY=... python /path/to/autogen_news.py >> ~/briefings.log 2>&1
Or use a workflow scheduler (Prefect, Airflow, GitHub Actions cron) for more control.
Get your free wpnews API key
1,000 calls/day free. No credit card. AutoGen news agent ready in 5 minutes.
Get Free API Key โOr try keyless first: curl https://api.wpnews.pro/api/v1/morning-briefing