Skip to main content

Scenario

You want an agent that answers questions about things that happened after its training cutoff—product launches, pricing changes, release notes—and cites its sources instead of guessing. That is the search then fetch pattern: discover candidates cheaply, read selectively, synthesize from real content.

What you need

The flow

The selection step in the middle is what keeps this cheap. Fetching everything a search returns wastes credits and context on results the snippets already showed were irrelevant.

Step 1: search for sources

freshness: "month" matters for questions about recent events—without it you get well-ranked pages from years ago. Search costs one credit whether you ask for 10 results or 100, so ask for enough to choose from.

Step 2: choose what to read

Use title and snippet to filter before spending credits. A useful heuristic:
  • Prefer primary sources—official docs, release notes, vendor blogs—over aggregators
  • Drop results whose snippet clearly answers a different question
  • Keep 3 to 5 URLs; more rarely improves the answer and always costs more

Step 3: read the selected pages

only_main_content: true strips navigation and footers, so what reaches the model is the article rather than the site chrome.

Step 4: handle partial results

With several URLs, expect some to fail. Read both arrays:
Synthesize from pages, and mention the gap rather than hiding it. If a source you needed failed, fall back to the next-best URL from the original search rather than searching again.

A prompt that produces this behavior

System prompt
The instruction to select before fetching is what keeps cost proportional to the question.

Complete implementation

The idempotency_key derived from the question means a retried research call replays the original fetch instead of paying twice. See Idempotency and retries.

Handling slow fetches

A large batch can exceed the 30-second wait window. When it does, poll rather than re-fetch:

Cost in practice

A typical question: Fetching all 10 results instead would cost 11 credits for an answer that is rarely better. Selection is the whole game.

Next steps