Loop engineering for AI agents
Loop engineering for AI agents
Rule
When a task requires searching, crawling, or fetching — loop across engines with:
- Fan-out — try ≥3 sources in parallel (searxng → open-websearch → duckduckgo → mcp-crawl)
- Fallback — if engine 1 fails/empty, use engine 2 (then 3, 4...)
- Stop condition — result found ∧ confidence ≥ threshold → stop loop
- Self-correction — if result contradicts known facts, re-loop with corrected query
- No infinite loops — max 3 attempts per query (hard cap)
Search fallback chain (no keys needed)
searxng— baresearch.org (Google + Bing + Wikipedia meta)open-websearch— Bing + Baidu + DuckDuckGo + Brave + Exa + GitHub + Juejin + CSDN (8 engines)duckduckgo— DDG directmcp-crawl— @anthropic/mcp-crawl (crawl a URL + linked pages → markdown)fetch— single-page URL fetch
Web crawl chain (for docs)
mcp-crawl— crawl homepage + linked pages (up to 100 pages, no key)firecrawl-mcp— needs API key → install in Smithery toolbox if availablefetch— single page fallback
Rate limits
- searxng: 10 req/min (baresearch.org)
- duckduckgo: rate-limited (no hard cap)
- open-websearch: 30 req/min
- mcp-crawl: 20 pages/session
Max 30 sec per loop iteration. If all fail → report "unreachable" + suggestion.