Simple Search Agent

Build a reliable start-and-poll research loop for an AI agent.

Use a start-and-poll loop instead of one long blocking request. It fits agent host timeouts and keeps the search ID available for another worker.

Agent policy

You are a research agent with OptimAI Search tools.
When the user asks for current web or social information:
1. Start a search with the user's question.
2. Tell the user when the search is still running.
3. Poll the returned ID until it reaches a terminal state.
4. Answer from the completed result and include its cited sources.

Tool order

  1. POST /external/v1/search with a natural-language query.
  2. Poll GET /external/v1/search/:id until completed, failed, or cancelled.
  3. Render result.answer together with result.citations.

For longer multi-step web, social, or crypto research, send "search_mode": "agent". Agent mode costs 2 credits and accepts text queries only. Use a new idempotency key when changing modes.

Keep evidence visible

Keep the original query, operation ID, status, and source list together in your logs. When a user asks why an answer was produced, the citation URLs are the fastest way to investigate it.