Live web search and real-time news for LlamaIndex agents
Give a LlamaIndex FunctionAgent NestDaddy's news search and page reading as plain Python tools, with any model, including a free local one through Ollama.
LlamaIndex's FunctionAgent accepts plain Python functions as tools: it reads the docstring and type hints to tell the model what each tool does. Two functions give your agent today's news and the full text of any article.
Install
pip install llama-index-core llama-index-llms-openai-like requests
export NESTDADDY_API_KEY="your-key"
Get a key at nestdaddy.com/mcp (free plan: 1,000 calls a month, no card). Use llama-index-llms-openai instead if you run OpenAI models.
The tools
import os, requests
API = "https://nestdaddy.com/api/v1"
HEADERS = {"X-API-Key": os.environ["NESTDADDY_API_KEY"]}
def news_search(query: str, days: int = 3) -> list[dict]:
"""Search the latest news. Use it for anything that happened recently.
Args:
query: Short key words, like a search box.
days: How many days back to search, 1 to 30.
"""
r = requests.get(f"{API}/news/search", headers=HEADERS, timeout=30,
params={"q": query, "days": days, "limit": 5})
r.raise_for_status()
return [{"title": a["title"], "source": a.get("source_domain"),
"date": a.get("published_timestamp"), "url": a["url"]}
for a in r.json().get("results", [])]
def read_page(url: str) -> str:
"""Read the full text of a web page, for example a news article.
Args:
url: The full URL.
"""
r = requests.get(f"{API}/extract", headers=HEADERS, timeout=30, params={"url": url})
r.raise_for_status()
return r.json().get("text", "")[:4000]
The agent
This uses a free local model through Ollama's OpenAI-compatible endpoint (ollama pull qwen2.5:7b):
import asyncio
from datetime import date
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(model="qwen2.5:7b", api_base="http://localhost:11434/v1", api_key="ollama",
is_chat_model=True, is_function_calling_model=True, context_window=32000, timeout=180)
agent = FunctionAgent(tools=[news_search, read_page], llm=llm, system_prompt=(
f"Today is {date.today()}. Use your tools for anything recent. Search results are only headlines: "
"before you give details, read the best article with read_page. Only state facts you found, and cite the URLs."))
async def main():
print(await agent.run("What happened in AI today? Give 3 headlines with links."))
asyncio.run(main())
is_function_calling_model=True matters: without it, LlamaIndex does not send the tools to an OpenAI-compatible model.
What we got
Run on 14 November 2026 with llama-index-core 0.14 and qwen2.5:7b, the agent called news_search {'query': 'AI', 'days': 1} and answered with three of that day's AI headlines, each with its link.
For RAG over news instead of a tool-calling agent, fetch articles with the same API and load them as Documents; the LangChain guide shows the retriever pattern.
