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.

fix(ui): show actual search engine name instead of "web_search" (#4470)

LearningCircuita8736b03448c
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 c277a8e94d..69ef4b87fd 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
@@ -533,6 +533,20 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
logger.debug("Could not extract engine name from class")
return ""
+ def _display_tool_name(self, tool_name: str) -> str:
+ """Return a user-friendly display name for a tool.
+
+ ``web_search`` is a generic wrapper around the user's configured
+ engine. Resolve it through the same curated ``_TOOL_DISPLAY_NAMES``
+ map as the specialized search tools (keyed by ``search_<engine>``)
+ so the UI shows brand-correct names like "DuckDuckGo" or
+ "the web (SearXNG)" instead of the raw lowercase engine id
+ (e.g. "searxng"). Other tools use the map directly.
+ """
+ if tool_name == "web_search":
+ return _tool_display_name(f"search_{self._search_engine_name}")
+ return _tool_display_name(tool_name)
+
def _build_egress_context(self):
"""Construct the frozen ``EgressContext`` for this run.
@@ -750,8 +764,10 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
if not tools:
return self._error_result("No tools available")
# Stash tool names for the per-step heartbeat — gives the user
- # concrete info ("from web_search, search_pubmed, …") instead of
- # a vague spinner while the LLM picks its next move.
+ # concrete info ("from the web (SearXNG), PubMed, …") instead of
+ # a vague spinner while the LLM picks its next move. The raw ids
+ # are mapped to friendly names at render time via
+ # ``_display_tool_name``.
self._tool_names = [getattr(t, "name", "?") for t in tools]
# Build system prompt — fetch_line wording mirrors the active mode
@@ -922,7 +938,9 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
for tc in tool_calls:
tc_args = tc.get("args", {})
raw_name = tc["name"]
- friendly = _tool_display_name(raw_name)
+ display_name = self._display_tool_name(
+ raw_name
+ )
# `fetch_url` carries a URL arg; the
# search tools carry a query arg.
# Either way, show the meaningful arg
@@ -932,9 +950,7 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
target = str(tc_args.get("url", ""))[
:80
]
- msg_text = (
- f'📖 Reading {friendly}: "{target}"'
- )
+ msg_text = f'📖 Reading {display_name}: "{target}"'
elif raw_name == "research_subtopic":
# Tool signature is `subtopics: list[str]`.
# Accept either key for forward-compat
@@ -965,12 +981,15 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
tc_args.get("url", ""),
)
)[:80]
- msg_text = f'🔍 Searching {friendly}: "{tc_query}"'
+ msg_text = f'🔍 Searching {display_name}: "{tc_query}"'
self._update_progress(
msg_text,
min(85, progress),
{
"phase": "tool_call",
+ # Keep the stable tool id in
+ # metadata; the friendly label
+ # already lives in msg_text.
"tool": raw_name,
"iteration": iteration,
},
@@ -983,16 +1002,18 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
msgs = chunk["tools"].get("messages", [])
for msg in msgs:
tool_name = getattr(msg, "name", "tool")
- friendly = _tool_display_name(tool_name)
+ display_name = self._display_tool_name(tool_name)
preview = str(getattr(msg, "content", ""))[
:150
].replace("\n", " ")
self._update_progress(
- f"📄 From {friendly}: {preview}",
+ f"📄 From {display_name}: {preview}",
min(
85,
10 + int((iteration / effective_max) * 75) + 3,
),
+ # Keep the stable tool id in metadata; the
+ # friendly label already lives in the message.
{"phase": "observation", "tool": tool_name},
)
# After every tool result, the agent immediately re-
@@ -1021,7 +1042,9 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
# the line ballooning when many specialised
# engines are enabled.
names = getattr(self, "_tool_names", []) or []
- sample = ", ".join(names[:3])
+ sample = ", ".join(
+ self._display_tool_name(n) for n in names[:3]
+ )
more = (
f" +{len(names) - 3} more" if len(names) > 3 else ""
)
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 523fca4471..1a1e0e89f9 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
@@ -322,12 +322,13 @@ class MCPSearchStrategy(BaseSearchStrategy):
progress,
{"phase": "thought", "thought": thought},
)
+ display_name = self._display_tool_name(tool_name)
self._update_progress(
- f'ACTION: Using {tool_name} - "{search_query}"',
+ f'ACTION: Using {display_name} - "{search_query}"',
progress + 2,
{
"phase": "tool_call",
- "tool": tool_name,
+ "tool": display_name,
"arguments": arguments,
},
)
@@ -359,7 +360,7 @@ class MCPSearchStrategy(BaseSearchStrategy):
progress + 4,
{
"phase": "observation",
- "tool": tool_name,
+ "tool": self._display_tool_name(tool_name),
"result_length": len(observation),
"content": obs_preview,
},
@@ -1634,6 +1635,18 @@ class MCPSearchStrategy(BaseSearchStrategy):
logger.debug("best-effort class name extraction", exc_info=True)
return ""
+ def _display_tool_name(self, tool_name: str) -> str:
+ """Return a user-friendly display name for a tool.
+
+ ``web_search`` is a generic tool wrapper — show the user's selected
+ search engine so the UI says e.g. "selected engine (searxng)"
+ instead of "web_search".
+ """
+ if tool_name == "web_search":
+ engine = self._get_current_engine_name() or "web search"
+ return f"{engine} (primary)"
+ return tool_name
+
def _execute_specialized_search(
self, arguments: Dict[str, Any], engine_name: str
) -> Dict[str, Any]:
diff --git a/tests/strategies/test_langgraph_agent_strategy.py b/tests/strategies/test_langgraph_agent_strategy.py
index 83c84b28b1..d0fbd74108 100644
--- a/tests/strategies/test_langgraph_agent_strategy.py
+++ b/tests/strategies/test_langgraph_agent_strategy.py
@@ -296,6 +296,41 @@ class TestLangGraphAgentStrategy:
strategy = self._make_strategy(search=mock_search, settings_snapshot={})
assert strategy._search_engine_name == "duckduckgo"
+ def test_display_tool_name_web_search_uses_curated_engine_name(self):
+ """``web_search`` renders the configured engine through the curated
+ display-name map, with brand-correct casing rather than the raw
+ lowercase id."""
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": {"value": "duckduckgo"}}
+ )
+ assert strategy._display_tool_name("web_search") == "DuckDuckGo"
+
+ def test_display_tool_name_web_search_searxng(self):
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": {"value": "searxng"}}
+ )
+ assert strategy._display_tool_name("web_search") == "the web (SearXNG)"
+
+ def test_display_tool_name_web_search_multiword_engine(self):
+ """Multi-word engine ids resolve to their curated display name."""
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": {"value": "semantic_scholar"}}
+ )
+ assert strategy._display_tool_name("web_search") == "Semantic Scholar"
+
+ def test_display_tool_name_web_search_unknown_engine_titlecased(self):
+ """Engines absent from the curated map fall back to a cleaned,
+ title-cased name — never the raw lowercase id."""
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": {"value": "tavily"}}
+ )
+ assert strategy._display_tool_name("web_search") == "Tavily"
+
+ def test_display_tool_name_specialized_tool_uses_map(self):
+ """Non-web_search tools keep their curated display name."""
+ strategy = self._make_strategy()
+ assert strategy._display_tool_name("search_pubmed") == "PubMed"
+
# ---------------------------------------------------------------------------
# Citation offset for detailed report mode
@@ -884,6 +919,93 @@ class TestQueryParameterNotClobbered:
assert result["findings"][0]["question"] == original_query
+class TestProgressMetadataKeepsStableId:
+ """Progress metadata ``tool`` must carry the STABLE tool id while the
+ human-readable engine label appears only in the message text.
+
+ A prior revision of this PR overwrote ``metadata["tool"]`` with the
+ friendly label; that discards the only machine-readable id reaching
+ progress consumers. This pins the id-in-metadata / label-in-message
+ split so a regression can't silently re-introduce the overwrite.
+ """
+
+ def _make_strategy(self):
+ from local_deep_research.advanced_search_system.strategies.langgraph_agent_strategy import (
+ LangGraphAgentStrategy,
+ )
+
+ return LangGraphAgentStrategy(
+ model=MagicMock(),
+ search=MagicMock(),
+ all_links_of_system=[],
+ settings_snapshot={"search.tool": {"value": "duckduckgo"}},
+ )
+
+ def test_tool_call_metadata_keeps_id_label_in_message(self):
+ from langchain_core.messages import AIMessage
+
+ strategy = self._make_strategy()
+
+ tool_call_msg = AIMessage(
+ content="",
+ tool_calls=[
+ {
+ "name": "web_search",
+ "args": {"query": "anything"},
+ "id": "call_1",
+ "type": "tool_call",
+ }
+ ],
+ )
+ answer_msg = AIMessage(content="Final answer with [1].")
+
+ mock_agent = MagicMock()
+ mock_agent.stream.return_value = iter(
+ [
+ {"agent": {"messages": [tool_call_msg]}},
+ {"agent": {"messages": [answer_msg]}},
+ ]
+ )
+
+ progress_calls = []
+
+ def capture(*args, **kwargs):
+ message = args[0] if args else kwargs.get("message", "")
+ metadata = (
+ args[2] if len(args) > 2 else kwargs.get("metadata", {})
+ ) or {}
+ progress_calls.append((message, metadata))
+
+ with (
+ patch.object(strategy, "_build_tools", return_value=[MagicMock()]),
+ patch("langchain.agents.create_agent", return_value=mock_agent),
+ patch.object(strategy, "_update_progress", side_effect=capture),
+ patch.object(
+ strategy,
+ "_finalize",
+ return_value={
+ "findings": [],
+ "current_knowledge": "",
+ "iterations": 1,
+ "error": None,
+ },
+ ),
+ ):
+ strategy.analyze_topic("test query")
+
+ tool_calls = [
+ (msg, md)
+ for msg, md in progress_calls
+ if md.get("phase") == "tool_call"
+ ]
+ assert tool_calls, "expected a tool_call progress event"
+ message, metadata = tool_calls[0]
+ # metadata keeps the stable id ...
+ assert metadata["tool"] == "web_search"
+ # ... while the user sees the brand label in the message text.
+ assert "DuckDuckGo" in message
+
+
# ---------------------------------------------------------------------------
# Egress-scope tool filtering
# ---------------------------------------------------------------------------