Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat(search): add Webz.io news search engine (#7366)

Chanhyo Junga12c5299be2c
diff --git a/changelog.d/7188.feature.md b/changelog.d/7188.feature.md
new file mode 100644
index 0000000000..7e866391a1
--- /dev/null
+++ b/changelog.d/7188.feature.md
@@ -0,0 +1 @@
+Add Webz.io semantic news search with publication dates, source metadata, configurable filters and existing full-content fetch support.
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md
index 20b154df2e..118a313c85 100644
--- a/docs/CONFIGURATION.md
+++ b/docs/CONFIGURATION.md
@@ -613,6 +613,20 @@ They are not available in the Web UI because they are needed to start the applic
| `search.engine.web.wayback.supports_full_search` | `LDR_SEARCH_ENGINE_WEB_WAYBACK_SUPPORTS_FULL_SEARCH` | `true` | Indicates this engine can fetch full archived page content, not just metadata. | SEARCH |
| `search.engine.web.wayback.use_in_auto_search` | `LDR_SEARCH_ENGINE_WEB_WAYBACK_USE_IN_AUTO_SEARCH` | `false` | Include Wayback in auto search mode | SEARCH |
| `search.engine.web.wayback.weaknesses` | `LDR_SEARCH_ENGINE_WEB_WAYBACK_WEAKNESSES` | ``["limited to previously archived content", "may miss recent changes", "archiving quality varies"]`` | Limitations: Only finds previously archived content, may miss recent changes, archive quality varies by site. | SEARCH |
+| `search.engine.web.webz.agent_enabled` | `LDR_SEARCH_ENGINE_WEB_WEBZ_AGENT_ENABLED` | `false` | Include Webz.io as an additional specialized news tool for the research agent. Disabled by default; selecting Webz.io as search.tool still uses it as the primary engine. | SEARCH |
+| `search.engine.web.webz.api_key` | `LDR_SEARCH_ENGINE_WEB_WEBZ_API_KEY` | `` | Webz.io API token with api_news permission and available credits. Stored as a password setting. Requests use HTTPS only with no redirects; direct documentation shows HTTP, and live TLS compatibility has not been smoke-tested. | SEARCH |
+| `search.engine.web.webz.default_params.filters` | `LDR_SEARCH_ENGINE_WEB_WEBZ_DEFAULT_PARAMS_FILTERS` | ``{}`` | Direct-API filters object. Supports language, country, category, sentiment, domain, exclude_domain, topic, person, organization, location, ticker, political_bias, published_from, published_to, source_type, trust_category and domain rank bounds. Dates must be YYYY-MM-DD and ordered; omitted dates leave coverage to the provider. Client bounds array filters to 50 nonempty strings of at most 256 characters. MCP days/allow_all_dates are not accepted. | SEARCH |
+| `search.engine.web.webz.default_params.score_gte` | `LDR_SEARCH_ENGINE_WEB_WEBZ_DEFAULT_PARAMS_SCORE_GTE` | `4` | Minimum direct-API match score, 0-10; use 0 to disable the floor. | SEARCH |
+| `search.engine.web.webz.default_params.score_lte` | `LDR_SEARCH_ENGINE_WEB_WEBZ_DEFAULT_PARAMS_SCORE_LTE` | `null` | Optional direct-API maximum match score, 0-10; null omits the upper bound. Must be at least score_gte. | SEARCH |
+| `search.engine.web.webz.description` | `LDR_SEARCH_ENGINE_WEB_WEBZ_DESCRIPTION` | `Semantic news search via the Webz.io direct News Search API; publication dates, source metadata and matching article excerpts. Queries are limited to 750 characters and 100 words; requested results are clamped to 1-50. Full article text uses the existing result-URL fetch wrapper, not an additional Webz API.` | Human-readable description of the search engine. | SEARCH |
+| `search.engine.web.webz.display_name` | `LDR_SEARCH_ENGINE_WEB_WEBZ_DISPLAY_NAME` | `Webz.io News Search` | Display name to use in the U.I. for this search engine. | SEARCH |
+| `search.engine.web.webz.reliability` | `LDR_SEARCH_ENGINE_WEB_WEBZ_RELIABILITY` | `0.85` | Reliability of the Webz.io search engine | SEARCH |
+| `search.engine.web.webz.requires_api_key` | `LDR_SEARCH_ENGINE_WEB_WEBZ_REQUIRES_API_KEY` | `true` | Whether this search engine requires an API key | SEARCH |
+| `search.engine.web.webz.requires_llm` | `LDR_SEARCH_ENGINE_WEB_WEBZ_REQUIRES_LLM` | `false` | Whether this search engine requires an LLM for relevance filtering | SEARCH |
+| `search.engine.web.webz.strengths` | `LDR_SEARCH_ENGINE_WEB_WEBZ_STRENGTHS` | ``["Semantic news search", "Publication dates and source metadata", "Relevant article excerpts"]`` | Strengths of this search engine | SEARCH |
+| `search.engine.web.webz.supports_full_search` | `LDR_SEARCH_ENGINE_WEB_WEBZ_SUPPORTS_FULL_SEARCH` | `true` | Whether this search engine supports full document search | SEARCH |
+| `search.engine.web.webz.use_in_auto_search` | `LDR_SEARCH_ENGINE_WEB_WEBZ_USE_IN_AUTO_SEARCH` | `false` | Whether to include this engine in auto/meta search selection | SEARCH |
+| `search.engine.web.webz.weaknesses` | `LDR_SEARCH_ENGINE_WEB_WEBZ_WEAKNESSES` | ``["Requires api_news permission and available credits", "Live HTTPS compatibility has not been smoke-tested", "Client caps results at 50: Parameters says 100, but Errors says k greater than 50 returns HTTP 422"]`` | Weaknesses of this search engine | SEARCH |
| `search.engine.web.wikinews.adaptive_search` | `LDR_SEARCH_ENGINE_WEB_WIKINEWS_ADAPTIVE_SEARCH` | `true` | Automatically adjust the search period based on the query type (recent or historical) to improve news search relevance | SEARCH |
| `search.engine.web.wikinews.agent_enabled` | `LDR_SEARCH_ENGINE_WEB_WIKINEWS_AGENT_ENABLED` | `true` | Include Wikinews as a specialized tool for the langgraph research agent. The engine selected as `search.tool` always keeps its generic web_search tool — this flag only controls additional specialized tools. Independent of egress; the per-collection 'available to the research agent' toggle still wins for collections. | SEARCH |
| `search.engine.web.wikinews.description` | `LDR_SEARCH_ENGINE_WEB_WIKINEWS_DESCRIPTION` | `Search news articles written by volunteers with verified sources` | Human-readable description of the search engine. | SEARCH |
diff --git a/src/local_deep_research/defaults/settings/search_engines/webz.json b/src/local_deep_research/defaults/settings/search_engines/webz.json
new file mode 100644
index 0000000000..eb634cc0f7
--- /dev/null
+++ b/src/local_deep_research/defaults/settings/search_engines/webz.json
@@ -0,0 +1,206 @@
+{
+ "search.engine.web.webz.display_name": {
+ "category": "webz",
+ "description": "Display name to use in the U.I. for this search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Display Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Webz.io News Search",
+ "visible": false
+ },
+ "search.engine.web.webz.description": {
+ "category": "webz",
+ "description": "Human-readable description of the search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Description",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Semantic news search via the Webz.io direct News Search API; publication dates, source metadata and matching article excerpts. Queries are limited to 750 characters and 100 words; requested results are clamped to 1-50. Full article text uses the existing result-URL fetch wrapper, not an additional Webz API.",
+ "visible": false
+ },
+ "search.engine.web.webz.api_key": {
+ "category": "webz",
+ "description": "Webz.io API token with api_news permission and available credits. Stored as a password setting. Requests use HTTPS only with no redirects; direct documentation shows HTTP, and live TLS compatibility has not been smoke-tested.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "password",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.webz.reliability": {
+ "category": "webz",
+ "description": "Reliability of the Webz.io search engine",
+ "editable": true,
+ "max_value": 1.0,
+ "min_value": 0.0,
+ "name": "Reliability",
+ "options": null,
+ "step": 0.05,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 0.85,
+ "visible": true
+ },
+ "search.engine.web.webz.requires_api_key": {
+ "category": "webz",
+ "description": "Whether this search engine requires an API key",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": false
+ },
+ "search.engine.web.webz.requires_llm": {
+ "category": "webz",
+ "description": "Whether this search engine requires an LLM for relevance filtering",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires LLM",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": false
+ },
+ "search.engine.web.webz.supports_full_search": {
+ "category": "webz",
+ "description": "Whether this search engine supports full document search",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Supports Full Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": false
+ },
+ "search.engine.web.webz.strengths": {
+ "category": "webz",
+ "description": "Strengths of this search engine",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Strengths",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "Semantic news search",
+ "Publication dates and source metadata",
+ "Relevant article excerpts"
+ ],
+ "visible": false
+ },
+ "search.engine.web.webz.weaknesses": {
+ "category": "webz",
+ "description": "Weaknesses of this search engine",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Weaknesses",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "Requires api_news permission and available credits",
+ "Live HTTPS compatibility has not been smoke-tested",
+ "Client caps results at 50: Parameters says 100, but Errors says k greater than 50 returns HTTP 422"
+ ],
+ "visible": false
+ },
+ "search.engine.web.webz.use_in_auto_search": {
+ "category": "webz",
+ "description": "Whether to include this engine in auto/meta search selection",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Use In Auto Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ },
+ "search.engine.web.webz.agent_enabled": {
+ "category": "webz",
+ "description": "Include Webz.io as an additional specialized news tool for the research agent. Disabled by default; selecting Webz.io as search.tool still uses it as the primary engine.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Available to Research Agent",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.score_gte": {
+ "category": "webz",
+ "description": "Minimum direct-API match score, 0-10; use 0 to disable the floor.",
+ "editable": true,
+ "max_value": 10,
+ "min_value": 0,
+ "name": "Minimum Match Score",
+ "options": null,
+ "step": 0.5,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 4,
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.score_lte": {
+ "category": "webz",
+ "description": "Optional direct-API maximum match score, 0-10; null omits the upper bound. Must be at least score_gte.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Maximum Match Score",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": null,
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.filters": {
+ "category": "webz",
+ "description": "Direct-API filters object. Supports language, country, category, sentiment, domain, exclude_domain, topic, person, organization, location, ticker, political_bias, published_from, published_to, source_type, trust_category and domain rank bounds. Dates must be YYYY-MM-DD and ordered; omitted dates leave coverage to the provider. Client bounds array filters to 50 nonempty strings of at most 256 characters. MCP days/allow_all_dates are not accepted.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "News Filters",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": {},
+ "visible": true
+ }
+}
diff --git a/src/local_deep_research/security/module_whitelist.py b/src/local_deep_research/security/module_whitelist.py
index c1489889e5..3186ec1767 100644
--- a/src/local_deep_research/security/module_whitelist.py
+++ b/src/local_deep_research/security/module_whitelist.py
@@ -52,6 +52,7 @@ ALLOWED_MODULE_PATHS: frozenset[str] = frozenset(
".engines.search_engine_serper",
".engines.search_engine_serpapi",
".engines.search_engine_serply",
+ ".engines.search_engine_webz",
".engines.search_engine_sofya",
".engines.search_engine_tavily",
".engines.search_engine_tinyfish",
@@ -104,6 +105,7 @@ ALLOWED_CLASS_NAMES: frozenset[str] = frozenset(
"SerpAPISearchEngine",
"SerperSearchEngine",
"SerplySearchEngine",
+ "WebzSearchEngine",
"SofyaSearchEngine",
"StackExchangeSearchEngine",
"TavilySearchEngine",
diff --git a/src/local_deep_research/web_search_engines/engine_registry.py b/src/local_deep_research/web_search_engines/engine_registry.py
index 68ffde9294..e885b300d0 100644
--- a/src/local_deep_research/web_search_engines/engine_registry.py
+++ b/src/local_deep_research/web_search_engines/engine_registry.py
@@ -123,6 +123,12 @@ ENGINE_REGISTRY: Dict[str, EngineEntry] = {
module_path=".engines.search_engine_serply",
class_name="SerplySearchEngine",
),
+ "webz": EngineEntry(
+ module_path=".engines.search_engine_webz",
+ class_name="WebzSearchEngine",
+ full_search_module=".engines.full_search",
+ full_search_class="FullSearchResults",
+ ),
"sofya": EngineEntry(
module_path=".engines.search_engine_sofya",
class_name="SofyaSearchEngine",
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_webz.py b/src/local_deep_research/web_search_engines/engines/search_engine_webz.py
new file mode 100644
index 0000000000..3afa68bd0a
--- /dev/null
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_webz.py
@@ -0,0 +1,325 @@
+"""Webz.io direct News Search API (not the MCP service).
+
+The provider's examples use HTTP. This adapter only uses HTTPS, refuses
+redirects and never falls back to HTTP; live TLS compatibility is unverified.
+The client caps k at 50 because the Parameters and Errors pages disagree.
+"""
+
+import copy
+import math
+from datetime import date
+from typing import Any, Dict, List, Optional
+
+import requests
+from langchain_core.language_models import BaseLLM
+
+from ...security.safe_requests import safe_post
+from ...security.secure_logging import logger
+from ..rate_limiting import RateLimitError
+from ..search_engine_base import BaseSearchEngine, Exposure, Sensitivity
+
+
+class WebzSearchEngine(BaseSearchEngine):
+ """Semantic news search with article excerpts and source metadata."""
+
+ is_public = True
+ is_news = True
+ egress_sensitivity = Sensitivity.NON_SENSITIVE
+ egress_exposure = Exposure.EXPOSING
+
+ SEARCH_URL = "https://api.webz.io/api/news/context"
+ MAX_RESULTS_CAP = 50
+ REQUEST_TIMEOUT = 30
+ # Client-side bounds for documented array filters, not provider limits.
+ MAX_FILTER_VALUES = 50
+ MAX_FILTER_VALUE_LENGTH = 256
+ ARRAY_FILTERS = frozenset(
+ {
+ "language",
+ "country",
+ "category",
+ "sentiment",
+ "domain",
+ "exclude_domain",
+ "topic",
+ "person",
+ "organization",
+ "location",
+ "ticker",
+ "political_bias",
+ }
+ )
+ DATE_FILTERS = frozenset({"published_from", "published_to"})
+ RANK_FILTERS = frozenset({"domain_rank_gte", "domain_rank_lte"})
+ CHOICE_FILTERS = {
+ "source_type": {"local_news", "newsroom", "gov_news"},
+ "trust_category": {"trusted_news", "fake_news", "satirical_news"},
+ }
+
+ def __init__(
+ self,
+ max_results: int = 10,
+ api_key: Optional[str] = None,
+ filters: Optional[Dict[str, Any]] = None,
+ score_gte: float = 4,
+ score_lte: Optional[float] = None,
+ allow_multiple_chunks_per_article: bool = False,
+ llm: Optional[BaseLLM] = None,
+ max_filtered_results: Optional[int] = None,
+ settings_snapshot: Optional[Dict[str, Any]] = None,
+ **kwargs,
+ ):
+ """Accept only documented direct-API fields and normal base kwargs.
+
+ ``filters`` uses absolute ISO calendar dates, with no implicit recency
+ conversion. The provider determines coverage when dates are omitted.
+ Array filters are bounded to 50 nonempty strings of 256 characters.
+ Credentials are resolved by the base class from parameters/snapshot.
+ """
+ if type(max_results) is not int:
+ raise ValueError("Webz max_results must be an integer")
+ max_results = max(1, min(max_results, self.MAX_RESULTS_CAP))
+ for score in (score_gte, score_lte):
+ if score is not None and (
+ type(score) not in (int, float)
+ or not math.isfinite(score)
+ or not 0 <= score <= 10
+ ):
+ raise ValueError(
+ "Webz scores must be finite numbers from 0 to 10"
+ )
+ if score_gte is None or (
+ score_lte is not None and score_gte > score_lte
+ ):
+ raise ValueError("Webz score_gte must not exceed score_lte")
+ if type(allow_multiple_chunks_per_article) is not bool:
+ raise ValueError(
+ "Webz allow_multiple_chunks_per_article must be boolean"
+ )
+ self.filters = self._validate_filters(filters)
+ self.score_gte = score_gte
+ self.score_lte = score_lte
+ self.allow_multiple_chunks_per_article = (
+ allow_multiple_chunks_per_article
+ )
+ if api_key is not None and not isinstance(api_key, str):
+ raise ValueError("Webz API key must be a string")
+ super().__init__(
+ llm=llm,
+ max_filtered_results=max_filtered_results,
+ max_results=max_results,
+ settings_snapshot=settings_snapshot,
+ **kwargs,
+ )
+ try:
+ self.api_key = self._resolve_api_key(
+ api_key,
+ "search.engine.web.webz.api_key",
+ engine_name="Webz.io",
+ settings_snapshot=settings_snapshot,
+ )
+ except (AttributeError, TypeError):
+ raise ValueError("Webz API key must be a string") from None
+ if any(ord(char) < 32 or ord(char) == 127 for char in self.api_key):
+ raise ValueError("Webz API key contains invalid header characters")
+
+ @classmethod
+ def _validate_filters(
+ cls, filters: Optional[Dict[str, Any]]
+ ) -> Dict[str, Any]:
+ if filters is None:
+ return {}
+ if not isinstance(filters, dict):
+ raise ValueError("Webz filters must be an object")
+ allowed = (
+ cls.ARRAY_FILTERS
+ | cls.DATE_FILTERS
+ | cls.RANK_FILTERS
+ | cls.CHOICE_FILTERS.keys()
+ )
+ if filters.keys() - allowed:
+ raise ValueError("Unsupported Webz filter field")
+ for key, value in filters.items():
+ if key in cls.ARRAY_FILTERS:
+ if (
+ not isinstance(value, list)
+ or not 1 <= len(value) <= cls.MAX_FILTER_VALUES
+ ):
+ raise ValueError("Webz array filters need 1-50 values")
+ if any(
+ not isinstance(item, str)
+ or not item.strip()
+ or len(item) > cls.MAX_FILTER_VALUE_LENGTH
+ for item in value
+ ):
+ raise ValueError(
+ "Webz array filter values need nonempty strings of at most 256 characters"
+ )
+ elif key in cls.DATE_FILTERS:
+ if not isinstance(value, str):
+ raise ValueError(
+ "Webz date filters need YYYY-MM-DD strings"
+ )
+ try:
+ parsed = date.fromisoformat(value)
+ except ValueError:
+ raise ValueError(
+ "Webz date filters need valid YYYY-MM-DD dates"
+ ) from None
+ if parsed.isoformat() != value:
+ raise ValueError("Webz date filters need YYYY-MM-DD dates")
+ elif key in cls.RANK_FILTERS:
+ if type(value) is not int or not 1 <= value <= 1000000:
+ raise ValueError(
+ "Webz domain rank filters need integers from 1 to 1000000"
+ )
+ elif (
+ not isinstance(value, str)
+ or value not in cls.CHOICE_FILTERS[key]
+ ):
+ raise ValueError(
+ "Invalid Webz source_type or trust_category filter"
+ )
+ for lower, upper in (
+ ("published_from", "published_to"),
+ ("domain_rank_gte", "domain_rank_lte"),
+ ):
+ if (
+ lower in filters
+ and upper in filters
+ and filters[lower] > filters[upper]
+ ):
+ raise ValueError(
+ "Webz filter lower bound must not exceed upper bound"
+ )
+ included = {item.lower() for item in filters.get("domain", [])}
+ excluded = {item.lower() for item in filters.get("exclude_domain", [])}
+ if included & excluded:
+ raise ValueError(
+ "Webz domain filters cannot include and exclude the same domain"
+ )
+ return copy.deepcopy(filters)
+
+ @staticmethod
+ def _check_response(response: requests.Response) -> None:
+ response.raise_for_status()
+ if response.status_code != 200:
+ raise requests.HTTPError(
+ f"Unexpected Webz HTTP status {response.status_code}",
+ response=response,
+ )
+
+ def _get_previews(self, query: str) -> List[Dict[str, Any]]:
+ if not isinstance(query, str):
+ raise ValueError("Webz query must be a string")
+ if not query.strip():
+ return []
+ if len(query) > 750 or len(query.split()) > 100:
+ raise ValueError("Webz query exceeds 750 characters or 100 words")
+ body: Dict[str, Any] = {
+ "query": query,
+ "k": self.max_results,
+ "score_gte": self.score_gte,
+ "allow_multiple_chunks_per_article": self.allow_multiple_chunks_per_article,
+ }
+ if self.score_lte is not None:
+ body["score_lte"] = self.score_lte
+ if self.filters:
+ body["filters"] = copy.deepcopy(self.filters)
+ try:
+ self._last_wait_time = self.rate_tracker.apply_rate_limit(
+ self.engine_type
+ )
+ response = safe_post(
+ self.SEARCH_URL,
+ json=body,
+ headers={
+ "Authorization": f"Bearer {self.api_key}",
+ "Accept": "application/json",
+ },
+ timeout=self.REQUEST_TIMEOUT,
+ allow_redirects=False,
+ )
+ self._check_response(response)
+ data = response.json()
+ rows = data.get("results") if isinstance(data, dict) else None
+ if not isinstance(rows, list):
+ return []
+ previews: List[Dict[str, Any]] = []
+ for row in rows:
+ if not isinstance(row, dict) or not isinstance(
+ row.get("article"), dict
+ ):
+ continue
+ article = row["article"]
+ link = article.get("url")
+ if not isinstance(link, str) or not link.strip():
+ continue
+ link = self._clean_result_url(link)
+ if not link.lower().startswith(("https://", "http://")):
+ continue
+ if not self._extract_display_link(link):
+ continue
+ chunk = row.get("chunk")
+ text = chunk.get("text") if isinstance(chunk, dict) else None
+ summary = article.get("summary")
+ snippet = (
+ text if isinstance(text, str) and text.strip() else summary
+ )
+ metadata = row.get("metadata")
+ metadata = metadata if isinstance(metadata, dict) else {}
+ domain = metadata.get("domain")
+ preview = {
+ "id": len(previews),
+ "title": article.get("title")
+ if isinstance(article.get("title"), str)
+ else "",
+ "link": link,
+ "snippet": snippet if isinstance(snippet, str) else "",
+ "displayed_link": self._extract_display_link(link),
+ "source": domain
+ if isinstance(domain, str)
+ else self._extract_display_link(link),
+ "metadata": copy.deepcopy(metadata),
+ "position": len(previews) + 1,
+ }
+ for field, target in (
+ ("published_at", "date"),
+ ("article_id", "article_id"),
+ ("main_image", "main_image"),
+ ):
+ if isinstance(article.get(field), str) and article[field]:
+ preview[target] = article[field]
+ score = row.get("score")
+ if (
+ isinstance(score, (int, float))
+ and not isinstance(score, bool)
+ and math.isfinite(score)
+ ):
+ preview["score"] = score
+ previews.append(preview)
+ if len(previews) == self.max_results:
+ break
+ self._search_results = previews
+ return previews
+ except RateLimitError:
+ raise
+ except requests.RequestException as error:
+ self._record_search_failure(error)
+ safe_msg = self._scrub_error(error)
+ # Preserve Retry-After while passing only scrubbed text to the
+ # base rate-limit detector (which can include error text).
+ self._raise_if_rate_limit(
+ requests.RequestException(
+ safe_msg, response=getattr(error, "response", None)
+ )
+ )
+ logger.warning(f"Error getting Webz.io news results: {safe_msg}")
+ return []
+ except Exception as error:
+ self._record_search_failure(error)
+ safe_msg = self._scrub_error(error)
+ logger.warning(
+ f"Unexpected error getting Webz.io news results: {safe_msg}"
+ )
+ return []
diff --git a/tests/settings/golden_master_settings.json b/tests/settings/golden_master_settings.json
index 0410e96334..3db66dab5b 100644
--- a/tests/settings/golden_master_settings.json
+++ b/tests/settings/golden_master_settings.json
@@ -8658,6 +8658,210 @@
],
"visible": true
},
+ "search.engine.web.webz.agent_enabled": {
+ "category": "webz",
+ "description": "Include Webz.io as an additional specialized news tool for the research agent. Disabled by default; selecting Webz.io as search.tool still uses it as the primary engine.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Available to Research Agent",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ },
+ "search.engine.web.webz.api_key": {
+ "category": "webz",
+ "description": "Webz.io API token with api_news permission and available credits. Stored as a password setting. Requests use HTTPS only with no redirects; direct documentation shows HTTP, and live TLS compatibility has not been smoke-tested.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "password",
+ "value": "",
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.filters": {
+ "category": "webz",
+ "description": "Direct-API filters object. Supports language, country, category, sentiment, domain, exclude_domain, topic, person, organization, location, ticker, political_bias, published_from, published_to, source_type, trust_category and domain rank bounds. Dates must be YYYY-MM-DD and ordered; omitted dates leave coverage to the provider. Client bounds array filters to 50 nonempty strings of at most 256 characters. MCP days/allow_all_dates are not accepted.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "News Filters",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": {},
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.score_gte": {
+ "category": "webz",
+ "description": "Minimum direct-API match score, 0-10; use 0 to disable the floor.",
+ "editable": true,
+ "max_value": 10,
+ "min_value": 0,
+ "name": "Minimum Match Score",
+ "options": null,
+ "step": 0.5,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 4,
+ "visible": true
+ },
+ "search.engine.web.webz.default_params.score_lte": {
+ "category": "webz",
+ "description": "Optional direct-API maximum match score, 0-10; null omits the upper bound. Must be at least score_gte.",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Maximum Match Score",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": null,
+ "visible": true
+ },
+ "search.engine.web.webz.description": {
+ "category": "webz",
+ "description": "Human-readable description of the search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Description",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Semantic news search via the Webz.io direct News Search API; publication dates, source metadata and matching article excerpts. Queries are limited to 750 characters and 100 words; requested results are clamped to 1-50. Full article text uses the existing result-URL fetch wrapper, not an additional Webz API.",
+ "visible": false
+ },
+ "search.engine.web.webz.display_name": {
+ "category": "webz",
+ "description": "Display name to use in the U.I. for this search engine.",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Display Name",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "text",
+ "value": "Webz.io News Search",
+ "visible": false
+ },
+ "search.engine.web.webz.reliability": {
+ "category": "webz",
+ "description": "Reliability of the Webz.io search engine",
+ "editable": true,
+ "max_value": 1.0,
+ "min_value": 0.0,
+ "name": "Reliability",
+ "options": null,
+ "step": 0.05,
+ "type": "SEARCH",
+ "ui_element": "range",
+ "value": 0.85,
+ "visible": true
+ },
+ "search.engine.web.webz.requires_api_key": {
+ "category": "webz",
+ "description": "Whether this search engine requires an API key",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires Api Key",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": false
+ },
+ "search.engine.web.webz.requires_llm": {
+ "category": "webz",
+ "description": "Whether this search engine requires an LLM for relevance filtering",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Requires LLM",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": false
+ },
+ "search.engine.web.webz.strengths": {
+ "category": "webz",
+ "description": "Strengths of this search engine",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Strengths",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "Semantic news search",
+ "Publication dates and source metadata",
+ "Relevant article excerpts"
+ ],
+ "visible": false
+ },
+ "search.engine.web.webz.supports_full_search": {
+ "category": "webz",
+ "description": "Whether this search engine supports full document search",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Supports Full Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": true,
+ "visible": false
+ },
+ "search.engine.web.webz.use_in_auto_search": {
+ "category": "webz",
+ "description": "Whether to include this engine in auto/meta search selection",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Use In Auto Search",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "checkbox",
+ "value": false,
+ "visible": true
+ },
+ "search.engine.web.webz.weaknesses": {
+ "category": "webz",
+ "description": "Weaknesses of this search engine",
+ "editable": false,
+ "max_value": null,
+ "min_value": null,
+ "name": "Weaknesses",
+ "options": null,
+ "step": null,
+ "type": "SEARCH",
+ "ui_element": "json",
+ "value": [
+ "Requires api_news permission and available credits",
+ "Live HTTPS compatibility has not been smoke-tested",
+ "Client caps results at 50: Parameters says 100, but Errors says k greater than 50 returns HTTP 422"
+ ],
+ "visible": false
+ },
"search.engine.web.wikinews.adaptive_search": {
"category": "wikinews",
"description": "Automatically adjust the search period based on the query type (recent or historical) to improve news search relevance",
diff --git a/tests/web_search_engines/engines/test_search_engine_webz.py b/tests/web_search_engines/engines/test_search_engine_webz.py
new file mode 100644
index 0000000000..a180d2ceb2
--- /dev/null
+++ b/tests/web_search_engines/engines/test_search_engine_webz.py
@@ -0,0 +1,485 @@
+"""Offline contracts for the production Webz News Search engine and factory."""
+
+from unittest.mock import patch
+
+import pytest
+import requests
+
+from local_deep_research.settings.manager import SettingsManager
+from local_deep_research.web_search_engines.engine_registry import (
+ ENGINE_REGISTRY,
+)
+from local_deep_research.web_search_engines.search_engine_factory import (
+ create_search_engine,
+)
+
+
[email protected](autouse=True)
+def no_outbound_network():
+ """Fail even when an adapter catches the transport exception."""
+ attempts = []
+
+ def blocked(*args, **kwargs):
+ attempts.append(True)
+ raise AssertionError("Unmocked outbound HTTP is forbidden")
+
+ with patch.object(requests.adapters.HTTPAdapter, "send", blocked):
+ yield
+ assert not attempts, "The engine attempted unmocked outbound HTTP"
+
+
+def webz_snapshot():
+ defaults = SettingsManager(db_session=None).default_settings
+ snapshot = {
+ key: value
+ for key, value in defaults.items()
+ if key.startswith("search.engine.web.webz.")
+ }
+ snapshot.update(
+ {
+ "search.engine.web.webz.api_key": "offline-webz-test-key",
+ "search.engine.library.enabled": False,
+ "policy.egress_scope": "public_only",
+ "search.tool": "webz",
+ }
+ )
+ return snapshot
+
+
+def test_factory_registers_webz_from_shipped_settings():
+ assert "webz" in ENGINE_REGISTRY, "Webz News Search is not registered"
+ engine = create_search_engine(
+ "webz", settings_snapshot=webz_snapshot(), programmatic_mode=True
+ )
+ assert engine is not None
+ assert type(engine).__name__ == "WebzSearchEngine"
+ assert engine.api_key == "offline-webz-test-key"
+ assert engine.programmatic_mode is True
+ assert engine.is_news is True
+ assert engine.is_public is True
+ assert engine.allow_private_result_fetch is False
+
+
+def make_engine(**kwargs):
+ from local_deep_research.web_search_engines.engines.search_engine_webz import (
+ WebzSearchEngine,
+ )
+
+ kwargs.setdefault("api_key", "offline-webz-test-key")
+ return WebzSearchEngine(**kwargs)
+
+
+def response(payload, status=200, headers=None):
+ import json
+
+ result = requests.Response()
+ result.status_code = status
+ result.url = "https://api.webz.io/api/news/context"
+ result._content = json.dumps(payload).encode()
+ result.headers.update(headers or {})
+ return result
+
+
+# One documented result row inside the documented results[] envelope.
+ARTICLE = {
+ "score": 7.1,
+ "article": {
+ "article_id": "32445ab27737dcdad9119b67fb1d379908a41ecf",
+ "url": "https://www.example.com/edition/",
+ "title": "Article Title",
+ "published_at": "2026-08-27T07:07:00.000+03:00",
+ "summary": "Article's extractive summary",
+ "main_image": "https://media.example.com/image.png",
+ },
+ "chunk": {"text": "Relevant chunk matching the query."},
+ "metadata": {
+ "domain": "example.com",
+ "country": "US",
+ "language": "english",
+ "category": ["Economy, Business and Finance"],
+ "source_type": "local_news",
+ },
+}
+MODULE = "local_deep_research.web_search_engines.engines.search_engine_webz"
+
+
+def test_direct_request_and_result_metadata(mock_rate_tracker):
+ with patch(
+ f"{MODULE}.safe_post", return_value=response({"results": [ARTICLE]})
+ ) as post:
+ engine = make_engine(max_results=100)
+ items = engine._get_previews("central bank interest rate decision")
+ post.assert_called_once_with(
+ "https://api.webz.io/api/news/context",
+ json={
+ "query": "central bank interest rate decision",
+ "k": 50,
+ "score_gte": 4,
+ "allow_multiple_chunks_per_article": False,
+ },
+ headers={
+ "Authorization": "Bearer offline-webz-test-key",
+ "Accept": "application/json",
+ },
+ timeout=30,
+ allow_redirects=False,
+ )
+ mock_rate_tracker.apply_rate_limit.assert_called_once_with(
+ engine.engine_type
+ )
+ assert len(items) == 1
+ assert items[0]["title"] == "Article Title"
+ assert items[0]["link"] == ARTICLE["article"]["url"]
+ assert items[0]["snippet"] == ARTICLE["chunk"]["text"]
+ assert items[0]["date"] == ARTICLE["article"]["published_at"]
+ assert items[0]["source"] == "example.com"
+ assert items[0]["metadata"] == ARTICLE["metadata"]
+ assert items[0]["article_id"] == ARTICLE["article"]["article_id"]
+ assert items[0]["main_image"] == ARTICLE["article"]["main_image"]
+ assert items[0]["score"] == 7.1
+ assert "full_content" not in items[0]
+ assert "_full_result" not in items[0]
+ # Full content remains the existing wrapper's responsibility, with no News API call.
+ assert engine._get_full_content(items) == items
+
+
+ "query", ["x" * 751, " ".join(["word"] * 101), None, 123]
+)
+def test_invalid_queries_never_send(query, mock_rate_tracker):
+ with patch(f"{MODULE}.safe_post") as post:
+ engine = make_engine()
+ with pytest.raises(ValueError, match="query"):
+ engine._get_previews(query)
+ post.assert_not_called()
+ mock_rate_tracker.apply_rate_limit.assert_not_called()
+
+
[email protected]("query", ["", " \n\t "])
+def test_blank_query_is_empty_without_io(query):
+ with patch(f"{MODULE}.safe_post") as post:
+ assert make_engine()._get_previews(query) == []
+ post.assert_not_called()
+
+
[email protected]("query", ["x" * 750, " ".join(["w"] * 100)])
+def test_query_limits_are_inclusive(query):
+ with patch(
+ f"{MODULE}.safe_post", return_value=response({"results": []})
+ ) as post:
+ assert make_engine()._get_previews(query) == []
+ assert post.call_args.kwargs["json"]["query"] == query
+
+
+ "requested,expected", [(0, 1), (-2, 1), (1, 1), (50, 50), (51, 50)]
+)
+def test_result_count_is_bounded(requested, expected):
+ with patch(
+ f"{MODULE}.safe_post",
+ return_value=response({"results": [ARTICLE] * 55}),
+ ) as post:
+ results = make_engine(max_results=requested)._get_previews("news")
+ assert post.call_args.kwargs["json"]["k"] == expected
+ assert len(results) == expected
+
+
[email protected]("requested", [True, "10", 1.5, None])
+def test_result_count_rejects_non_integers(requested):
+ with pytest.raises(ValueError, match="max_results"):
+ make_engine(max_results=requested)
+
+
+def test_filters_scores_and_multiple_chunks_use_direct_fields():
+ filters = {
+ "language": ["english"],
+ "country": ["US", "GB"],
+ "domain": ["example.com"],
+ "exclude_domain": ["excluded.example"],
+ "published_from": "2026-08-01",
+ "published_to": "2026-08-27",
+ "source_type": "newsroom",
+ "trust_category": "trusted_news",
+ "domain_rank_gte": 1,
+ "domain_rank_lte": 10000,
+ }
+ engine = make_engine(
+ filters=filters,
+ score_gte=0,
+ score_lte=8,
+ allow_multiple_chunks_per_article=True,
+ )
+ filters["country"].append("CA")
+ with patch(
+ f"{MODULE}.safe_post", return_value=response({"results": []})
+ ) as post:
+ engine._get_previews("news")
+ body = post.call_args.kwargs["json"]
+ assert body["filters"]["country"] == ["US", "GB"]
+ assert body["filters"]["published_from"] == "2026-08-01"
+ assert body["filters"]["published_to"] == "2026-08-27"
+ assert body["score_gte"] == 0
+ assert body["score_lte"] == 8
+ assert body["allow_multiple_chunks_per_article"] is True
+ assert "days" not in body
+ assert "allow_all_dates" not in body
+
+
+ "filters",
+ [
+ [],
+ {"days": 7},
+ {"allow_all_dates": True},
+ {"score_gte": 2},
+ {"country": "US"},
+ {"domain": [None]},
+ {"language": [""]},
+ {"country": ["US"] * 51},
+ {"person": ["a" * 257]},
+ {"published_from": "2026-02-30"},
+ {"published_to": "2026-8-1"},
+ {"published_from": "2026-08-28", "published_to": "2026-08-27"},
+ {"domain_rank_gte": 0},
+ {"domain_rank_lte": 1000001},
+ {"domain_rank_gte": True},
+ {"domain_rank_gte": 10, "domain_rank_lte": 5},
+ {"source_type": "unknown"},
+ {"trust_category": "unknown"},
+ {"domain": ["example.com"], "exclude_domain": ["example.com"]},
+ ],
+)
+def test_invalid_filters_are_rejected_before_io(filters):
+ with patch(f"{MODULE}.safe_post") as post:
+ with pytest.raises(ValueError, match="filter"):
+ make_engine(filters=filters)
+ post.assert_not_called()
+
+
+ "kwargs",
+ [
+ {"score_gte": -1},
+ {"score_lte": 11},
+ {"score_gte": float("nan")},
+ {"score_lte": float("inf")},
+ {"score_gte": "4"},
+ {"score_gte": True},
+ {"score_gte": 5, "score_lte": 4},
+ {"allow_multiple_chunks_per_article": "false"},
+ ],
+)
+def test_invalid_request_options_are_rejected(kwargs):
+ with pytest.raises(ValueError):
+ make_engine(**kwargs)
+
+
+ "payload",
+ [
+ None,
+ [],
+ {},
+ {"results": None},
+ {"results": {}},
+ {"detail": "no results"},
+ {"results": [None, "bad", {}, {"article": []}]},
+ ],
+)
+def test_empty_or_malformed_payloads_have_no_invented_content(payload):
+ with patch(f"{MODULE}.safe_post", return_value=response(payload)):
+ assert make_engine()._get_previews("news") == []
+
+
+def test_partial_rows_do_not_discard_later_results_and_summary_is_fallback():
+ rows = [
+ None,
+ {"article": {"url": 123}},
+ {
+ "article": {
+ "url": "https://example.com/summary",
+ "summary": "Summary only",
+ },
+ "chunk": {"text": None},
+ "metadata": None,
+ },
+ {"article": {"url": "https://example.com/empty"}, "chunk": {}},
+ ARTICLE,
+ ]
+ with patch(f"{MODULE}.safe_post", return_value=response({"results": rows})):
+ items = make_engine()._get_previews("news")
+ assert len(items) == 3
+ assert items[0]["title"] == ""
+ assert items[0]["snippet"] == "Summary only"
+ assert items[1]["snippet"] == ""
+ assert items[2]["title"] == "Article Title"
+
+
[email protected]("status", [400, 401, 402, 403, 422, 500, 503])
+def test_http_failures_are_empty_and_recorded_without_provider_text(status):
+ engine = make_engine()
+ with patch(
+ f"{MODULE}.safe_post",
+ return_value=response({"detail": "offline-webz-test-key"}, status),
+ ):
+ assert engine._get_previews("news") == []
+ if status in (400, 422):
+ assert engine.last_search_failure is None
+ else:
+ assert engine.last_search_failure is not None
+ assert "offline-webz-test-key" not in engine.last_search_failure.reason
+
+
+def test_rate_limit_propagates_retry_after_and_scrubs_credential():
+ from local_deep_research.web_search_engines.rate_limiting import (
+ RateLimitError,
+ )
+
+ engine = make_engine()
+ error_response = response(
+ {"detail": "offline-webz-test-key"}, 429, {"Retry-After": "17"}
+ )
+ with patch(f"{MODULE}.safe_post", return_value=error_response):
+ with pytest.raises(RateLimitError) as exc:
+ engine._get_previews("news")
+ assert exc.value.retry_after == 17
+ assert "offline-webz-test-key" not in str(exc.value)
+
+
+ "error",
+ [
+ requests.Timeout("offline-webz-test-key"),
+ requests.ConnectionError("offline-webz-test-key"),
+ ValueError("offline-webz-test-key"),
+ ],
+)
+def test_errors_use_base_credential_scrubbing(error):
+ with (
+ patch(f"{MODULE}.safe_post", side_effect=error),
+ patch(f"{MODULE}.logger") as logger,
+ ):
+ assert make_engine()._get_previews("news") == []
+ text = str(logger.warning.call_args)
+ assert "offline-webz-test-key" not in text
+ assert "REDACTED" in text
+
+
+ "key",
+ [
+ None,
+ "",
+ "placeholder",
+ "your_api_key",
+ 123,
+ True,
+ "secret\r\nInjected: value",
+ ],
+)
+def test_missing_invalid_credentials_never_send(key):
+ with patch(f"{MODULE}.safe_post") as post:
+ with pytest.raises(ValueError):
+ make_engine(api_key=key)
+ post.assert_not_called()
+
+
+def test_settings_credentials_base_kwargs_and_no_environment_bypass(
+ monkeypatch,
+):
+ monkeypatch.setenv("LDR_SEARCH_ENGINE_WEB_WEBZ_API_KEY", "unused-env-key")
+ engine = make_engine(
+ api_key=None,
+ settings_snapshot={"search.engine.web.webz.api_key": "snapshot-key"},
+ programmatic_mode=True,
+ include_full_content=True,
+ preview_filters=[],
+ )
+ assert engine.api_key == "snapshot-key"
+ assert engine.programmatic_mode is True
+ assert engine.include_full_content is True
+ with pytest.raises(ValueError, match="No valid API key"):
+ make_engine(api_key=None)
+
+
+def test_factory_without_key_is_unavailable_and_does_not_fall_back():
+ snapshot = webz_snapshot()
+ snapshot["search.engine.web.webz.api_key"] = ""
+ assert create_search_engine("webz", settings_snapshot=snapshot) is None
+
+
+ "link", ["https://", "https://[broken", "not a URL", "", None, 42]
+)
+def test_malformed_urls_do_not_become_usable_sources(link):
+ bad = {
+ "article": {"url": link, "title": "Malformed", "summary": "unusable"}
+ }
+ with patch(
+ f"{MODULE}.safe_post",
+ return_value=response({"results": [bad, ARTICLE]}),
+ ):
+ items = make_engine()._get_previews("news")
+ assert [item["title"] for item in items] == ["Article Title"]
+
+
[email protected]("key", [123, True, [], {}])
+def test_invalid_snapshot_credentials_are_value_errors(key):
+ with pytest.raises(ValueError):
+ make_engine(
+ api_key=None,
+ settings_snapshot={"search.engine.web.webz.api_key": key},
+ )
+
+
[email protected]("status", [301, 302, 307, 308])
+def test_redirects_are_refused_without_a_second_request(status):
+ with patch(
+ f"{MODULE}.safe_post",
+ return_value=response(
+ {"results": [ARTICLE]},
+ status,
+ {"Location": "http://api.webz.io/api/news/context"},
+ ),
+ ) as post:
+ assert make_engine()._get_previews("news") == []
+ assert post.call_count == 1
+ assert post.call_args.kwargs["allow_redirects"] is False
+
+
+def test_transport_rate_error_scrubs_known_key_and_retains_headers():
+ from local_deep_research.web_search_engines.rate_limiting import (
+ RateLimitError,
+ )
+
+ error = requests.HTTPError(
+ "upstream included offline-webz-test-key",
+ response=response({}, 429, {"Retry-After": "19"}),
+ )
+ with patch(f"{MODULE}.safe_post", side_effect=error):
+ with pytest.raises(RateLimitError) as exc:
+ make_engine()._get_previews("news")
+ assert exc.value.retry_after == 19
+ assert "offline-webz-test-key" not in str(exc.value)
+
+
+def test_factory_respects_private_scope_without_io():
+ from local_deep_research.security.egress.policy import PolicyDeniedError
+
+ snapshot = webz_snapshot()
+ snapshot["policy.egress_scope"] = "private_only"
+ with pytest.raises(PolicyDeniedError):
+ create_search_engine("webz", settings_snapshot=snapshot)
+
+
+def test_factory_wraps_full_content_using_existing_security_boundary():
+ from local_deep_research.web_search_engines.engines.full_search import (
+ FullSearchResults,
+ )
+
+ wrapped = create_search_engine(
+ "webz", settings_snapshot=webz_snapshot(), use_full_search=True
+ )
+ assert isinstance(wrapped, FullSearchResults)
+ assert type(wrapped.web_search).__name__ == "WebzSearchEngine"
+ assert wrapped.allow_private_ips is False
diff --git a/tests/web_search_engines/test_engine_success_path.py b/tests/web_search_engines/test_engine_success_path.py
index 24c9ec3577..1178fda3a8 100644
--- a/tests/web_search_engines/test_engine_success_path.py
+++ b/tests/web_search_engines/test_engine_success_path.py
@@ -1329,6 +1329,64 @@ def _drive_serply(tracker):
return engine._get_previews(QUERY)
+def _drive_webz(tracker):
+ from local_deep_research.settings.manager import SettingsManager
+ from local_deep_research.web_search_engines.search_engine_factory import (
+ create_search_engine,
+ )
+ from local_deep_research.web_search_engines.engines import (
+ search_engine_webz as webz_engine,
+ )
+
+ snapshot = {
+ key: value
+ for key, value in SettingsManager(
+ db_session=None
+ ).default_settings.items()
+ if key.startswith("search.engine.web.webz.")
+ }
+ snapshot.update(
+ {
+ "search.engine.web.webz.api_key": API_KEY,
+ "search.engine.library.enabled": False,
+ "policy.egress_scope": "public_only",
+ "search.tool": "webz",
+ }
+ )
+ engine = create_search_engine(
+ "webz", settings_snapshot=snapshot, max_results=3
+ )
+ assert isinstance(engine, webz_engine.WebzSearchEngine)
+ engine = _wire(engine, tracker)
+ # Official response-format row within the documented results[] envelope.
+ payload = {
+ "results": [
+ {
+ "score": 7.1,
+ "article": {
+ "article_id": "32445ab27737dcdad9119b67fb1d379908a41ecf",
+ "url": "https://www.example.com/edition/",
+ "title": "Article Title",
+ "published_at": "2026-08-27T07:07:00.000+03:00",
+ "summary": "Article's extractive summary",
+ },
+ "chunk": {"text": "Relevant chunk matching the query."},
+ "metadata": {
+ "domain": "example.com",
+ "source_type": "local_news",
+ },
+ }
+ ]
+ }
+ with patch.object(
+ webz_engine, "safe_post", const_response(payload=payload)
+ ):
+ previews = engine._get_previews(QUERY)
+ assert previews[0]["date"] == "2026-08-27T07:07:00.000+03:00"
+ assert previews[0]["source"] == "example.com"
+ return previews
+
+
def _drive_serply_scholar(tracker):
engine = _build_serply(tracker, search_type="scholar")
with patch.object(
@@ -1764,6 +1822,13 @@ CASES = [
"https://serper-result.example/transformers",
"Serper's snippet",
),
+ Case(
+ "webz",
+ _drive_webz,
+ "Article Title",
+ "https://www.example.com/edition/",
+ "Relevant chunk matching the query.",
+ ),
Case(
"serply",
_drive_serply,