--- type: concept title: Agentic Search Best Practices description: Query formulation, extraction, validation, retry, and rate limiting for an agent that searches the web. tags: - agentic - search - rag - retrieval - unverified verified: 2026-08-28 timestamp: 2026-08-11 --- # Agentic Search Best Practices An agent that searches well does not fire one query and trust one answer. It rewrites queries, reads the strongest sources, and checks its own work. This page gives the practices. See [Research Effectiveness](research-effectiveness.md) for how to orchestrate the loop. ## The Search Pipeline ```mermaid graph LR A[User question] --> B[Query rewriter] B --> C[Query 1] B --> C2[Query 2] B --> C3[Query 3] C --> D[SearXNG] C2 --> D C3 --> D D --> E[Extract content] E --> F[Re-rank + dedupe] F --> G[Validate facts] G --> H[Synthesize + cite] ``` ## Query Formulation - Rewrite the user question into a search-ready query. - Generate two or three alternative queries for broader coverage. - Add synonyms and related terms. - Batch the queries in one action when the framework allows it. A code-based agent (CodeAct) can run several searches in one action. This cuts LLM calls by about 30 percent compared with one tool call per search. The ReAct loop (reason, act, observe) is the default pattern. ## Extraction and Processing - Convert HTML to clean Markdown before you feed the model. Pi does this in `fetch_content`. - Remove near-duplicate results across engines. - Re-rank with BM25 relevance scoring. - Keep a source reference for every extracted fact. - Truncate long pages. A common cap is 40,000 characters per page. Use query-aware content filters to cut noise before the model sees text. Crawl4AI ships three filters: - `BM25ContentFilter` — score page chunks against the query. Keep only relevant snippets. - `PruningContentFilter` — strip boilerplate by text and link density. - `LLMContentFilter` — delegate filtering to a model for hard pages. Run BM25 re-ranking on the search results themselves. The SearXNG BM25 reranker plugin builds a temporary index and fuses BM25 scores with engine rankings using reciprocal rank fusion. This lifts keyword accuracy over raw engine order. ## Respect Rate Limits Upstream engines and SearXNG block agents that hammer them. Slow down on purpose. - Respect `Retry-After` headers. - Use exponential backoff on retries. - Rotate user-agent strings. - Add random delays between requests. - Cap the request rate. A common default is 1 request per second. - Run a circuit breaker that suspends a failing engine. - Cache results with a time-to-live value. ```yaml # SearXNG side: cap timeouts and retries outgoing: request_timeout: 2.0 max_request_timeout: 10.0 retries: 3 ``` SearXNG suspends failing engines on a timer. For example, a CAPTCHA response suspends the engine for 3600 seconds. Respect that pause instead of retrying into the block. ## Validate the Answer - Cross-reference each claim against a second independent source. - Prefer primary sources over summaries. - Record the authority and freshness of each source. Score credibility on concrete signals: - Domain type. Prefer `.edu`, `.gov`, and `.org` over personal `.com` sites. - Link density. A low text-to-link ratio signals a content farm. - Metadata. A real `