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.

refactor: centralize the default search engine as DEFAULT_SEARCH_TOOL (#4547)

LearningCircuit59d78579b798
diff --git a/src/local_deep_research/advanced_search_system/filters/journal_reputation_filter.py b/src/local_deep_research/advanced_search_system/filters/journal_reputation_filter.py
index 9a7d750377..47962a54a8 100644
--- a/src/local_deep_research/advanced_search_system/filters/journal_reputation_filter.py
+++ b/src/local_deep_research/advanced_search_system/filters/journal_reputation_filter.py
@@ -56,6 +56,7 @@ from ...utilities.resource_utils import safe_close
from ...utilities.thread_context import get_search_context
from ...web_search_engines.search_engine_factory import create_search_engine
from .base_filter import BaseFilter
+from ...constants import DEFAULT_SEARCH_TOOL
# Patterns that indicate a venue is a conference, not a journal.
@@ -349,10 +350,12 @@ class JournalReputationFilter(BaseFilter):
context_from_snapshot,
)
- primary_raw = snapshot.get("search.tool", "searxng")
+ primary_raw = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)
if isinstance(primary_raw, dict) and "value" in primary_raw:
primary_raw = primary_raw["value"]
- ctx = context_from_snapshot(snapshot, primary_raw or "searxng")
+ ctx = context_from_snapshot(
+ snapshot, primary_raw or DEFAULT_SEARCH_TOOL
+ )
return ctx.scope in (EgressScope.PRIVATE_ONLY, EgressScope.STRICT)
except PolicyDeniedError:
# Corrupt/unknown scope value — we cannot certify that a public
diff --git a/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py b/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py
index c1c213e0c0..c277a8e94d 100644
--- a/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py
@@ -26,6 +26,7 @@ from ...utilities.search_utilities import (
)
from ..tools.fetch import FETCH_MODES, build_fetch_tool
from .base_strategy import BaseSearchStrategy
+from ...constants import DEFAULT_SEARCH_TOOL
# ---------------------------------------------------------------------------
# Constants
@@ -554,7 +555,7 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
primary = primary["value"]
try:
return context_from_snapshot(
- self.settings_snapshot, primary or "searxng"
+ self.settings_snapshot, primary or DEFAULT_SEARCH_TOOL
)
except PolicyDeniedError:
# Corrupted/invalid policy.egress_scope — re-raise so the
diff --git a/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.py b/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.py
index e130a10608..523fca4471 100644
--- a/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.py
@@ -24,6 +24,7 @@ from ...utilities.search_utilities import (
format_links_to_markdown,
)
from .base_strategy import BaseSearchStrategy
+from ...constants import DEFAULT_SEARCH_TOOL
# ReAct prompt template - simplified for better model compatibility
# Note: {current_date} placeholder is replaced at runtime
@@ -609,11 +610,13 @@ class MCPSearchStrategy(BaseSearchStrategy):
context_from_snapshot,
)
- _primary = self.settings_snapshot.get("search.tool", "searxng")
+ _primary = self.settings_snapshot.get(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
if isinstance(_primary, dict) and "value" in _primary:
_primary = _primary["value"]
policy_ctx = context_from_snapshot(
- self.settings_snapshot, _primary or "searxng"
+ self.settings_snapshot, _primary or DEFAULT_SEARCH_TOOL
)
except PolicyDeniedError:
# Corrupt / incoherent scope → fail closed: expose no
@@ -754,11 +757,13 @@ class MCPSearchStrategy(BaseSearchStrategy):
# (allow MCP). Live deployments always have the module.
return False, ""
- primary = snapshot.get("search.tool", "searxng")
+ primary = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)
if isinstance(primary, dict) and "value" in primary:
primary = primary["value"]
try:
- ctx = context_from_snapshot(snapshot, primary or "searxng")
+ ctx = context_from_snapshot(
+ snapshot, primary or DEFAULT_SEARCH_TOOL
+ )
except (PolicyDeniedError, ValueError) as exc:
# Policy itself is unevaluable (corrupt scope value).
# Cannot certify MCP is safe — fail closed.
@@ -1317,13 +1322,14 @@ class MCPSearchStrategy(BaseSearchStrategy):
)
else:
primary = self.settings_snapshot.get(
- "search.tool", "searxng"
+ "search.tool", DEFAULT_SEARCH_TOOL
)
if isinstance(primary, dict) and "value" in primary:
primary = primary["value"]
try:
egress_context = context_from_snapshot(
- self.settings_snapshot, primary or "searxng"
+ self.settings_snapshot,
+ primary or DEFAULT_SEARCH_TOOL,
)
except (PolicyDeniedError, ValueError) as exc:
# Snapshot was supplied but the policy itself
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 7e4c8c9c9d..dc0298eae4 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -15,6 +15,7 @@ from ..utilities.search_utilities import remove_think_tags
from ..llm.providers import discover_providers # noqa: F401
from ..llm.providers.base import normalize_provider
from .thread_settings import get_setting_from_snapshot
+from ..constants import DEFAULT_SEARCH_TOOL
# Valid provider options
VALID_PROVIDERS = [
@@ -323,7 +324,9 @@ def get_llm(
target=provider,
)
else:
- primary_engine_raw = settings_snapshot.get("search.tool", "searxng")
+ primary_engine_raw = settings_snapshot.get(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
if (
isinstance(primary_engine_raw, dict)
and "value" in primary_engine_raw
@@ -332,7 +335,7 @@ def get_llm(
try:
ctx = context_from_snapshot(
- settings_snapshot, primary_engine_raw or "searxng"
+ settings_snapshot, primary_engine_raw or DEFAULT_SEARCH_TOOL
)
except ValueError as exc:
# An invalid policy config must fail closed here — this is
diff --git a/src/local_deep_research/constants.py b/src/local_deep_research/constants.py
index 56854ce04e..a9231890b3 100644
--- a/src/local_deep_research/constants.py
+++ b/src/local_deep_research/constants.py
@@ -21,6 +21,18 @@ BROWSER_USER_AGENT = (
)
+# Code-side single source of truth for the default search engine, used by
+# every reader that needs a fallback for a MISSING ``search.tool`` setting
+# (partial snapshots from the programmatic API, un-bootstrapped settings
+# DBs). Import THIS instead of hardcoding the string literal: scattered
+# literals are how the old ``"auto"`` default lingered across ~30 sites and
+# had to be hunted down one by one when the meta engines were removed.
+# Must match the registered default in defaults/default_settings.json —
+# pinned by tests/test_constants.py::test_default_search_tool_matches_registry.
+# Mirrors the DEFAULT_EGRESS_SCOPE pattern in security/egress/policy.py.
+DEFAULT_SEARCH_TOOL: str = "searxng"
+
+
# --- Research status values ---
# Frontend helpers: src/local_deep_research/web/static/js/config/constants.js
# Injected via: src/local_deep_research/web/app_factory.py (inject_frontend_constants)
diff --git a/src/local_deep_research/embeddings/embeddings_config.py b/src/local_deep_research/embeddings/embeddings_config.py
index e2b29469e1..cf4ebee4d3 100644
--- a/src/local_deep_research/embeddings/embeddings_config.py
+++ b/src/local_deep_research/embeddings/embeddings_config.py
@@ -12,6 +12,7 @@ from loguru import logger
from ..config.thread_settings import get_setting_from_snapshot
from .providers.base import BaseEmbeddingProvider
+from ..constants import DEFAULT_SEARCH_TOOL
# Internal: list of provider strings accepted by get_embeddings().
# Not re-exported from embeddings/__init__.py — call sites should not import it.
@@ -206,10 +207,10 @@ def get_embeddings(
primary = (
get_setting_from_snapshot(
"search.tool",
- default="searxng",
+ default=DEFAULT_SEARCH_TOOL,
settings_snapshot=settings_snapshot,
)
- or "searxng"
+ or DEFAULT_SEARCH_TOOL
)
try:
ctx = context_from_snapshot(settings_snapshot, primary)
diff --git a/src/local_deep_research/embeddings/providers/implementations/sentence_transformers.py b/src/local_deep_research/embeddings/providers/implementations/sentence_transformers.py
index 40f1333caa..860c799199 100644
--- a/src/local_deep_research/embeddings/providers/implementations/sentence_transformers.py
+++ b/src/local_deep_research/embeddings/providers/implementations/sentence_transformers.py
@@ -7,6 +7,7 @@ from loguru import logger
from ....config.thread_settings import get_setting_from_snapshot
from ..base import BaseEmbeddingProvider
+from ....constants import DEFAULT_SEARCH_TOOL
class SentenceTransformersProvider(BaseEmbeddingProvider):
@@ -112,10 +113,10 @@ class SentenceTransformersProvider(BaseEmbeddingProvider):
_primary = (
get_setting_from_snapshot(
"search.tool",
- default="searxng",
+ default=DEFAULT_SEARCH_TOOL,
settings_snapshot=settings_snapshot,
)
- or "searxng"
+ or DEFAULT_SEARCH_TOOL
)
require_local = context_from_snapshot(
settings_snapshot, _primary
diff --git a/src/local_deep_research/mcp/server.py b/src/local_deep_research/mcp/server.py
index dfbb923fe6..910e47d16d 100644
--- a/src/local_deep_research/mcp/server.py
+++ b/src/local_deep_research/mcp/server.py
@@ -46,6 +46,7 @@ from local_deep_research.api.settings_utils import create_settings_snapshot
from local_deep_research.search_system_factory import (
get_available_strategies,
)
+from ..constants import DEFAULT_SEARCH_TOOL
# Create FastMCP server instance
mcp = FastMCP(
@@ -713,12 +714,12 @@ def _egress_audit_net(settings: Dict[str, Any]):
if not settings or get_active_context() is not None:
return nullcontext()
try:
- primary = settings.get("search.tool", "searxng")
+ primary = settings.get("search.tool", DEFAULT_SEARCH_TOOL)
if isinstance(primary, dict) and "value" in primary:
primary = primary["value"]
ctx = context_from_snapshot(
settings,
- primary or "searxng",
+ primary or DEFAULT_SEARCH_TOOL,
username=settings.get("_username"),
)
except (PolicyDeniedError, ValueError):
@@ -906,7 +907,7 @@ def get_configuration() -> Dict[str, Any]:
},
"search": {
"default_engine": extract_setting_value(
- settings, "search.tool", "searxng"
+ settings, "search.tool", DEFAULT_SEARCH_TOOL
),
"default_strategy": extract_setting_value(
settings, "search.search_strategy", "source-based"
diff --git a/src/local_deep_research/news/api.py b/src/local_deep_research/news/api.py
index f26907700e..c2d5538e10 100644
--- a/src/local_deep_research/news/api.py
+++ b/src/local_deep_research/news/api.py
@@ -21,6 +21,7 @@ from .exceptions import (
NotImplementedException,
NewsAPIException,
)
+from ..constants import DEFAULT_SEARCH_TOOL
# Removed welcome feed import - no placeholders
# get_db_setting not available in merged codebase
@@ -921,10 +922,12 @@ def _validate_subscription_policy(
snapshot = settings_manager.get_settings_snapshot()
if not isinstance(snapshot, dict):
return None
- primary = settings_manager.get_setting("search.tool", "searxng")
+ primary = settings_manager.get_setting(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
try:
ctx = context_from_snapshot(
- snapshot, primary or "searxng", username=user_id
+ snapshot, primary or DEFAULT_SEARCH_TOOL, username=user_id
)
except PolicyDeniedError as exc:
return f"egress policy refused: {exc.decision.reason}"
diff --git a/src/local_deep_research/notifications/manager.py b/src/local_deep_research/notifications/manager.py
index 125b5c3042..ded9caf928 100644
--- a/src/local_deep_research/notifications/manager.py
+++ b/src/local_deep_research/notifications/manager.py
@@ -13,6 +13,7 @@ from ..settings.env_registry import get_env_setting
from .service import NotificationService
from .templates import EventType
from .exceptions import RateLimitError
+from ..constants import DEFAULT_SEARCH_TOOL
class NotificationManager:
@@ -340,11 +341,13 @@ class NotificationManager:
)
return service_urls
- primary_raw = snapshot.get("search.tool", "searxng")
+ primary_raw = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)
if isinstance(primary_raw, dict) and "value" in primary_raw:
primary_raw = primary_raw["value"]
try:
- ctx = context_from_snapshot(snapshot, primary_raw or "searxng")
+ ctx = context_from_snapshot(
+ snapshot, primary_raw or DEFAULT_SEARCH_TOOL
+ )
except (PolicyDeniedError, ValueError) as exc:
# Snapshot present but policy cannot be evaluated. The
# previous bare-except dropped to "return service_urls"
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index bc0833fd91..3fe75de7a0 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -59,6 +59,7 @@ from ...database.models.queue import TaskMetadata
from ...database.thread_local_session import thread_cleanup
from ...security.rate_limiter import limiter
from ...config.paths import get_library_directory
+from ...constants import DEFAULT_SEARCH_TOOL
rag_bp = Blueprint("rag", __name__, url_prefix="/library")
@@ -515,10 +516,10 @@ def get_available_models():
primary = (
get_setting_from_snapshot(
"search.tool",
- default="searxng",
+ default=DEFAULT_SEARCH_TOOL,
settings_snapshot=settings_snapshot,
)
- or "searxng"
+ or DEFAULT_SEARCH_TOOL
)
ctx = context_from_snapshot(settings_snapshot, primary)
if not ctx.require_local_embeddings:
diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.py
index 573d3d43a4..e27bbb54bf 100644
--- a/src/local_deep_research/research_library/services/download_service.py
+++ b/src/local_deep_research/research_library/services/download_service.py
@@ -63,6 +63,7 @@ from ..downloaders import (
OpenAlexDownloader,
GenericDownloader,
)
+from ...constants import DEFAULT_SEARCH_TOOL
class DownloadService:
@@ -278,13 +279,13 @@ class DownloadService:
)
return None
- primary_raw = settings_snapshot.get("search.tool", "searxng")
+ primary_raw = settings_snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)
if isinstance(primary_raw, dict) and "value" in primary_raw:
primary_raw = primary_raw["value"]
try:
return context_from_snapshot(
settings_snapshot,
- primary_raw or "searxng",
+ primary_raw or DEFAULT_SEARCH_TOOL,
username=self.username,
)
except (PolicyDeniedError, ValueError) as exc:
diff --git a/src/local_deep_research/research_library/services/library_rag_service.py b/src/local_deep_research/research_library/services/library_rag_service.py
index 78b69b74a6..07509629ab 100644
--- a/src/local_deep_research/research_library/services/library_rag_service.py
+++ b/src/local_deep_research/research_library/services/library_rag_service.py
@@ -40,6 +40,7 @@ import hashlib
from faiss import IndexFlatL2, IndexFlatIP, IndexHNSWFlat
from langchain_community.vectorstores import FAISS
from langchain_community.docstore.in_memory import InMemoryDocstore
+from ...constants import DEFAULT_SEARCH_TOOL
# Module-level locks serialise the FAISS save+record critical section and the
@@ -217,8 +218,10 @@ class LibraryRAGService:
# code both hardcoded scope=BOTH and gated on the raw flag, so
# a PRIVATE_ONLY corpus could be embedded by a cloud provider.
primary = (
- _get_setting_value(settings_snapshot, "search.tool", "searxng")
- or "searxng"
+ _get_setting_value(
+ settings_snapshot, "search.tool", DEFAULT_SEARCH_TOOL
+ )
+ or DEFAULT_SEARCH_TOOL
)
try:
policy_ctx = context_from_snapshot(
diff --git a/src/local_deep_research/scheduler/background.py b/src/local_deep_research/scheduler/background.py
index d7dd2b371c..7912e4ab26 100644
--- a/src/local_deep_research/scheduler/background.py
+++ b/src/local_deep_research/scheduler/background.py
@@ -27,6 +27,7 @@ from ..security.log_sanitizer import redact_secrets
from ..research_library.services.library_rag_service import LibraryRAGService
from ..database.library_init import get_default_library_id
from ..database.models.library import Document, DocumentCollection
+from ..constants import DEFAULT_SEARCH_TOOL
SCHEDULER_AVAILABLE = True # Always available since it's a required dependency
@@ -725,9 +726,11 @@ class BackgroundJobScheduler:
snapshot = settings_manager.get_settings_snapshot()
if not isinstance(snapshot, dict):
return
- primary = settings_manager.get_setting("search.tool", "searxng")
+ primary = settings_manager.get_setting(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
ctx = context_from_snapshot(
- snapshot, primary or "searxng", username=username
+ snapshot, primary or DEFAULT_SEARCH_TOOL, username=username
)
set_active_context(ctx)
except Exception:
@@ -1565,7 +1568,7 @@ class BackgroundJobScheduler:
else:
# Use the user's default search tool from their settings
default_search_tool = settings_snapshot.get(
- "search.tool", "searxng"
+ "search.tool", DEFAULT_SEARCH_TOOL
)
logger.info(
f"Using user's default search tool: '{default_search_tool}' for {subscription['id']}"
diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.py
index 48f8398a4b..f1d3cb58d6 100644
--- a/src/local_deep_research/search_system.py
+++ b/src/local_deep_research/search_system.py
@@ -14,6 +14,7 @@ from .advanced_search_system.strategies.followup.enhanced_contextual_followup im
from .citation_handler import CitationHandler
from .web_search_engines.search_engine_base import BaseSearchEngine
+from .constants import DEFAULT_SEARCH_TOOL
class AdvancedSearchSystem:
@@ -339,12 +340,14 @@ class AdvancedSearchSystem:
return False
try:
- primary = self.settings_snapshot.get("search.tool", "searxng")
+ primary = self.settings_snapshot.get(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
if isinstance(primary, dict) and "value" in primary:
primary = primary["value"]
ctx = context_from_snapshot(
self.settings_snapshot,
- primary or "searxng",
+ primary or DEFAULT_SEARCH_TOOL,
username=self.username,
)
except (PolicyDeniedError, ValueError):
@@ -393,7 +396,7 @@ class AdvancedSearchSystem:
tool_setting = self.settings_snapshot.get("search.tool", {})
search_tool = (
- tool_setting.get("value", "searxng")
+ tool_setting.get("value", DEFAULT_SEARCH_TOOL)
if isinstance(tool_setting, dict)
else tool_setting
)
diff --git a/src/local_deep_research/security/egress/policy.py b/src/local_deep_research/security/egress/policy.py
index f348c46d3f..330459b2a1 100644
--- a/src/local_deep_research/security/egress/policy.py
+++ b/src/local_deep_research/security/egress/policy.py
@@ -27,6 +27,7 @@ from urllib.parse import unquote, urlsplit
from loguru import logger
from ..network_utils import is_private_ip
+from ...constants import DEFAULT_SEARCH_TOOL
# Bounded DNS lookup timeout; getaddrinfo has no native timeout kwarg, so
@@ -540,8 +541,10 @@ def filter_candidates_by_egress(
):
return engine_names
primary = (
- _get_setting_value(settings_snapshot, "search.tool", "searxng")
- or "searxng"
+ _get_setting_value(
+ settings_snapshot, "search.tool", DEFAULT_SEARCH_TOOL
+ )
+ or DEFAULT_SEARCH_TOOL
)
ctx = context_from_snapshot(
settings_snapshot,
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index 05cb4b933b..4ec648e97d 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -68,6 +68,7 @@ from .globals import (
is_research_active,
set_termination_flag,
)
+from ...constants import DEFAULT_SEARCH_TOOL
# Create a Blueprint for the research application
research_bp = Blueprint("research", __name__)
@@ -166,7 +167,9 @@ def _extract_research_params(data, settings_manager):
search_engine = data.get("search_engine") or data.get("search_tool")
if not search_engine:
- search_engine = settings_manager.get_setting("search.tool", "searxng")
+ search_engine = settings_manager.get_setting(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
max_results = data.get("max_results")
time_period = data.get("time_period")
@@ -240,10 +243,14 @@ def _precheck_engine_policy(settings_manager, params, search_engine, username):
# a global settings save).
_apply_policy_overrides(policy_snapshot, params)
- primary = settings_manager.get_setting("search.tool", "searxng")
+ primary = settings_manager.get_setting(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
try:
policy_ctx = context_from_snapshot(
- policy_snapshot, primary or "searxng", username=username
+ policy_snapshot,
+ primary or DEFAULT_SEARCH_TOOL,
+ username=username,
)
except PolicyDeniedError as exc:
return (
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index d91d03b42c..4044e7cb18 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -84,6 +84,7 @@ from ..utils.templates import render_template_with_defaults
from ...security import safe_get
from ..warning_checks import calculate_warnings
+from ...constants import DEFAULT_SEARCH_TOOL
# Settings whose changes trigger a warning recalculation.
WARNING_AFFECTING_KEYS = frozenset(
@@ -249,10 +250,12 @@ def _model_list_local_only() -> bool:
snap = sm.get_settings_snapshot()
if isinstance(snap, dict):
- primary = sm.get_setting("search.tool", "searxng")
+ primary = sm.get_setting("search.tool", DEFAULT_SEARCH_TOOL)
return bool(
context_from_snapshot(
- snap, primary or "searxng", username=username
+ snap,
+ primary or DEFAULT_SEARCH_TOOL,
+ username=username,
).require_local_llm
)
return False
@@ -488,7 +491,7 @@ def save_all_settings(db_session=None, settings_manager=None):
elif key == "llm.provider":
value = "ollama"
elif key == "search.tool":
- value = "searxng"
+ value = DEFAULT_SEARCH_TOOL
elif key in ["app.theme", "app.default_theme"]:
value = "dark"
else:
@@ -2143,7 +2146,7 @@ def fix_corrupted_settings(db_session=None):
default_value = 1024
elif setting.key.startswith("search."):
if setting.key == "search.tool":
- default_value = "searxng"
+ default_value = DEFAULT_SEARCH_TOOL
elif setting.key == "search.max_results":
default_value = 10
elif setting.key == "search.region":
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index 809c4f08c8..209659889f 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -34,6 +34,7 @@ from ...utilities.threading_utils import thread_context, thread_with_app_context
from ..models.database import calculate_duration
from ...settings.env_registry import get_env_setting
from .socket_service import SocketIOService
+from ...constants import DEFAULT_SEARCH_TOOL
OUTPUT_DIR = get_research_outputs_directory()
@@ -938,7 +939,7 @@ def run_research_process(research_id, query, mode, **kwargs):
try:
_egress_primary = settings_snapshot.get(
- "search.tool", "searxng"
+ "search.tool", DEFAULT_SEARCH_TOOL
)
if (
isinstance(_egress_primary, dict)
@@ -947,7 +948,7 @@ def run_research_process(research_id, query, mode, **kwargs):
_egress_primary = _egress_primary["value"]
_egress_ctx = context_from_snapshot(
settings_snapshot,
- _egress_primary or "searxng",
+ _egress_primary or DEFAULT_SEARCH_TOOL,
username=username,
)
_set_egress_ctx(_egress_ctx)
diff --git a/src/local_deep_research/web/warning_checks/__init__.py b/src/local_deep_research/web/warning_checks/__init__.py
index 284e46827e..5335f3d63b 100644
--- a/src/local_deep_research/web/warning_checks/__init__.py
+++ b/src/local_deep_research/web/warning_checks/__init__.py
@@ -33,6 +33,7 @@ from ...security.egress.warnings import (
check_effective_scope,
check_public_egress_enabled,
)
+from ...constants import DEFAULT_SEARCH_TOOL
def _safe_check(check_fn, *args, **kwargs):
@@ -137,7 +138,7 @@ def calculate_warnings() -> List[dict]:
settings_manager.get_setting("embeddings.require_local", False)
)
primary_engine = settings_manager.get_setting(
- "search.tool", "searxng"
+ "search.tool", DEFAULT_SEARCH_TOOL
)
# Resolve the EFFECTIVE posture so the banners are accurate. For
@@ -162,7 +163,7 @@ def calculate_warnings() -> List[dict]:
# classification — accuracy here is best-effort by design.
_eff_ctx = context_from_snapshot(
_snap,
- primary_engine or "searxng",
+ primary_engine or DEFAULT_SEARCH_TOOL,
username=username,
allow_dns=False,
)
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_elasticsearch.py b/src/local_deep_research/web_search_engines/engines/search_engine_elasticsearch.py
index 689053a3a5..31b0750a14 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_elasticsearch.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_elasticsearch.py
@@ -7,6 +7,7 @@ from langchain_core.language_models import BaseLLM
from ...config import search_config
from ...constants import SNIPPET_LENGTH_SHORT
from ..search_engine_base import BaseSearchEngine
+from ...constants import DEFAULT_SEARCH_TOOL
class ElasticsearchSearchEngine(BaseSearchEngine):
@@ -49,10 +50,10 @@ class ElasticsearchSearchEngine(BaseSearchEngine):
primary = (
get_setting_from_snapshot(
"search.tool",
- default="searxng",
+ default=DEFAULT_SEARCH_TOOL,
settings_snapshot=snapshot,
)
- or "searxng"
+ or DEFAULT_SEARCH_TOOL
)
ctx = context_from_snapshot(snapshot, primary)
return ctx.scope in (
diff --git a/src/local_deep_research/web_search_engines/search_engine_base.py b/src/local_deep_research/web_search_engines/search_engine_base.py
index 1560ae3e3d..52a86ec563 100644
--- a/src/local_deep_research/web_search_engines/search_engine_base.py
+++ b/src/local_deep_research/web_search_engines/search_engine_base.py
@@ -22,6 +22,7 @@ from ..security.log_sanitizer import redact_secrets
from ..utilities.thread_context import clear_search_context, set_search_context
from .rate_limiting import RateLimitError, get_tracker
+from ..constants import DEFAULT_SEARCH_TOOL
class AdaptiveWait(wait_base):
@@ -1084,12 +1085,14 @@ class BaseSearchEngine(ABC):
)
return None
- primary_raw = self.settings_snapshot.get("search.tool", "searxng")
+ primary_raw = self.settings_snapshot.get(
+ "search.tool", DEFAULT_SEARCH_TOOL
+ )
if isinstance(primary_raw, dict) and "value" in primary_raw:
primary_raw = primary_raw["value"]
try:
return context_from_snapshot(
- self.settings_snapshot, primary_raw or "searxng"
+ self.settings_snapshot, primary_raw or DEFAULT_SEARCH_TOOL
)
except (PolicyDeniedError, ValueError) as exc:
logger.bind(policy_audit=True).warning(
diff --git a/tests/test_constants.py b/tests/test_constants.py
new file mode 100644
index 0000000000..fca48da20d
--- /dev/null
+++ b/tests/test_constants.py
@@ -0,0 +1,32 @@
+"""Tests for project-wide constants in local_deep_research.constants."""
+
+import json
+
+from local_deep_research.constants import DEFAULT_SEARCH_TOOL
+from local_deep_research.defaults import DEFAULTS_DIR
+
+
+def test_default_search_tool_matches_registry():
+ """DEFAULT_SEARCH_TOOL (the code-side fallback every reader imports for a
+ missing ``search.tool`` setting) must equal the registered default in
+ defaults/default_settings.json.
+
+ This single test replaces scattered ``"searxng"`` fallback literals and
+ is what prevents the code/registry drift that let the old ``"auto"``
+ default linger across ~30 sites. Mirrors
+ test_egress_policy::test_default_scope_constant_matches_registry.
+ """
+ path = DEFAULTS_DIR / "default_settings.json"
+ assert path.exists()
+ with open(path, encoding="utf-8-sig") as f:
+ registry = json.load(f)
+ assert registry["search.tool"]["value"] == DEFAULT_SEARCH_TOOL
+
+
+def test_default_search_tool_is_a_registered_option():
+ """The default must be one of the engines offered in the settings UI."""
+ path = DEFAULTS_DIR / "default_settings.json"
+ with open(path, encoding="utf-8-sig") as f:
+ registry = json.load(f)
+ option_values = {opt["value"] for opt in registry["search.tool"]["options"]}
+ assert DEFAULT_SEARCH_TOOL in option_values