~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(egress): close inference-path fail-open (LLM/embeddings PEPs use the single primary source) (#4752)
LearningCircuitf6256f5cbd4f
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.pyindex f8adb88e02..a5ec1de893 100644--- a/src/local_deep_research/config/llm_config.py+++ b/src/local_deep_research/config/llm_config.py@@ -15,7 +15,6 @@ from ..utilities.search_utilities import remove_think_tagsfrom ..llm.providers import discover_providers # noqa: F401from ..llm.providers.base import normalize_providerfrom .thread_settings import get_setting_from_snapshot-from ..constants import DEFAULT_SEARCH_TOOLdef get_selected_llm_provider(settings_snapshot=None):@@ -126,6 +125,7 @@ def get_llm(_is_user_registered_llm,context_from_snapshot,evaluate_llm_endpoint,+ resolve_run_primary_engine,)if settings_snapshot is None:@@ -145,28 +145,26 @@ def get_llm(target=provider,)else:- primary_engine_raw = settings_snapshot.get(- "search.tool", DEFAULT_SEARCH_TOOL- )- if (- isinstance(primary_engine_raw, dict)- and "value" in primary_engine_raw- ):- primary_engine_raw = primary_engine_raw["value"]-try:- ctx = context_from_snapshot(- settings_snapshot, primary_engine_raw or DEFAULT_SEARCH_TOOL- )+ # Derive the run's primary the SAME way the search-engine+ # factory does (single source of truth), instead of the old+ # ``search.tool`` + searxng fallback. That fallback was a+ # fail-OPEN: a missing/blank primary defaulted to searxng ->+ # ADAPTIVE -> PUBLIC_ONLY -> require_local_llm stayed False ->+ # the endpoint check below was skipped, admitting a CLOUD LLM+ # for a run whose actual posture was private. resolve_run_+ # primary_engine raises on a missing/invalid primary, which we+ # treat as a hard stop here.+ primary_engine = resolve_run_primary_engine(settings_snapshot)+ ctx = context_from_snapshot(settings_snapshot, primary_engine)except ValueError as exc:- # An invalid policy config must fail closed here — this is- # essential; previously we silently fell back to ctx=None- # which skipped the LLM endpoint check entirely, opening a- # cloud-LLM bypass under the very configuration the user- # asked to be strict about. Raise PolicyDeniedError instead- # so the misconfiguration surfaces as a hard stop.+ # No configured primary, or an invalid policy config. Fail+ # closed: previously a missing primary silently fell back to+ # searxng/PUBLIC_ONLY and skipped the LLM endpoint check+ # entirely, opening a cloud-LLM bypass under the very+ # configuration the user asked to be strict about.logger.bind(policy_audit=True).warning(- "invalid egress policy configuration; refusing LLM",+ "no/invalid egress policy primary; refusing LLM",provider=provider,reason=str(exc),)diff --git a/src/local_deep_research/embeddings/embeddings_config.py b/src/local_deep_research/embeddings/embeddings_config.pyindex cf4ebee4d3..540555eeb2 100644--- a/src/local_deep_research/embeddings/embeddings_config.py+++ b/src/local_deep_research/embeddings/embeddings_config.py@@ -12,7 +12,6 @@ from loguru import loggerfrom ..config.thread_settings import get_setting_from_snapshotfrom .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.@@ -202,17 +201,16 @@ def get_embeddings(PolicyDeniedError,context_from_snapshot,evaluate_embeddings,+ resolve_run_primary_engine,)- primary = (- get_setting_from_snapshot(- "search.tool",- default=DEFAULT_SEARCH_TOOL,- settings_snapshot=settings_snapshot,- )- or DEFAULT_SEARCH_TOOL- )try:+ # Single source of truth for the primary (was: search.tool ++ # searxng fallback, a fail-OPEN — a missing primary defaulted to+ # the public searxng -> PUBLIC_ONLY -> require_local_embeddings+ # stayed False -> the corpus could ship to a cloud embedder for a+ # private run). A missing/invalid primary now raises -> fail closed.+ primary = resolve_run_primary_engine(settings_snapshot)ctx = context_from_snapshot(settings_snapshot, primary)except PolicyDeniedError:raisediff --git a/tests/config/test_llm_config.py b/tests/config/test_llm_config.pyindex 40c62d0ac8..7686c73150 100644--- a/tests/config/test_llm_config.py+++ b/tests/config/test_llm_config.py@@ -192,7 +192,8 @@ class TestGetLlm:return_value="custom_provider",):result = get_llm(- provider="custom_provider", settings_snapshot={}+ provider="custom_provider",+ settings_snapshot={"search.tool": "searxng"},)assert result is mock_llm@@ -214,7 +215,7 @@ class TestGetLlm:}.get(key, default)with pytest.raises(ValueError, match="Invalid provider"):- get_llm(settings_snapshot={})+ get_llm(settings_snapshot={"search.tool": "searxng"})def test_raises_when_model_setting_empty(self):"""get_llm() must raise ValueError when llm.model is empty string."""@@ -312,7 +313,7 @@ class TestGetLlm:model_name="custom-model",temperature=0.5,provider="custom_provider",- settings_snapshot={},+ settings_snapshot={"search.tool": "searxng"},)mock_factory.assert_called_once()@@ -346,7 +347,10 @@ class TestGetLlm:}.get(key, default)with pytest.raises(TypeError, match="invalid signature"):- get_llm(provider="bad_factory", settings_snapshot={})+ get_llm(+ provider="bad_factory",+ settings_snapshot={"search.tool": "searxng"},+ )def test_custom_factory_returning_non_basechatmodel_raises(self):"""Should raise ValueError when factory returns non-BaseChatModel."""@@ -378,7 +382,10 @@ class TestGetLlm:with pytest.raises(ValueError, match="must return a BaseChatModel"):- get_llm(provider="bad_factory", settings_snapshot={})+ get_llm(+ provider="bad_factory",+ settings_snapshot={"search.tool": "searxng"},+ )class TestWrapperStringResponse:diff --git a/tests/config/test_llm_config_behavior.py b/tests/config/test_llm_config_behavior.pyindex 5a8a75ae7c..c45043d821 100644--- a/tests/config/test_llm_config_behavior.py+++ b/tests/config/test_llm_config_behavior.py@@ -30,7 +30,12 @@ class TestApiKeyAvailabilityChecks:OpenAIProvider,)- assert OpenAIProvider.is_available(settings_snapshot={}) is False+ assert (+ OpenAIProvider.is_available(+ settings_snapshot={"search.tool": "searxng"}+ )+ is False+ )def test_openai_unavailable_with_empty_api_key(self):"""Empty string API key is falsy — treated as missing."""@@ -58,7 +63,12 @@ class TestApiKeyAvailabilityChecks:AnthropicProvider,)- assert AnthropicProvider.is_available(settings_snapshot={}) is False+ assert (+ AnthropicProvider.is_available(+ settings_snapshot={"search.tool": "searxng"}+ )+ is False+ )def test_openai_endpoint_available_with_api_key(self):from local_deep_research.llm.providers.implementations.custom_openai_endpoint import (@@ -76,7 +86,9 @@ class TestApiKeyAvailabilityChecks:)assert (- CustomOpenAIEndpointProvider.is_available(settings_snapshot={})+ CustomOpenAIEndpointProvider.is_available(+ settings_snapshot={"search.tool": "searxng"}+ )is False)@@ -89,7 +101,10 @@ class TestProviderValidation:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="Invalid provider"):- get_llm(provider="nonexistent_provider", settings_snapshot={})+ get_llm(+ provider="nonexistent_provider",+ settings_snapshot={"search.tool": "searxng"},+ )def test_error_message_lists_valid_providers(self):"""ValueError message enumerates the auto-discovered providers.@@ -104,7 +119,10 @@ class TestProviderValidation:from local_deep_research.llm.providers.base import normalize_providerwith pytest.raises(ValueError) as exc_info:- get_llm(provider="bad_provider", settings_snapshot={})+ get_llm(+ provider="bad_provider",+ settings_snapshot={"search.tool": "searxng"},+ )message = str(exc_info.value)for option in get_discovered_provider_options():assert normalize_provider(option["value"]) in message@@ -125,7 +143,11 @@ class TestModelAndProviderNameCleaning:# 'none' is valid but has no implementation, so it raises ValueError# The point is the quotes are stripped before validationwith pytest.raises(ValueError, match="No LLM provider configured"):- get_llm(model_name="x", provider="'none'", settings_snapshot={})+ get_llm(+ model_name="x",+ provider="'none'",+ settings_snapshot={"search.tool": "searxng"},+ )def test_whitespace_provider_name_cleaned(self):"""Surrounding whitespace is stripped: ' none ' → 'none'."""@@ -133,7 +155,11 @@ class TestModelAndProviderNameCleaning:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="No LLM provider configured"):- get_llm(model_name="x", provider=" none ", settings_snapshot={})+ get_llm(+ model_name="x",+ provider=" none ",+ settings_snapshot={"search.tool": "searxng"},+ )def test_uppercase_provider_lowercased(self):"""Provider name is lowercased: 'NONE' → 'none'."""@@ -141,7 +167,11 @@ class TestModelAndProviderNameCleaning:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="No LLM provider configured"):- get_llm(model_name="x", provider="NONE", settings_snapshot={})+ get_llm(+ model_name="x",+ provider="NONE",+ settings_snapshot={"search.tool": "searxng"},+ )def test_combined_quotes_whitespace_case_cleaning(self):"""Combined cleaning: \" 'None' \" → 'none'."""@@ -149,7 +179,11 @@ class TestModelAndProviderNameCleaning:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="No LLM provider configured"):- get_llm(model_name="x", provider=" 'None' ", settings_snapshot={})+ get_llm(+ model_name="x",+ provider=" 'None' ",+ settings_snapshot={"search.tool": "searxng"},+ )class TestGetSelectedLlmProvider:@@ -172,5 +206,7 @@ class TestGetSelectedLlmProvider:get_selected_llm_provider,)- result = get_selected_llm_provider(settings_snapshot={})+ result = get_selected_llm_provider(+ settings_snapshot={"search.tool": "searxng"}+ )assert result == "ollama"diff --git a/tests/config/test_llm_config_deep_coverage.py b/tests/config/test_llm_config_deep_coverage.pyindex 82212ec621..94c64b6ca6 100644--- a/tests/config/test_llm_config_deep_coverage.py+++ b/tests/config/test_llm_config_deep_coverage.py@@ -63,7 +63,10 @@ class TestGetLlmRegisteredFactory:from local_deep_research.config.llm_config import get_llm- get_llm(provider="my_custom", settings_snapshot={})+ get_llm(+ provider="my_custom",+ settings_snapshot={"search.tool": "searxng"},+ )mock_factory.assert_called_once()mock_wrap.assert_called_once()@@ -87,7 +90,10 @@ class TestGetLlmRegisteredFactory:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="must return a BaseChatModel"):- get_llm(provider="my_custom", settings_snapshot={})+ get_llm(+ provider="my_custom",+ settings_snapshot={"search.tool": "searxng"},+ )def test_factory_with_bad_signature_raises_type_error(self):def bad_factory():@@ -109,7 +115,10 @@ class TestGetLlmRegisteredFactory:from local_deep_research.config.llm_config import get_llmwith pytest.raises(TypeError, match="invalid signature"):- get_llm(provider="bad_factory", settings_snapshot={})+ get_llm(+ provider="bad_factory",+ settings_snapshot={"search.tool": "searxng"},+ )def test_registered_basechatmodel_instance_used_directly(self):mock_instance = MagicMock(spec=BaseChatModel)@@ -132,7 +141,10 @@ class TestGetLlmRegisteredFactory:from local_deep_research.config.llm_config import get_llm- get_llm(provider="my_instance", settings_snapshot={})+ get_llm(+ provider="my_instance",+ settings_snapshot={"search.tool": "searxng"},+ )# The factory path is skipped for BaseChatModel instancesmock_wrap.assert_called_once()@@ -161,7 +173,10 @@ class TestGetLlmRegisteredFactory:with pytest.raises(ValueError, match="must be either a BaseChatModel"):- get_llm(provider="weird", settings_snapshot={})+ get_llm(+ provider="weird",+ settings_snapshot={"search.tool": "searxng"},+ )# ---------------------------------------------------------------------------@@ -189,7 +204,10 @@ class TestGetLlmInvalidProvider:from local_deep_research.config.llm_config import get_llmwith pytest.raises(ValueError, match="Invalid provider"):- get_llm(provider="bogus_provider", settings_snapshot={})+ get_llm(+ provider="bogus_provider",+ settings_snapshot={"search.tool": "searxng"},+ )# ---------------------------------------------------------------------------@@ -319,7 +337,7 @@ class TestGetLlmNameCleaning:try:from local_deep_research.config.llm_config import get_llm- get_llm(settings_snapshot={})+ get_llm(settings_snapshot={"search.tool": "searxng"})if mock_init.call_args:captured["model"] = mock_init.call_args.kwargs.get("model",diff --git a/tests/config/test_llm_config_missing_coverage.py b/tests/config/test_llm_config_missing_coverage.pyindex 390a784d92..5e48c25caa 100644--- a/tests/config/test_llm_config_missing_coverage.py+++ b/tests/config/test_llm_config_missing_coverage.py@@ -26,6 +26,7 @@ THREAD_SETTINGS = "local_deep_research.config.thread_settings"def _settings_dict(overrides=None):"""Base settings dict with sensible defaults for most tests."""base = {+ "search.tool": "searxng","llm.model": "test-model","llm.temperature": 0.5,"llm.provider": "ollama",diff --git a/tests/embeddings/test_embeddings_config_deep_coverage.py b/tests/embeddings/test_embeddings_config_deep_coverage.pyindex 4074a239cc..1086fca1b6 100644--- a/tests/embeddings/test_embeddings_config_deep_coverage.py+++ b/tests/embeddings/test_embeddings_config_deep_coverage.py@@ -65,7 +65,10 @@ class TestGetEmbeddings:}get_embeddings(- settings_snapshot={"embeddings.provider": "ollama"}+ settings_snapshot={+ "embeddings.provider": "ollama",+ "search.tool": "searxng",+ })mock_provider.create_embeddings.assert_called_once()diff --git a/tests/security/test_egress_pep_llm_embeddings_callsite.py b/tests/security/test_egress_pep_llm_embeddings_callsite.pyindex 3e1286917a..1347e70ee7 100644--- a/tests/security/test_egress_pep_llm_embeddings_callsite.py+++ b/tests/security/test_egress_pep_llm_embeddings_callsite.py@@ -49,14 +49,20 @@ from local_deep_research.security.egress.policy import PolicyDeniedError# routes the call sites must both honor:# - PRIVATE_ONLY scope: context_from_snapshot IMPLIES require_local_*.# - the explicit per-knob flag with an otherwise-permissive scope.-PRIVATE_ONLY = {"policy.egress_scope": "private_only"}+# All include a "search.tool": a real run always has a configured primary, and+# the inference PEPs now resolve it via resolve_run_primary_engine (fail closed+# on a missing primary). The explicit scope still drives the decision — the+# primary value here is irrelevant to it.+PRIVATE_ONLY = {"policy.egress_scope": "private_only", "search.tool": "searxng"}LLM_REQUIRE_LOCAL_FLAG = {"policy.egress_scope": "both","llm.require_local_endpoint": True,+ "search.tool": "searxng",}EMB_REQUIRE_LOCAL_FLAG = {"policy.egress_scope": "both","embeddings.require_local": True,+ "search.tool": "searxng",}@@ -130,8 +136,9 @@ class TestGetLlmCloudBlocked:pairing the deny tests could pass for an unrelated reason."""snapshot = {"policy.egress_scope": "both",- "llm.openai.api_key": "k",- } # gitleaks:allow+ "llm.openai.api_key": "k", # gitleaks:allow+ "search.tool": "searxng",+ }with patch("local_deep_research.config.llm_config.get_llm_from_registry") as mock_registry:@@ -310,6 +317,7 @@ class TestGetEmbeddingsCloudBlocked:settings_snapshot={"policy.egress_scope": "both","embeddings.require_local": False,+ "search.tool": "searxng",},)assert result is not None@@ -416,3 +424,109 @@ class TestGetEmbeddingsSnapshotless:)assert result is not Nonemock_create.assert_called_once()+++# ---------------------------------------------------------------------------+# Inference-path fail-OPEN closed: a snapshot with NO primary must not default+# to the public searxng (-> PUBLIC_ONLY -> require_local off) and admit a cloud+# provider for a run whose actual posture is private. The PEPs resolve the+# primary via resolve_run_primary_engine (no default) and fail closed.+# ---------------------------------------------------------------------------+++class TestInferencePepsFailClosedOnMissingPrimary:+ def test_llm_refuses_cloud_provider_when_no_primary(self):+ # A present cloud key but NO search.tool (and no explicit scope =>+ # ADAPTIVE). Pre-fix: searxng default -> PUBLIC_ONLY -> require_local+ # off -> openai ADMITTED. Post-fix: fail closed before construction.+ snapshot = {"llm.openai.api_key": "k"} # gitleaks:allow+ with patch(+ "local_deep_research.config.llm_config.get_llm_from_registry"+ ) as mock_registry:+ mock_registry.return_value = Mock(spec=BaseChatModel)+ with pytest.raises(PolicyDeniedError) as exc:+ get_llm(+ provider="openai",+ model_name="gpt-4o",+ settings_snapshot=snapshot,+ )+ assert exc.value.decision.reason == "invalid_policy_config"+ mock_registry.assert_not_called()++ def test_embeddings_refuses_cloud_provider_when_no_primary(self):+ with patch.object(+ OpenAIEmbeddingsProvider,+ "create_embeddings",+ return_value=Mock(spec=Embeddings),+ ) as mock_create:+ with pytest.raises(PolicyDeniedError) as exc:+ get_embeddings(+ provider="openai",+ settings_snapshot={"embeddings.require_local": False},+ )+ assert exc.value.decision.reason == "invalid_policy_config"+ mock_create.assert_not_called()+++# ---------------------------------------------------------------------------+# The PR's HEADLINE behavior (not just the missing-primary guardrail): with a+# PRESENT primary under the default ADAPTIVE scope, the inference PEPs now+# resolve the SAME scope the factory does. A private primary ("library") forces+# PRIVATE_ONLY -> a cloud provider is denied (provider_cloud_only) — exactly the+# exfil scenario from the PR body (search_tool="library"). A public primary+# ("searxng") resolves PUBLIC_ONLY -> the same cloud provider is admitted. The+# "library" key classifies private without any DB/username lookup.+# ---------------------------------------------------------------------------+++class TestInferencePepFollowsAdaptivePrimary:+ def test_llm_private_primary_denies_cloud_under_adaptive(self):+ snapshot = {+ "search.tool": "library", # private primary, scope defaults ADAPTIVE+ "llm.openai.api_key": "k", # gitleaks:allow+ }+ with patch(+ "local_deep_research.config.llm_config.get_llm_from_registry"+ ) as mock_registry:+ mock_registry.return_value = Mock(spec=BaseChatModel)+ with pytest.raises(PolicyDeniedError) as exc:+ get_llm(+ provider="openai",+ model_name="gpt-4o",+ settings_snapshot=snapshot,+ )+ assert exc.value.decision.reason == "provider_cloud_only"+ mock_registry.assert_not_called()++ def test_llm_public_primary_admits_cloud_under_adaptive(self):+ # Mirror: a public primary under ADAPTIVE => PUBLIC_ONLY => admitted.+ snapshot = {+ "search.tool": "searxng",+ "llm.openai.api_key": "k", # gitleaks:allow+ }+ with patch(+ "local_deep_research.config.llm_config.get_llm_from_registry"+ ) as mock_registry:+ mock_registry.return_value = Mock(spec=BaseChatModel)+ result = get_llm(+ provider="openai",+ model_name="gpt-4o",+ settings_snapshot=snapshot,+ )+ assert result is not None+ mock_registry.assert_called_once()++ def test_embeddings_private_primary_denies_cloud_under_adaptive(self):+ snapshot = {"search.tool": "library"} # private primary, ADAPTIVE+ with patch.object(+ OpenAIEmbeddingsProvider,+ "create_embeddings",+ return_value=Mock(spec=Embeddings),+ ) as mock_create:+ with pytest.raises(PolicyDeniedError) as exc:+ get_embeddings(provider="openai", settings_snapshot=snapshot)+ assert exc.value.decision.reason in (+ "provider_cloud_only",+ "provider_cloud",+ )+ mock_create.assert_not_called()diff --git a/tests/test_api_key_configuration.py b/tests/test_api_key_configuration.pyindex 3d536aee0f..90250c63f4 100644--- a/tests/test_api_key_configuration.py+++ b/tests/test_api_key_configuration.py@@ -71,6 +71,7 @@ class TestAPIKeyConfiguration:def _get_base_settings(self):"""Get base settings that all tests need."""return {+ "search.tool": "searxng","llm.supports_max_tokens": True,"llm.max_tokens": 4096,"llm.context_window_unrestricted": False,@@ -429,6 +430,7 @@ class TestLLMIntegration:def _get_base_settings(self):"""Get base settings that all tests need."""return {+ "search.tool": "searxng","llm.supports_max_tokens": True,"llm.max_tokens": 4096,"llm.context_window_unrestricted": False,diff --git a/tests/test_llm/test_llm_benchmarks.py b/tests/test_llm/test_llm_benchmarks.pyindex 678adc2e35..7e4f8055d0 100644--- a/tests/test_llm/test_llm_benchmarks.py+++ b/tests/test_llm/test_llm_benchmarks.py@@ -210,7 +210,7 @@ def test_benchmark_with_custom_llm_factory():provider="benchmark_factory",model_name="accurate",temperature=0.1,- settings_snapshot={},+ settings_snapshot={"search.tool": "searxng"},)# Should create the accurate versiondiff --git a/tests/test_llm/test_llm_edge_cases.py b/tests/test_llm/test_llm_edge_cases.pyindex e818d7129d..8c49647bec 100644--- a/tests/test_llm/test_llm_edge_cases.py+++ b/tests/test_llm/test_llm_edge_cases.py@@ -161,6 +161,7 @@ def full_settings_snapshot():return {"value": value, "ui_element": "checkbox"}return {+ "search.tool": _text_param("searxng"),"llm.model": _text_param("test-model"),"llm.temperature": _number_param(0.7),"llm.provider": _text_param("test"),diff --git a/tests/test_llm/test_llm_integration.py b/tests/test_llm/test_llm_integration.pyindex b998a48b99..671a9f36fd 100644--- a/tests/test_llm/test_llm_integration.py+++ b/tests/test_llm/test_llm_integration.py@@ -56,6 +56,9 @@ def full_settings_snapshot():return {"value": value, "ui_element": "checkbox"}return {+ # Real runs always carry a primary engine; the inference+ # egress PEP now fails closed without it.+ "search.tool": _text_param("searxng"),"llm.model": _text_param("test-model"),"llm.temperature": _number_param(0.7),"llm.provider": _text_param("test"),diff --git a/tests/test_openai_api_key_usage.py b/tests/test_openai_api_key_usage.pyindex 088432c23d..401ad03c06 100644--- a/tests/test_openai_api_key_usage.py+++ b/tests/test_openai_api_key_usage.py@@ -26,6 +26,7 @@ class TestOpenAIAPIKeyUsage:type coercion in get_setting_from_snapshot()."""return {+ "search.tool": "searxng","llm.provider": "openai","llm.model": "gpt-3.5-turbo","llm.temperature": 0.7,diff --git a/tests/web/services/test_research_service_core.py b/tests/web/services/test_research_service_core.pyindex 4691187b4a..6bd3e47f1c 100644--- a/tests/web/services/test_research_service_core.py+++ b/tests/web/services/test_research_service_core.py@@ -323,7 +323,10 @@ class TestLLMInstantiation:# which fails closed for snapshot-less non-local providers — lets the# call reach the provider-name validation this test exercises.with pytest.raises(ValueError) as exc_info:- get_llm(provider="invalid_provider", settings_snapshot={})+ get_llm(+ provider="invalid_provider",+ settings_snapshot={"search.tool": "searxng"},+ )assert "Invalid provider" in str(exc_info.value)diff --git a/tests/web_search_engines/engines/test_search_engine_semantic_scholar.py b/tests/web_search_engines/engines/test_search_engine_semantic_scholar.pyindex d0b0b34088..1d87a0a695 100644--- a/tests/web_search_engines/engines/test_search_engine_semantic_scholar.py+++ b/tests/web_search_engines/engines/test_search_engine_semantic_scholar.py@@ -62,7 +62,9 @@ class TestSemanticScholarSearchEngineInit:return_value="settings-api-key",):engine = SemanticScholarSearchEngine(- settings_snapshot={"key": "value"}+ # search.tool present so the inference PEP (now fail-closed+ # on a missing primary) doesn't raise during engine init.+ settings_snapshot={"key": "value", "search.tool": "searxng"})assert engine.api_key == "settings-api-key"diff --git a/tests/web_search_engines/test_search_engine_factory_branch_coverage.py b/tests/web_search_engines/test_search_engine_factory_branch_coverage.pyindex 569097df41..2861a00a34 100644--- a/tests/web_search_engines/test_search_engine_factory_branch_coverage.py+++ b/tests/web_search_engines/test_search_engine_factory_branch_coverage.py@@ -488,6 +488,10 @@ class TestGetLlmAnthropicMissingKey:def test_anthropic_no_api_key_raises(self):settings = {+ # A real run always carries a primary; the inference PEP now fails+ # closed without it (resolve_run_primary_engine), which would raise+ # before this test reaches the Anthropic-key check.+ "search.tool": "searxng","llm.model": "claude-3-haiku","llm.temperature": 0.7,"llm.provider": "anthropic",