~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
refactor(settings): add unwrap_setting utility (DRY) (#4716)
LearningCircuit8746bc99dc8f
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.pyindex 77ec86b706..e04bb87773 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@@ -37,6 +37,7 @@ from langchain_core.language_models.chat_models import BaseChatModelfrom loguru import loggerfrom sqlalchemy.orm import Session+from ...utilities.type_utils import unwrap_settingfrom ...config.llm_config import get_llmfrom ...constants import VALID_QUALITY_SCORESfrom ...database.models import Journal@@ -349,9 +350,9 @@ class JournalReputationFilter(BaseFilter):context_from_snapshot,)- primary_raw = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)- if isinstance(primary_raw, dict) and "value" in primary_raw:- primary_raw = primary_raw["value"]+ primary_raw = unwrap_setting(+ snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)+ )ctx = context_from_snapshot(snapshot, primary_raw or DEFAULT_SEARCH_TOOL)diff --git a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py b/src/local_deep_research/advanced_search_system/strategies/base_strategy.pyindex 8a2f7cb9b8..490f3bd677 100644--- a/src/local_deep_research/advanced_search_system/strategies/base_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/base_strategy.py@@ -8,6 +8,8 @@ from typing import Any, Callable, Optionalfrom loguru import logger+from ...utilities.type_utils import unwrap_setting+class BaseSearchStrategy(ABC):"""Abstract base class for all search strategies."""@@ -72,11 +74,7 @@ class BaseSearchStrategy(ABC):def get_setting(self, key: str, default=None):"""Get a setting value from the snapshot."""if key in self.settings_snapshot:- value = self.settings_snapshot[key]- # Extract value from dict structure if needed- if isinstance(value, dict) and "value" in value:- return value["value"]- return value+ return unwrap_setting(self.settings_snapshot[key])return defaultdef set_progress_callback(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.pyindex afd08bd68b..ebebd3b4f2 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@@ -19,6 +19,7 @@ from langchain_core.tools import toolfrom langgraph.errors import GraphRecursionErrorfrom loguru import logger+from ...utilities.type_utils import unwrap_settingfrom ...citation_handler import CitationHandlerfrom ..tools.fetch import FETCH_MODES, build_fetch_toolfrom .base_strategy import BaseSearchStrategy@@ -575,11 +576,9 @@ class LangGraphAgentStrategy(BaseSearchStrategy):context_from_snapshot,)- primary = self._get_current_engine_name() or self.settings_snapshot.get(- "search.tool"+ primary = self._get_current_engine_name() or unwrap_setting(+ self.settings_snapshot.get("search.tool"))- if isinstance(primary, dict) and "value" in primary:- primary = primary["value"]try:return context_from_snapshot(self.settings_snapshot, primary or DEFAULT_SEARCH_TOOLdiff --git a/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.py b/src/local_deep_research/advanced_search_system/strategies/mcp_strategy.pyindex a8a04ececc..2493eac6be 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@@ -17,6 +17,7 @@ from typing import Any, Dict, List, Optionalfrom langchain_core.language_models import BaseChatModelfrom loguru import logger+from ...utilities.type_utils import unwrap_settingfrom ...citation_handler import CitationHandlerfrom ...utilities.json_utils import extract_jsonfrom .base_strategy import BaseSearchStrategy@@ -582,11 +583,11 @@ class MCPSearchStrategy(BaseSearchStrategy):context_from_snapshot,)- _primary = self.settings_snapshot.get(- "search.tool", DEFAULT_SEARCH_TOOL+ _primary = unwrap_setting(+ 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 DEFAULT_SEARCH_TOOL)@@ -729,9 +730,9 @@ class MCPSearchStrategy(BaseSearchStrategy):# (allow MCP). Live deployments always have the module.return False, ""- primary = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)- if isinstance(primary, dict) and "value" in primary:- primary = primary["value"]+ primary = unwrap_setting(+ snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)+ )try:ctx = context_from_snapshot(snapshot, primary or DEFAULT_SEARCH_TOOL@@ -1293,11 +1294,11 @@ class MCPSearchStrategy(BaseSearchStrategy):"download_content; using SSRF-only check")else:- primary = self.settings_snapshot.get(- "search.tool", DEFAULT_SEARCH_TOOL+ primary = unwrap_setting(+ self.settings_snapshot.get(+ "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,diff --git a/src/local_deep_research/api/settings_utils.py b/src/local_deep_research/api/settings_utils.pyindex e66dda90d8..3d2b799673 100644--- a/src/local_deep_research/api/settings_utils.py+++ b/src/local_deep_research/api/settings_utils.py@@ -13,7 +13,7 @@ from loguru import loggerfrom ..settings import SettingsManagerfrom ..settings.base import ISettingsManagerfrom ..settings.manager import UI_ELEMENT_TO_SETTING_TYPE, check_env_setting-from ..utilities.type_utils import to_bool+from ..utilities.type_utils import to_bool, unwrap_settingclass InMemorySettingsManager(ISettingsManager):@@ -334,9 +334,7 @@ def extract_setting_value(return defaultif key in settings_snapshot:setting = settings_snapshot[key]- if isinstance(setting, dict) and "value" in setting:- return setting["value"]- return setting+ return unwrap_setting(setting)return defaultdiff --git a/src/local_deep_research/citation_handler.py b/src/local_deep_research/citation_handler.pyindex 16011e5c01..b7f6b567c9 100644--- a/src/local_deep_research/citation_handler.py+++ b/src/local_deep_research/citation_handler.py@@ -4,6 +4,8 @@ from typing import Any, Dict, List, Optional, Unionfrom loguru import logger+from .utilities.type_utils import unwrap_setting+class CitationHandler:"""@@ -22,11 +24,7 @@ class CitationHandler:# Try to get from settings snapshot, default to standardif "citation.handler_type" in self.settings_snapshot:value = self.settings_snapshot["citation.handler_type"]- handler_type = (- value["value"]- if isinstance(value, dict) and "value" in value- else value- )+ handler_type = unwrap_setting(value)else:handler_type = "standard"diff --git a/src/local_deep_research/citation_handlers/base_citation_handler.py b/src/local_deep_research/citation_handlers/base_citation_handler.pyindex 6fd9117bda..3f4671cf06 100644--- a/src/local_deep_research/citation_handlers/base_citation_handler.py+++ b/src/local_deep_research/citation_handlers/base_citation_handler.py@@ -8,6 +8,7 @@ from typing import Any, Callable, Dict, List, Optional, Unionfrom langchain_core.documents import Documentfrom loguru import logger+from ..utilities.type_utils import unwrap_settingfrom ..utilities.json_utils import get_llm_response_text@@ -92,11 +93,7 @@ class BaseCitationHandler(ABC):def get_setting(self, key: str, default=None):"""Get a setting value from the snapshot."""if key in self.settings_snapshot:- value = self.settings_snapshot[key]- # Extract value from dict structure if needed- if isinstance(value, dict) and "value" in value:- return value["value"]- return value+ return unwrap_setting(self.settings_snapshot[key])return defaultdef is_fact_checking_enabled(self) -> bool:diff --git a/src/local_deep_research/mcp/server.py b/src/local_deep_research/mcp/server.pyindex 910e47d16d..5c16f243a0 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_snapshotfrom local_deep_research.search_system_factory import (get_available_strategies,)+from ..utilities.type_utils import unwrap_settingfrom ..constants import DEFAULT_SEARCH_TOOL# Create FastMCP server instance@@ -714,9 +715,9 @@ 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", DEFAULT_SEARCH_TOOL)- if isinstance(primary, dict) and "value" in primary:- primary = primary["value"]+ primary = unwrap_setting(+ settings.get("search.tool", DEFAULT_SEARCH_TOOL)+ )ctx = context_from_snapshot(settings,primary or DEFAULT_SEARCH_TOOL,diff --git a/src/local_deep_research/notifications/manager.py b/src/local_deep_research/notifications/manager.pyindex ded9caf928..2518b9eb38 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_settingfrom .service import NotificationServicefrom .templates import EventTypefrom .exceptions import RateLimitError+from ..utilities.type_utils import unwrap_settingfrom ..constants import DEFAULT_SEARCH_TOOL@@ -341,9 +342,9 @@ class NotificationManager:)return service_urls- primary_raw = snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)- if isinstance(primary_raw, dict) and "value" in primary_raw:- primary_raw = primary_raw["value"]+ primary_raw = unwrap_setting(+ snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)+ )try:ctx = context_from_snapshot(snapshot, primary_raw or DEFAULT_SEARCH_TOOLdiff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.pyindex df0adfdc63..04243467e5 100644--- a/src/local_deep_research/research_library/services/download_service.py+++ b/src/local_deep_research/research_library/services/download_service.py@@ -24,6 +24,7 @@ from sqlalchemy.orm import Sessionimport pdfplumberfrom pypdf import PdfReader+from ...utilities.type_utils import unwrap_settingfrom ...constants import FILE_PATH_SENTINELS, FILE_PATH_TEXT_ONLYfrom ...database.models.download_tracker import (DownloadAttempt,@@ -279,9 +280,9 @@ class DownloadService:)return None- 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"]+ primary_raw = unwrap_setting(+ settings_snapshot.get("search.tool", DEFAULT_SEARCH_TOOL)+ )try:return context_from_snapshot(settings_snapshot,diff --git a/src/local_deep_research/search_system.py b/src/local_deep_research/search_system.pyindex f1d3cb58d6..5cd9c56ce3 100644--- a/src/local_deep_research/search_system.py+++ b/src/local_deep_research/search_system.py@@ -12,6 +12,7 @@ from .advanced_search_system.strategies.followup.enhanced_contextual_followup imEnhancedContextualFollowUpStrategy,)+from .utilities.type_utils import unwrap_settingfrom .citation_handler import CitationHandlerfrom .web_search_engines.search_engine_base import BaseSearchEnginefrom .constants import DEFAULT_SEARCH_TOOL@@ -111,11 +112,9 @@ class AdvancedSearchSystem:if self.max_iterations is None:# Use settings from snapshotif "search.iterations" in self.settings_snapshot:- value = self.settings_snapshot["search.iterations"]- if isinstance(value, dict) and "value" in value:- self.max_iterations = value["value"]- else:- self.max_iterations = value+ self.max_iterations = unwrap_setting(+ self.settings_snapshot["search.iterations"]+ )else:self.max_iterations = 1 # Default@@ -123,11 +122,9 @@ class AdvancedSearchSystem:if self.questions_per_iteration is None:# Use settings from snapshotif "search.questions_per_iteration" in self.settings_snapshot:- value = self.settings_snapshot["search.questions_per_iteration"]- if isinstance(value, dict) and "value" in value:- self.questions_per_iteration = value["value"]- else:- self.questions_per_iteration = value+ self.questions_per_iteration = unwrap_setting(+ self.settings_snapshot["search.questions_per_iteration"]+ )else:self.questions_per_iteration = 3 # Default@@ -340,11 +337,9 @@ class AdvancedSearchSystem:return Falsetry:- primary = self.settings_snapshot.get(- "search.tool", DEFAULT_SEARCH_TOOL+ primary = unwrap_setting(+ 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 DEFAULT_SEARCH_TOOL,diff --git a/src/local_deep_research/search_system_factory.py b/src/local_deep_research/search_system_factory.pyindex e6a818d058..e20f7b4e15 100644--- a/src/local_deep_research/search_system_factory.py+++ b/src/local_deep_research/search_system_factory.py@@ -8,6 +8,8 @@ from loguru import loggerfrom typing import Optional, Dict, Any, Listfrom langchain_core.language_models import BaseChatModel+from .utilities.type_utils import unwrap_setting+# Re-export from constants so existing importers don't breakfrom .constants import ( # noqa: F401AVAILABLE_STRATEGIES,@@ -22,10 +24,7 @@ def _get_setting(if not settings_snapshot or key not in settings_snapshot:return defaultvalue = settings_snapshot[key]- # Extract value from dict structure if needed- if isinstance(value, dict) and "value" in value:- return value["value"]- return value+ return unwrap_setting(value)def create_strategy(diff --git a/src/local_deep_research/security/egress/policy.py b/src/local_deep_research/security/egress/policy.pyindex 330459b2a1..9ca95c55b0 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, urlsplitfrom loguru import loggerfrom ..network_utils import is_private_ip+from ...utilities.type_utils import unwrap_settingfrom ...constants import DEFAULT_SEARCH_TOOL@@ -1326,9 +1327,7 @@ def _get_setting_value(snapshot: dict, key: str, default):schemas — both shapes appear in LDR's settings infrastructure."""raw = snapshot.get(key, default)- if isinstance(raw, dict) and "value" in raw:- return raw["value"]- return raw+ return unwrap_setting(raw)def _coerce_bool(value) -> bool:diff --git a/src/local_deep_research/security/security_settings.py b/src/local_deep_research/security/security_settings.pyindex 9cb7e4b14d..8028ebc2f5 100644--- a/src/local_deep_research/security/security_settings.py+++ b/src/local_deep_research/security/security_settings.py@@ -12,6 +12,7 @@ from typing import Any, Optional, TypeVar, Unionfrom loguru import logger+from local_deep_research.utilities.type_utils import unwrap_settingfrom local_deep_research.settings.manager import check_env_settingT = TypeVar("T", int, float, str, bool)@@ -156,8 +157,6 @@ def get_security_default(key: str, default: T) -> T:# Load from JSON defaultsif key in settings:- if isinstance(setting_data, dict) and "value" in setting_data:- return setting_data["value"]- return setting_data+ return unwrap_setting(setting_data)return defaultdiff --git a/src/local_deep_research/utilities/type_utils.py b/src/local_deep_research/utilities/type_utils.pyindex fdf45b266a..1869db286a 100644--- a/src/local_deep_research/utilities/type_utils.py+++ b/src/local_deep_research/utilities/type_utils.py@@ -54,3 +54,27 @@ def to_bool(value: Any, default: bool = False) -> bool:return default# For other types (int, etc.), use Python's bool conversionreturn bool(value)+++def unwrap_setting(val: Any) -> Any:+ """Unwrap a setting that may be stored as ``{"value": x}`` or as ``x``.++ Settings snapshots produced by ``SettingsManager.get_all_settings``+ encode each value as a dict (``{"value": actual, "ui_element": ...}``),+ while simplified snapshots use the raw value. This helper normalizes+ a single value to its unwrapped form.++ Returns ``val["value"]`` when ``val`` is a dict with a ``"value"`` key,+ otherwise ``val`` unchanged. ``None`` is preserved (use+ ``api.settings_utils.extract_setting_value`` if you want+ default-substitution semantics).++ Lives in this dependency-free leaf module (rather than+ ``api.settings_utils``) so the many low-level callers — security/egress+ policy, the search-engine factory, notifications — can import it without+ dragging in the heavy ``api`` package ``__init__`` chain, which created+ an import cycle (``cannot import name 'PolicyDeniedError'``).+ """+ if isinstance(val, dict) and "value" in val:+ return val["value"]+ return valdiff --git a/src/local_deep_research/web/api.py b/src/local_deep_research/web/api.pyindex f9877c89b5..fe6252afe3 100644--- a/src/local_deep_research/web/api.py+++ b/src/local_deep_research/web/api.py@@ -12,6 +12,7 @@ from flask import Blueprint, jsonify, request, Responsefrom loguru import loggerfrom ..api.research_functions import analyze_documents+from ..utilities.type_utils import unwrap_settingfrom ..database.session_context import get_user_db_sessionfrom ..security.decorators import require_json_bodyfrom ..utilities.db_utils import get_settings_manager@@ -90,10 +91,7 @@ def _load_user_context_into_params(all_settings = settings_manager.get_all_settings()snapshot: Dict[str, Any] = {}for key, setting in all_settings.items():- if isinstance(setting, dict) and "value" in setting:- snapshot[key] = setting["value"]- else:- snapshot[key] = setting+ snapshot[key] = unwrap_setting(setting)params["settings_snapshot"] = snapshotlogger.debug(f"Loaded settings snapshot for user '{username}' "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.pyindex 132fc34c2c..6c6aebfbd8 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@@ -15,6 +15,7 @@ from tenacity import (from tenacity.wait import wait_basefrom ..advanced_search_system.filters.base_filter import BaseFilter+from ..utilities.type_utils import unwrap_settingfrom ..config.constants import DEFAULT_MAX_FILTERED_RESULTSfrom ..config.thread_settings import get_setting_from_snapshotfrom ..security.log_sanitizer import redact_secrets, sanitize_error_message@@ -513,12 +514,10 @@ class BaseSearchEngine(ABC):otherwise an in-place mutation of that key returns a stale memo."""- scope = self.settings_snapshot.get("policy.egress_scope")- if isinstance(scope, dict) and "value" in scope:- scope = scope.get("value")- primary = self.settings_snapshot.get("search.tool")- if isinstance(primary, dict) and "value" in primary:- primary = primary.get("value")+ scope = unwrap_setting(+ self.settings_snapshot.get("policy.egress_scope")+ )+ primary = unwrap_setting(self.settings_snapshot.get("search.tool"))return (scope, primary)def _check_egress_policy(self) -> None:@@ -530,9 +529,9 @@ class BaseSearchEngine(ABC):evaluate_engine,)- primary = self.settings_snapshot.get("search.tool", self._engine_name)- if isinstance(primary, dict) and "value" in primary:- primary = primary["value"]+ primary = unwrap_setting(+ self.settings_snapshot.get("search.tool", self._engine_name)+ )ctx = context_from_snapshot(self.settings_snapshot,primary or self._engine_name,@@ -1120,11 +1119,9 @@ class BaseSearchEngine(ABC):)return None- primary_raw = self.settings_snapshot.get(- "search.tool", DEFAULT_SEARCH_TOOL+ primary_raw = unwrap_setting(+ 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 DEFAULT_SEARCH_TOOLdiff --git a/src/local_deep_research/web_search_engines/search_engine_factory.py b/src/local_deep_research/web_search_engines/search_engine_factory.pyindex 16dded653f..eb0791d263 100644--- a/src/local_deep_research/web_search_engines/search_engine_factory.py+++ b/src/local_deep_research/web_search_engines/search_engine_factory.py@@ -3,6 +3,7 @@ from typing import Any, Dict, Optionalfrom loguru import logger+from ..utilities.type_utils import unwrap_settingfrom ..security.egress.policy import PolicyDeniedErrorfrom ..security.module_whitelist import get_safe_module_classfrom .retriever_registry import retriever_registry@@ -64,9 +65,9 @@ def create_search_engine(target=engine_name,)- primary_raw = settings_snapshot.get("search.tool", engine_name)- if isinstance(primary_raw, dict) and "value" in primary_raw:- primary_raw = primary_raw["value"]+ primary_raw = unwrap_setting(+ settings_snapshot.get("search.tool", engine_name)+ )try:_ctx = context_from_snapshot(settings_snapshot,@@ -205,9 +206,9 @@ def create_search_engine(evaluate_engine,)- primary_engine_raw = settings_snapshot.get("search.tool", engine_name)- if isinstance(primary_engine_raw, dict) and "value" in primary_engine_raw:- primary_engine_raw = primary_engine_raw["value"]+ primary_engine_raw = unwrap_setting(+ settings_snapshot.get("search.tool", engine_name)+ )primary_engine = primary_engine_raw or engine_nametry:diff --git a/tests/test_unwrap_setting_no_import_cycle.py b/tests/test_unwrap_setting_no_import_cycle.pynew file mode 100644index 0000000000..532805b9aa--- /dev/null+++ b/tests/test_unwrap_setting_no_import_cycle.py@@ -0,0 +1,64 @@+"""Regression: ``unwrap_setting`` must not reintroduce the api<->security+import cycle.++``unwrap_setting`` briefly lived in ``api.settings_utils``, whose package+``__init__`` eagerly imports the research/search/security chain. Low-level+modules (``security.egress.policy``, ``web_search_engines.search_engine_factory``,+``notifications.manager``, ...) importing it created a circular import that+crashed at import time::++ ImportError: cannot import name 'PolicyDeniedError' from partially+ initialized module 'local_deep_research.security.egress.policy'++It now lives in the dependency-free ``utilities.type_utils`` leaf. These+checks import the cycle-critical modules in FRESH interpreters — pytest's+module cache would mask a real cycle within a single process — and assert+they load cleanly.+"""++import subprocess+import sys++import pytest++# Statements that sat on (or triggered) the api<->security import cycle.+# Each must import on its own in a clean interpreter.+CYCLE_CRITICAL = [+ "from local_deep_research.web_search_engines.search_engine_factory "+ "import PolicyDeniedError",+ "from local_deep_research.security.egress.policy import PolicyDeniedError",+ "import local_deep_research.security",+ "import local_deep_research.web.app_factory",+]++[email protected]("stmt", CYCLE_CRITICAL)+def test_cycle_critical_module_imports_clean(stmt):+ result = subprocess.run(+ [sys.executable, "-c", stmt],+ capture_output=True,+ text=True,+ timeout=120,+ )+ assert result.returncode == 0, (+ "Import failed (possible reintroduced circular import):\n"+ f" statement: {stmt}\n{result.stderr}"+ )+++def test_unwrap_setting_lives_in_leaf_and_behaves():+ from local_deep_research.utilities.type_utils import unwrap_setting++ assert unwrap_setting({"value": 5}) == 5+ assert unwrap_setting({"value": None}) is None+ # A dict without a "value" key is returned unchanged.+ assert unwrap_setting({"other": 1}) == {"other": 1}+ assert unwrap_setting("raw") == "raw"+ assert unwrap_setting(None) is None+++def test_settings_utils_still_reexports_unwrap_setting():+ # Backwards-compat: the function is still importable from its old home.+ from local_deep_research.api.settings_utils import unwrap_setting++ assert unwrap_setting({"value": "x"}) == "x"