LangGraph Research Agent with Search Grounding
LangGraph agents without search grounding hallucinate 15-30%. Adding a search tool node reduces factual errors to under 5% with 20 lines of Python.
LangGraph research agents without search grounding hallucinate facts at a 15-30% rate depending on the domain. Adding a search tool node reduces hallucination to under 5% for factual claims because the agent verifies against live results before generating output. The integration takes 20 lines of Python.
Why LangGraph Needs Search
LangGraph's state machine architecture is ideal for research agents because it supports cycles: the agent can search, evaluate results, decide to search again with a refined query, and iterate until it has enough evidence. Without a search tool, the agent is limited to its training data, which is months old for any fast-moving topic.
Adding Search as a Tool Node
import requests, os
from langchain_core.tools import tool
API_KEY = os.environ["SCAVIO_API_KEY"]
@tool
def web_search(query: str) -> str:
"""Search the web for current information."""
resp = requests.post("https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": query})
results = resp.json().get("organic", [])[:3]
return "\n".join(
f"- {r['title']}: {r.get('snippet', '')}"
for r in results
)
# Use in LangGraph:
# graph.add_node("search", ToolNode(tools=[web_search]))
# graph.add_edge("agent", "search")
# graph.add_edge("search", "agent")
The Research Loop Pattern
The agent starts with a broad query, evaluates the results, identifies gaps, and searches again with more specific queries. A research task like "compare SERP API pricing in 2026" might trigger 3-5 searches: one for the overview, then one per vendor for specific pricing pages. Each search costs $0.005, so a typical research task costs $0.015-0.025 in search plus LLM costs.
Tavily vs Scavio for LangGraph
Tavily ($200/month for 20,000 API calls) is the default search provider in LangChain documentation and has a dedicated LangChain integration. Scavio ($30/month for 7,000 credits) costs less but requires a custom tool wrapper (shown above). Tavily returns AI-summarized results; Scavio returns raw SERP data. For research agents that need original source snippets rather than summaries, raw SERP data is more useful for citation and verification.
Multi-Source Research
Add platform-specific search tools for YouTube (video research), Reddit (community sentiment), and Amazon (product research). A multi-source agent can search Google for facts, Reddit for opinions, and YouTube for tutorials — each as a separate tool node in the LangGraph state machine. The agent decides which platform to query based on the research question.