Building a Research Agent with a Search API

A pattern for an agent that plans queries, fetches results, and synthesizes a cited answer.

How it works

A research agent typically runs a plan-search-synthesize loop rather than a single search call: it first breaks the user's question into sub-questions, issues a search for each, optionally fetches full page content for the most promising results, and then composes a final answer that cites which sub-finding came from which source. The loop can iterate — if the first round of searches doesn't yield enough to answer confidently, the agent generates follow-up queries before synthesizing.

Example

Question: 'How has cloud GPU pricing changed in the last year?' The agent plans two sub-queries — cloud GPU pricing trends 2025 2026 and AWS Azure GCP GPU instance price changes — runs both, reads the top few snippets from each, and produces a synthesized answer with inline citations like [1] and [2] mapped to the source URLs.

A concrete example: SerpStack works well here because its response is already clean JSON — organic results, titles, snippets, and URLs — with no HTML parsing step standing between the API call and the prompt you hand the model.

Pitfalls

Related reading