web-search

Public

Forked from altra/web-search

Fork of Altra web-search - Fact-grounded web search with source verification — searches the web, reads full pages, fact-checks claims, and flags single-source info as unverified. No API key required. Fixes oriented on stability and reliability - especially around default DDG/Bing scrapers.

326 Downloads

README

Web Search Plugin for LM Studio — Research-Grade Local Web Search

Keywords: lm studio plugin, web search ai, local web research, fact checking ai, source verification, no api key, offline capable, private browsing ai

A research-grade web search plugin that goes beyond snippets — it reads pages, verifies claims, detects contradictions, finds primary sources, and enforces cross-source fact verification before asserting anything as true.


Standard search gives you ten links and short snippets. You get:

  • Snippets, not actual page content
  • One perspective, not multiple angles
  • Links, not answers
  • No way to verify if a claim is true
  • No source quality signals
  • No detection of conflicts between sources
  • No tracing claims back to primary sources
  • Stale and fresh results mixed together with no distinction
  • No check on whether a claim comes from one publisher or many independent ones

This plugin fixes all of that.


Who This Is For

  • Researchers and students who need verified, multi-source answers — not just the first result that sounds right
  • Journalists, analysts, and fact-checkers who need to trace claims to primary sources and surface contradictions
  • Anyone who wants local, private web research with no API key, no cloud account, and no per-query costs
  • LM Studio users who want research-grade source verification built directly into their local AI workflow

Installation

cd web-search-plugin
npm install
npx tsc

Load the built plugin in LM Studio.


Configuration

FieldDefaultDescription
Max Search Results8Results retrieved per query
Max Pages to Read3Pages actually fetched and read per search
Page Fetch Timeout8000msPer-page timeout before giving up
Search Interval4000msMinimum interval between search requests (all enabled providers). Higher = fewer CAPTCHA blocks, slower. If blocked often, raise to 5000–6000 ms or use SearXNG.
SearXNGOFFSelf-hosted first tier, opt-in (compact toggle; details on hover). Most users do not host SearXNG — leave off unless you have a URL.
DuckDuckGoONPrimary DDG scraper (compact).
BingONFallback tier (compact).
GoogleOFFGoogle scraper, stricter bot protection (compact).
EcosiaOFFBing-powered, privacy (compact).
StartpageONGoogle proxy, privacy (compact).
[Dubious] YandexOFFRussian, heavy bot protection (compact).
[Dubious] YahooOFFBing-powered, ad-heavy (compact).
[Dubious] BaiduOFFChinese, censored, aggressive (compact).
Custom User Agents4 defaultsParagraph field — one per line, randomly chosen per request. Long strings wrap and you can scroll/drag/arrow-key inside the field. Prefix a line with # or 0:: to disable without deleting; remove prefix or use 1:: to re-enable. Delete a line to remove entirely. Leave empty for built-in randomized header generator. (Previous stringArray UI had no per-item toggle and truncated long UAs — this paragraph field fixes both; SDK limitation: stringArray cannot have per-item enable/disable toggles, so prefix is the workaround.)
Search Languageen-usLanguage/region for results
SearXNG URL(blank)Recommended. Self-hosted SearXNG instance. Falls back to DDG → Startpage → Google → Ecosia → Bing → (Dubious) Yandex/Yahoo/Baidu if blank. DDG/Bing/Google etc. may block headless requests — SearXNG is the reliable path.
Search Recency WindowanyLimit general search to: day, week, month, year, or any (no filter, default). Use search_recent / search_news when you explicitly need recent results.
LM Studio URLhttp://localhost:1234Used for embedding-based result reranking via nomic-embed-text

How It Works

Clarify Before Searching

Before running any search, the plugin calls a clarify step. It detects ambiguity signals in the user's question:

  • Short/vague queries — fewer than 4 words with no clear intent
  • Ambiguous terms — e.g. "python" (language vs. snake), "java" (language vs. island vs. coffee), "bank", "swift", "mercury", "rust", "go"
  • Time-sensitive terms without a time context — e.g. "best", "latest", "current" with no year or window specified
  • Location-dependent queries — e.g. "near me", "local", "nearby"

If ambiguity is detected, the LLM asks the user focused questions before searching. This avoids wasted searches and produces a much more targeted answer.

Semantic Reranking

After retrieving search results, the plugin reranks them using embeddings before fetching any pages. This means the pages that actually get read are the most semantically relevant to the query — not just the top SEO results.

How it works:

  • Query + all result snippets are embedded via nomic-embed-text (requires the model loaded in LM Studio)
  • Cosine similarity scores each result against the query
  • Results are reordered by score before pages are fetched

If the embedding call fails (model not loaded, wrong URL), it falls back silently to the original search engine ranking.

Publisher Diversity Signal

search, search_recent, and search_news each report independent_publishers_read — the number of distinct root domains among the pages successfully fetched. This feeds a dynamic instruction injected into every result:

Publishers readInstruction to the LLM
0Do not assert any facts — re-search or inform the user
1Hard UNVERIFIED warning — call fact_check or label every claim as unverified before presenting
2+Report publisher count — flag any claim supported by only one of them as UNVERIFIED

This prevents the LLM from repeating a claim as fact just because one website said it.

Hard Verification Rules

The system prompt enforces five non-negotiable rules on top of the publisher diversity signal:

  • SINGLE-SOURCE RULE — a claim appearing in only one source must be labeled "unverified — found in one source only," regardless of how credible that source is.
  • CONFLICT RULE — if sources disagree, the LLM must not pick a side. It states the conflict and calls fact_check or compare_sources.
  • STATISTICS RULE — for any number or percentage, the LLM must state who published it, when, and what the sample was. If any of those three are missing, it calls verify_statistic before asserting the number.
  • AI/ML/TECH RULE — vendor blogs, SaaS marketing pages, press releases, and LinkedIn posts are not evidence of capability claims. Academic papers or independent journalism are required.
  • WIRE SERVICE RULE — multiple outlets reporting the same story from the same wire (AP, Reuters) or the same press release does not count as independent verification.

Search Backend

Results come from SearXNG (if configured) → DuckDuckGo → Startpage (Google proxy, default ON) → Google (opt-in) → Ecosia (Bing-powered, opt-in) → Bing → [Dubious, opt-in] Yandex / Yahoo / Baidu. No API keys required. All tiers are individually toggleable in settings and share the configurable interval + jitter + randomized User-Agent.


Tools

clarify — Ambiguity check (called automatically first)

Always called before any search. Returns either:

  • STATUS: READY — question is specific enough, search proceeds
  • STATUS: CLARIFY — question is ambiguous, LLM asks user before searching

You do not need to call this manually. The system prompt enforces it as a mandatory first step.


search — Core search with page reading

The main tool. Unlike basic search, it fetches and reads the actual page content — not just snippets.

search(query, max_pages_to_read?)

Returns:

  • Full text of each page read (reranked by semantic similarity)
  • Source credibility assessment for each URL
  • independent_publishers_read — count of distinct root domains among successful page reads
  • Additional snippet-only results beyond the read pages
  • Dynamic instruction based on publisher count (single-source warning or N-publisher count)

fetch_and_read — Read a specific URL

Fetch any URL and return the full readable text content.

fetch_and_read(url, max_chars?)

Use when:

  • Someone shares a link and wants you to read it
  • A search result looks relevant but you need the full article
  • You want to verify what a source actually says vs what others claim it says
  • You need exact wording from a policy, study, or report

deep_search — Multi-angle research

Runs 3–5 separate searches from different perspectives on the same topic, reads pages for each, and returns everything together. Defeats single-search bias.

deep_search(topic, angles?, pages_per_angle?)

Default angles: overview facts, latest research, criticism/limitations, expert consensus.

You can specify your own angles, e.g.:

angles: ["economic impact", "environmental cost", "industry response", "regulatory landscape"]

fact_check — Verify a specific claim

Cross-checks a claim across four search angles: direct confirmation, debunking searches, evidence searches, and expert opinion. Returns raw evidence from all angles for the LLM to assess.

fact_check(claim)

Verdict categories: supported, disputed, unsupported, nuanced, uncertain.


verify_statistic — Verify a number or percentage

Statistics are frequently outdated, misquoted, out of context, or fabricated. This tool searches for the stat, its primary source, fact-check results, and updated data.

verify_statistic(statistic, context?)

Example: verify_statistic("90% of startups fail in year one", "venture-backed US tech startups")


find_primary_source — Trace a claim to its origin

Secondary sources often distort original findings. This tool searches for the original study, report, official document, or statement where a claim first appeared.

find_primary_source(claim, domain?)

Prioritises: peer-reviewed journals, government reports, official organisation publications over secondary citations.


Only returns results from the specified time window. Prevents stale results from dominating on fast-moving topics.

search_recent(query, window?, read_pages?)

Windows: day (last 24h), week, month, year.

Returns independent_publishers_read and a dynamic publisher diversity instruction alongside the results.


compare_sources — Surface agreements and conflicts

Fetches multiple sources on the same topic and returns them side by side for the LLM to compare framing, spot conflicts, and identify unique claims.

compare_sources(topic, urls?, num_sources?)

Provide specific URLs to compare, or let it search and pick sources with varied domains automatically.

Returns structured analysis of:

  • Agreements — facts all sources confirm
  • Conflicts — where sources say different things
  • Framing differences — same facts, different emphasis
  • Unique claims — things only one source reports

find_expert_views — Expert consensus and dissent

Searches specifically for academic research, official positions, expert interviews, and scientific consensus — not what random blogs claim experts say.

find_expert_views(topic, field?)

Covers four angles: expert consensus, peer-reviewed research, official institutional positions, and active scientific debate.


search_academic — Academic papers only

Searches arXiv, PubMed, and Semantic Scholar for peer-reviewed papers and research publications.

search_academic(topic, source?, year_from?)

Sources: arxiv, pubmed, semantic_scholar, all.

Fetches paper pages to extract abstracts, methodology, and findings. The LLM is instructed to distinguish preprints from peer-reviewed work, note sample sizes, and not overstate findings.


News-filtered search that actively ranks established journalism above blogs, product pages, and content farms. Runs two queries — one general, one targeting major news outlets — then ranks high-credibility results first.

search_news(query, window?, read_pages?)

Windows: day, week, month, any.

Unlike search_recent (which filters by date), this filters by source type — it's about journalistic sourcing, not just recency. Best for: breaking news, corporate announcements, policy changes, anything where "who is reporting it" matters.

Returns independent_publishers_read and a dynamic publisher diversity instruction alongside the results.


research_topic — Full multi-step research brief

Runs multiple searches from different angles, reads key pages, and instructs the LLM to produce a structured research brief: overview, established facts, contested areas, expert consensus, open questions, key sources, and confidence assessment.

research_topic(topic, depth?, focus?)

Depths:

  • overview — 3 angles, 2 pages each
  • detailed — 5 angles, 2 pages each (default)
  • comprehensive — 7 angles, 3 pages each

check_source — Source credibility assessment

Assesses a URL or domain and returns its credibility type, known signals, reputation search results, and red flags to watch for.

check_source(url)

Domain types: government, academic institution, academic/research platform, established news outlet, encyclopedia, user-generated content, unknown.

Credibility levels: high, medium, low, unknown.

Red flags checked:

  • No named authors or editorial team
  • No About page or contact information
  • Recently registered domain with no track record
  • Known for misleading content
  • Listed on media bias databases as unreliable
  • No corrections policy

Source Credibility System

Every search result and fetched page gets a credibility assessment based on domain signals:

Domain TypeCredibilityExamples
GovernmentHIGH.gov, .mil, WHO, CDC
Academic institutionHIGH.edu, .ac.uk, universities
Academic platformsHIGHarXiv, PubMed, Semantic Scholar
Established newsHIGHReuters, AP, BBC, Nature, NYT
WikipediaMEDIUMGood overview, verify citations
User-generated / blogsLOWBlogspot, WordPress, Reddit, Quora
UnknownUNKNOWNCheck About page and author credentials

How Reasoning Works

The plugin's system prompt instructs the LLM to:

  • Always call clarify first — ask focused questions before searching if the query is ambiguous
  • Always cite sources — format: "According to [title] ([url])..."
  • Distinguish facts from inferences — facts are directly stated; inferences are concluded
  • Show reasoning — explain why, not just what
  • Never fabricate — if evidence isn't found, say so
  • Surface contradictions — "Source A says X, but Source B says Y — here's why..."
  • Signal confidence using exactly five labels:
    • HIGH — 2+ independent publishers agree AND at least one is a primary source (.gov, .edu, peer-reviewed journal)
    • MEDIUM — 2+ sources agree but no primary source, OR 1 high-credibility primary source alone
    • LOW — only 1 source found, OR all sources are from the same publisher or wire service
    • UNVERIFIED — claim was found but no corroboration exists (must use this label, not LOW)
    • UNCERTAIN — sources conflict, coverage is thin, or claim is under 2 weeks old

Example Queries

Simple fact:

"What is the Dunning-Kruger effect?" → clarify (READY) → search

Ambiguous query:

"Tell me about python" → clarify (CLARIFY) → asks: "Do you mean the programming language or the snake?" → search

Verify a claim:

"Is it true that we only use 10% of our brains?" → clarify (READY) → fact_check

Verify a statistic:

"Someone told me 50,000 species go extinct every year. Is that right?" → clarify (READY) → verify_statistic

Recent developments:

"What's happened with GPT-5 in the last week?" → clarify (READY) → search_recent(window: "week")

Compare perspectives:

"What do different sources say about seed oils and health?" → clarify (READY) → compare_sources or deep_search

Scientific consensus:

"What does the research actually say about intermittent fasting?" → clarify (READY) → find_expert_views + search_academic

Deep research:

"Give me a thorough research brief on quantum error correction" → clarify (READY) → research_topic(depth: "comprehensive")

Read a specific article:

"Can you read this paper and summarise the key findings? [url]" → clarify (READY) → fetch_and_read

Check if a source is reliable:

"Is naturalhealth365.com a reliable source?" → clarify (READY) → check_source

AI capability claim:

"I read that [model X] achieves 95% accuracy on [benchmark]. Is that right?" → clarify (READY) → fact_check — vendor blogs and press releases are not accepted as evidence; requires independent academic or journalistic confirmation


Peer Plugin Behaviour

Other altra plugins that include web search as a secondary capability will automatically defer to this plugin when it is installed alongside them. Their duplicate search/fetch tools are omitted at startup so this plugin's richer versions take over:

PluginTools deferred to web-search
altra/researchsearch_sources, read_source
altra/ideasresearch
altra/high-perf-toolsfetch_url, search_web

Installing this plugin is the recommended way to get the best search quality across all plugins at once. Each affected plugin also shows a tip on first message when this plugin is not installed.


CSL Changes

Root cause of empty search results

The ddgSearch() function had multiple flaws that caused search results to silently return empty after one or two successful calls per session:

  • No TLS fingerprint spoofing — DuckDuckGo performs TLS fingerprinting to detect bots. The native fetch() call lacks a realistic TLS fingerprint, so DDG identifies it as a bot and serves a CAPTCHA challenge page ("Select all squares containing a duck") instead of search results. This is the primary cause of persistent empty results.

  • Silent error swallowing — all catch { /* fall through */ } blocks discarded errors completely. When DuckDuckGo blocked or rate-limited requests, there was zero indication of what went wrong.

  • No rate limiting — only 300ms sleeps between requests. DuckDuckGo silently returns empty results when hit too fast.

  • No retry logic — if DDG returned empty (due to blocking), it immediately fell through to Bing (which often also fails) without retrying.

Changes

got-scraping for anti-bot evasion (new dependency): All search backend requests and page fetches now use got-scraping with headerGeneratorOptions (Chrome 120+, desktop, Linux, en-US). This generates realistic browser headers and TLS fingerprints that bypass DDG's bot detection. Native fetch() is used as a fallback only.

CAPTCHA detection (isDuckDuckGoCaptcha): Detects DDG's bot challenge pages by checking for anomaly-modal, cc=botnet, challenge-form, and related markers. When detected, throws a clear error instead of silently returning empty results.

Rate limiter (makeRateLimiter + searchRateLimiter): Enforces a 2000ms minimum interval between search backend requests, preventing DuckDuckGo from blocking or rate-limiting the plugin.

Retry logic (DDG_MAX_RETRIES = 3, DDG_RETRY_WAIT_MS = 2500): Retries DuckDuckGo up to 3 times with 2.5s waits when results are empty. CAPTCHA errors and network failures fall through immediately to Bing without retrying.

Diagnostic reporting (SearchDiagnostic interface): Every search call now returns a search_diagnostics array alongside results. Each entry tracks:

  • backend — which search engine was tried (searxng, ddg, bing)
  • ok — whether it returned results
  • resultCount — how many hits were returned
  • error — error message if it failed
  • attempts — how many retries were attempted (DDG only)

All 13 tool implementations updated: Each tool now includes search_diagnostics in its JSON response, so the model and user can see exactly which backend succeeded or failed and why.

What the model/user now sees

When searches fail, instead of silently empty results, the response includes diagnostics:

{
  "search_diagnostics": [
    { "backend": "ddg", "ok": false, "resultCount": 0,
      "error": "DDG returned a bot challenge (CAPTCHA) — requests are being blocked by DuckDuckGo's anti-bot system",
      "attempts": 1 },
    { "backend": "bing", "ok": true, "resultCount": 5 }
  ]
}

This tells you exactly which backends were tried, how many attempts were made, and what went wrong — so you and the model can diagnose and adapt.

Previously the model invoked search_recent/search_news too often even for evergreen queries. Three guardrails were added:

  • Prompt (promptPreprocessor.ts): TOOL SELECTION GUIDE now marks search as DEFAULT — 90% of queries and restricts search_recent/search_news to RECENCY-SENSITIVE ONLY — only when the user explicitly says latest/recent/current/breaking/today/this week… or the query contains time-sensitive keywords (latest, recent, current, today, breaking, news, 2025/2026, this week/month) or the topic is inherently time-sensitive (stock price, weather, live scores, breaking news). Otherwise: When in doubt, use 'search'.
  • Tool descriptions (toolsProvider.ts): search is now DEFAULT for 90% of queries / FIRST CHOICE; search_recent and search_news both start with DO NOT use by default and Use ONLY when (a) explicit user request / (b) explicit time keywords / (c) inherently time-sensitive topic.
  • Config (config.ts/config.js): searchRecencyWindow default changed year → any (no filter). This makes general search timeless and prevents evergreen topics from being silently filtered; explicit recency now requires search_recent/search_news with a window.

Fix: DDG bot protection, retry loops, and configurable search interval

  • Removed re-search loop instruction (toolsProvider.ts:106-118): publisherDiversityInstruction() previously told the model re-search or inform the user when no pages were read. This caused the model to retry the exact same query identically after a DDG CAPTCHA/block, creating an infinite loop. Replaced with: check search_diagnostics for CAPTCHA/bot errors, do not immediately retry the same query, you may wait a few seconds and retry once (optionally rephrased), and if this is the 2nd/3rd consecutive block, stop and clearly inform the user (explain the engine is temporarily blocking automated requests, list search_diagnostics, suggest alternatives). A new helper botBlockGuidance() appends the same guidance to every tool returning search_diagnostics (search, search_recent, search_news, deep_search, fact_check, verify_statistic, find_primary_source, compare_sources, find_expert_views, search_academic, research_topic).

  • Inspected bot-protection countermeasures (toolsProvider.ts:366-411): DDG blocks were frequent because the fingerprint was too static and the cadence too regular.

    • fetchSearchHtml() and fetchPage() now use diversified headerGeneratorOptions — chrome 120–130 and firefox 115–128, devices: [desktop], locales: [en-US, en], operatingSystems: [windows, macos, linux] instead of fixed chrome 120 / linux / en-US.
    • Added Referer: https://duckduckgo.com/ to search fetches so requests look like normal navigation.
    • Expanded isDuckDuckGoCaptcha() from 5 to 12+ signals (case-insensitive captcha, please verify you are a human, verifying you are human, temporarily blocked, rate limit, automated requests, enable javascript+continue, challenges.cloudflare.com, etc.) so blocks are correctly classified instead of appearing as empty results.
    • Increased DDG_RETRY_WAIT_MS 2500 → 3500 ms (plus rate-limiter jitter) to avoid hammering a blocked endpoint.
  • Increased interval and made it configurable (config.ts:22-31, toolsProvider.ts:72-84,673-699):

    • Default interval 2000 ms → 4000 ms (was the brius-web-search 2 s value). Higher values reduce CAPTCHA frequency; multi-angle searches are slower but far more reliable.
    • New plugin GUI field searchIntervalMs (numeric 1000–10000 ms, step 500, slider, default 4000) with subtitle explaining the trade-off and SearXNG alternative. The plugin syncs configuredSearchIntervalMs from cfg.get("searchIntervalMs") before every ddg()/sar() call.
    • makeRateLimiter() now takes () => number and adds 0–600 ms jitter on every wait, so requests are not perfectly periodic (a known bot signal).

Fix: Google support, provider toggles, and custom User-Agents

  • Google search support (toolsProvider.ts:557-623, 625-631, 644-730): Google sometimes yields better results than DDG/Bing. Added isGoogleCaptcha() (detects Our systems have detected unusual traffic, /sorry/index, recaptcha + google.com/sorry, unusual traffic + captcha, etc.) and scrapeGoogle() (builds https://www.google.com/search?q=…&num=&hl=en&gl=us&pws=0&tbs=qdr:X when a time window is requested, reuses the hardened fetchSearchHtml() with TLS spoofing + custom UA, parses yuRUbf blocks and /url?q= redirects with a generic <a><h3> fallback). Integrated into the unified fallback chain as Tier 3 between DDG and Bing: SearXNG → DDG → Google → Bing. Google respects the same searchRateLimiter() + jitter and contributes backend: "google" entries to search_diagnostics.

  • Provider enable/disable GUI (config.ts:33-48, toolsProvider.ts:89-102,645-730,848-872): Added enableSearxng (default ON), enableDDG (ON), enableBing (ON), enableGoogle (OFF by default) as boolean fields in LM Studio's plugin settings. The plugin syncs configuredProviders from cfg before every ddg()/sar() call; disabled providers emit skipped — disabled in config diagnostics and are bypassed. This lets you run DDG-only, Google+Bing, SearXNG-only, etc., without editing code. Order is fixed (SearXNG → DDG → Google → Bing) but each tier can be individually disabled.

  • Custom User-Agent multi-select (config.ts:50-64, toolsProvider.ts:104-131,348-365,381-393,422-472,629-631,996-998): Added userAgents stringArray with 4 sensible defaults (Chrome Win/Mac, Firefox Linux, Safari Mac). GUI shows them as chips — add via input, delete via ×. Per-item enable/disable without deleting: prefix an entry with # or 0:: (or disabled::) to disable it, remove the prefix or use 1:: to re-enable; empty or non-string entries are ignored. The plugin filters to enabled entries via getEnabledUserAgents(), and pickRandomUserAgent() chooses one at random per request (search and page fetch). Both fetchSearchHtml() (search backends) and fetchPage() (article reads + SearXNG) now send the chosen UA as User-Agent (overriding the header generator) and set a proper Referer (<origin>/ from the request URL). Native fetch fallbacks also use the same random UA. If the list is empty or all entries are disabled, the built-in randomized got-scraping header generator is used as before.

Fix: Dubious providers & additional regular engines (Ecosia, Startpage, Yandex, Baidu, Yahoo)

Category split (config.ts:33-68, toolsProvider.ts:92-100,1067-1085): Search providers are now grouped into Regular (SearXNG, DDG, Bing, Google, Ecosia, Startpage) and [Dubious] (Yandex, Baidu, Yahoo). Dubious engines are those with heavier bias/censorship, ad-heavy or less reliable indexes, and aggressive anti-scraping. Each has an individual boolean toggle in the GUI (enableYandex / enableYahoo / enableBaidu — all OFF by default, opt-in only) with subtitle warnings. Regular toggles are enableEcosia (OFF by default) and enableStartpage (ON by default) in addition to the existing enableSearxng/enableDDG/enableBing/enableGoogle. The unified chain is now SearXNG → DDG → Startpage → Google → Ecosia → Bing → (Dubious) Yandex → Yahoo → Baidu; disabled tiers emit skipped — disabled in config diagnostics. README.md:54-62 Documents the new toggles; README.md:120 documents the full order.

  • Ecosia (toolsProvider.ts:632-670) — regular, disabled by default: Bing-powered, privacy-focused. Scrapes https://www.ecosia.org/search?q=. Useful as a Bing alternative if Bing blocks (different domain, same Bing index). Parser looks for <article class="result"> / <div class="result"> with <a href> + <h2> title and <p> snippet, with generic <a><h2/3> fallback. isEcosiaCaptcha() checks captcha+ecosia, verify you are human, unusual traffic, challenges.cloudflare.com.

  • Startpage (toolsProvider.ts:672-722) — regular, enabled by default: Google proxy, privacy-focused. Scrapes https://www.startpage.com/sp/search?query=. Provides Google results without tracking; if Google's sorry/index CAPTCHA blocks, Startpage via a different frontend may still succeed. Note on difficulty: Startpage is Cloudflare-protected (challenges.cloudflare.com / cf-challenge / DDoS protection by Cloudflare / Please turn JavaScript on), so scraping is inherently less reliable than DDG/Bing. Implementation tries w-gl__result blocks with w-gl__description snippets, but will often fall through to the next tier; diagnostics will show Startpage exception: …Cloudflare/CAPTCHA… rather than silently empty.

  • Yandex (toolsProvider.ts:724-767) — dubious, OFF: Scrapes https://yandex.com/search?text=. isYandexCaptcha() detects SmartCaptcha/showcaptcha/please confirm you are not a robot/captcha+yandex. Parser looks for li.serp-item + <a href> and OrganicText snippet, with generic fallback. Yandex heavily JS-rendered and SmartCaptcha is frequent; success rate may be low without SearXNG.

  • Yahoo (toolsProvider.ts:769-810) — dubious, OFF: Scrapes https://search.yahoo.com/search?p=. Yahoo is Bing-powered and ad-heavy. isYahooCaptcha() checks captcha+yahoo/verify you are human. Parser for div.algo / dd algo with h3>a and compText snippet. Yahoo wraps result URLs in r.search.yahoo.com redirects — those are skipped.

  • Baidu (toolsProvider.ts:812-863) — dubious, OFF: Scrapes https://www.baidu.com/s?wd=. Most difficult: Baidu uses c-container blocks, baidu.com/link?url= redirects that require decoding, Chinese 安全验证 (security verification) challenge, and GBK encoding quirks. Parser handles c-container → h3>a + c-abstract snippet, decodes url= param, falls back to generic <a> scan. Expect low success outside Chinese queries; leave disabled unless you specifically need Baidu coverage.

All new scrapers reuse the hardened fetchSearchHtml() (TLS spoof, jitter interval, randomized UA from userAgents, proper Referer) and report backend: "ecosia"|"startpage"|"yandex"|"yahoo"|"baidu" diagnostics with CAPTCHA/empty handling consistent with DDG/Google/Bing.

Fix: Loop prevention & instruction hardening (anti-stuck/anti-retry) — promptPreprocessor.ts:74-81, toolsProvider.ts:39-62,173-195,2170-2245

Squashed several subtle loops that could still trap the model even after the earlier re-search fix:

  • safe_impl hint now branches on bot-block (toolsProvider.ts:53-62): previously always Read the error above, adjust the parameters if needed, and retry. — now detects captcha|bot challenge|blocked|botnet|challenge-form|unusual traffic|Cloudflare|SmartCaptcha|429|403 and returns an anti-loop hint (Do NOT retry same query immediately… wait, rephrase, try different enabled provider, or inform user… max 2 identical calls per turn). Prevents hint contradicting botBlockGuidance.
  • publisherDiversityInstruction:0-pages hardened (toolsProvider.ts:173-188): now also handles skipped — disabled in config (tell user to enable a provider instead of retrying) and genuine 0 results, no CAPTCHA (rephrase broader or inform no results, do not loop). Expanded provider list to SearXNG/DDG/Startpage/Google/Ecosia/Bing + dubious in suggestions.
  • Single-source fan-out capped (toolsProvider.ts:191-194): WARNING: All pages read are from same publisher… Call fact_check on key claims → now Consider calling fact_check ONLY if claim is high-stakes and you have not already called fact_check for this claim; otherwise label unverified. Do not call fact_check repeatedly — max once per claim per turn. Prevents search 1 publisher → fact_check (4× searches) → also single-source → fact_check … amplification.
  • check_source rate-limited (toolsProvider.ts:2238-2245): instruction now Limit use: do not call check_source for every URL — max 1–2 most important domains per turn. If already checked, reuse prior verdict. + botBlockGuidance(allDiags) attached. Prevents model calling check_source for each of 3 results → 6 extra searches.
  • Global LOOP PREVENTION (hard) in SYSTEM_RULES (promptPreprocessor.ts:74-81): new top-level rule NEVER call same tool with identical parameters more than twice per turn. After 2 failures (empty, CAPTCHA, tool_error) STOP and summarize search_diagnostics… suggest wait 30–60s / enable different provider / rephrase broader / provide URL. If publisherDiversityInstruction / botBlockGuidance / safe_impl hint says STOP, obey immediately. Max one fact_check/verify_statistic/check_source per claim/domain per turn, max one deep_search/research_topic per topic per turn.

Acknowledgements

Thanks to Altra for making something cool, and giving it to the world to toy around!

Additional "Thank you!" to brius and nub235 for field expertise; The engineering solutions in your code served as a reference implementation for fixes here. Your use of got-scraping for anti-bot evasion, structured error reporting, and rate limiting informed the approach taken in these fixes.