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(langgraph-agent): show collection names in progress summaries (#5332)

LearningCircuit924c29a17219
diff --git a/changelog.d/5332.bugfix.md b/changelog.d/5332.bugfix.md
new file mode 100644
index 0000000000..415c79c85f
--- /dev/null
+++ b/changelog.d/5332.bugfix.md
@@ -0,0 +1 @@
+The LangGraph research progress summary now shows human-readable collection names instead of raw UUIDs, and no longer prints a trailing ellipsis when every available tool is already listed.
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 0c085542b3..f619fd5b53 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
@@ -1053,6 +1053,8 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
settings_snapshot=settings_snapshot,
)
self.collector = SearchResultsCollector(self.all_links_of_system)
+ self._collection_tool_display_names: dict[str, str] = {}
+ self._collection_tool_display_names_loaded = False
fetch_mode = self.get_setting(
"search.fetch.mode", "summary_focus_query"
@@ -1177,11 +1179,70 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
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.
+ (e.g. "searxng"). ``search_collection_<id>`` tools (including
+ ``web_search`` remapped onto a collection primary engine) resolve
+ through the per-run collection-label cache instead — a raw UUID
+ title-cased through the map fallback is unreadable — and fall back
+ to the generic "Collection" when no label is known. 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)
+ resolved_tool_name = (
+ f"search_{self._search_engine_name}"
+ if tool_name == "web_search"
+ else tool_name
+ )
+ if resolved_tool_name.startswith("search_collection_"):
+ self._load_collection_display_names()
+ return self._collection_tool_display_names.get(
+ resolved_tool_name, "Collection"
+ )
+ return _tool_display_name(resolved_tool_name)
+
+ def _load_collection_display_names(
+ self, collection_configs: Optional[dict] = None
+ ) -> None:
+ """Cache each ``collection_*`` engine's configured ``display_name``,
+ keyed by tool name (``search_collection_<id>``), for progress text.
+
+ Runs at most once per research run. ``_build_tools`` passes the
+ ``search_config()`` result it already fetched so the common path
+ costs no extra DB round-trip; the no-argument call from
+ ``_display_tool_name`` is the fallback for runs that never built
+ tools, and fetches ``search_config()`` itself. Any failure —
+ including one mid-parse — is swallowed: labels are cosmetic, so a
+ broken config degrades to the generic "Collection" fallback
+ (entries parsed before the failure keep their labels) rather than
+ crashing progress reporting, and is not retried within the run.
+ """
+ if self._collection_tool_display_names_loaded:
+ return
+ self._collection_tool_display_names_loaded = True
+ try:
+ if collection_configs is None:
+ from local_deep_research.web_search_engines.search_engines_config import (
+ search_config,
+ )
+
+ collection_configs = search_config(
+ settings_snapshot=self.settings_snapshot
+ )
+ for engine_id, engine_config in collection_configs.items():
+ if not engine_id.startswith("collection_"):
+ continue
+ # ``collection_*`` entries are built internally with a
+ # guaranteed display_name; the check only shields the
+ # cache from a missing/blank label ever reaching the UI.
+ display_name = engine_config.get("display_name")
+ if isinstance(display_name, str) and display_name.strip():
+ self._collection_tool_display_names[
+ f"search_{engine_id}"
+ ] = display_name.strip()
+ except Exception:
+ logger.warning(
+ "Could not load collection display names; "
+ "using generic collection labels"
+ )
+ logger.debug("Collection display name load failure", exc_info=True)
def _format_tool_call_progress(self, tc, display_name: str) -> str:
"""Format a single tool call as a user-facing progress message.
@@ -1324,7 +1385,7 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
return (
f"Step {iteration} · {sources_so_far} source"
f"{'s' if sources_so_far != 1 else ''} gathered · "
- f"selecting next action from {listing}…"
+ f"selecting next action from {listing}"
)
def _build_egress_context(self):
@@ -1419,9 +1480,17 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
search_config,
)
- primary_source_config = search_config(
+ engines_config = search_config(
settings_snapshot=self.settings_snapshot
- ).get(self._search_engine_name)
+ )
+ # Seed the collection-label cache from the fetch we already
+ # paid for — search_config() opens a per-user DB session, so
+ # letting _display_tool_name lazy-load it again mid-run
+ # would duplicate the round-trip.
+ self._load_collection_display_names(engines_config)
+ primary_source_config = engines_config.get(
+ self._search_engine_name
+ )
primary_source_type = PrimarySourceType.SEARCH
primary_engine_classification: EngineClassification | None = (
None
diff --git a/tests/strategies/test_langgraph_agent_strategy.py b/tests/strategies/test_langgraph_agent_strategy.py
index 6b4a915621..187317b52e 100644
--- a/tests/strategies/test_langgraph_agent_strategy.py
+++ b/tests/strategies/test_langgraph_agent_strategy.py
@@ -469,6 +469,222 @@ class TestLangGraphAgentStrategy:
strategy = self._make_strategy()
assert strategy._display_tool_name("search_pubmed") == "PubMed"
+ @pytest.mark.parametrize(
+ "tool_name",
+ ("web_search", "search_collection_abc123"),
+ )
+ def test_display_tool_name_collection_uses_configured_label(
+ self, tool_name: str
+ ):
+ from local_deep_research.web_search_engines import search_engines_config
+
+ collection_engine = "collection_abc123"
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": collection_engine}
+ )
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ return_value={
+ collection_engine: {"display_name": "Library (Collection)"}
+ },
+ ):
+ display_name = strategy._display_tool_name(tool_name)
+
+ assert display_name == "Library (Collection)"
+
+ def test_display_tool_names_collection_loads_config_once(self):
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ return_value={
+ "collection_abc123": {"display_name": "Library (Collection)"},
+ "collection_def456": {"display_name": "History (Collection)"},
+ },
+ ) as search_config:
+ display_names = (
+ strategy._display_tool_name("search_collection_abc123"),
+ strategy._display_tool_name("search_collection_def456"),
+ )
+
+ assert display_names == ("Library (Collection)", "History (Collection)")
+ search_config.assert_called_once_with(
+ settings_snapshot=strategy.settings_snapshot
+ )
+
+ def test_display_tool_name_collection_load_failure_uses_generic_name(self):
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ side_effect=RuntimeError("configuration unavailable"),
+ ) as search_config:
+ display_names = (
+ strategy._display_tool_name("search_collection_abc123"),
+ strategy._display_tool_name("search_collection_abc123"),
+ )
+
+ assert display_names == ("Collection", "Collection")
+ assert all(
+ "abc123" not in display_name for display_name in display_names
+ )
+ search_config.assert_called_once_with(
+ settings_snapshot=strategy.settings_snapshot
+ )
+
+ def test_display_tool_name_collection_without_label_uses_generic_name(self):
+ from local_deep_research.web_search_engines import search_engines_config
+
+ collection_engine = "collection_abc123"
+ strategy = self._make_strategy(
+ settings_snapshot={"search.tool": collection_engine}
+ )
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ return_value={collection_engine: {"display_name": ""}},
+ ):
+ display_name = strategy._display_tool_name(
+ "search_collection_abc123"
+ )
+
+ assert display_name == "Collection"
+ assert "abc123" not in display_name
+
+ @pytest.mark.parametrize(
+ "malformed_key, malformed_value",
+ [
+ pytest.param(
+ "collection_bad",
+ {},
+ id="missing-display-name",
+ ),
+ pytest.param(
+ "collection_bad",
+ {"display_name": 42},
+ id="nonstring-display-name",
+ ),
+ pytest.param(
+ "collection_bad",
+ None,
+ id="none-value",
+ ),
+ pytest.param(
+ None,
+ {"display_name": "Bad"},
+ id="nonstring-key",
+ ),
+ ],
+ )
+ def test_display_tool_name_collection_malformed_entries_degrade(
+ self, malformed_key, malformed_value
+ ):
+ """Malformed collection entries never crash ``_display_tool_name``:
+ a missing/non-string ``display_name`` is skipped outright, while an
+ entry that breaks parsing itself (None value, non-string key) aborts
+ the rest of the load — either way the malformed tool renders the
+ generic ``Collection``, labels cached before the failure survive
+ (the valid sibling is listed first), and ``search_config`` loads
+ exactly once (#5332 follow-up)."""
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+ config = {
+ "collection_abc123": {"display_name": "Library (Collection)"},
+ malformed_key: malformed_value,
+ }
+
+ with patch.object(
+ search_engines_config, "search_config", return_value=config
+ ) as search_config:
+ valid = strategy._display_tool_name("search_collection_abc123")
+ bad = strategy._display_tool_name("search_collection_bad")
+
+ assert valid == "Library (Collection)"
+ assert bad == "Collection"
+ search_config.assert_called_once_with(
+ settings_snapshot=strategy.settings_snapshot
+ )
+
+ def test_display_tool_name_reuses_prefetched_config(self):
+ """``_build_tools`` seeds the label cache with the
+ ``search_config()`` result it already fetched; after that,
+ ``_display_tool_name`` must not trigger a second fetch (#5332
+ follow-up: avoid a duplicate per-user DB round-trip)."""
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+ strategy._load_collection_display_names(
+ {"collection_abc123": {"display_name": "Library (Collection)"}}
+ )
+
+ with patch.object(
+ search_engines_config, "search_config"
+ ) as search_config:
+ display_name = strategy._display_tool_name(
+ "search_collection_abc123"
+ )
+
+ assert display_name == "Library (Collection)"
+ search_config.assert_not_called()
+
+ def test_display_tool_name_collection_whitespace_and_padding_normalized(
+ self,
+ ):
+ """A whitespace-only ``display_name`` falls back to the generic
+ ``Collection``; a padded label is stripped before caching (#5332
+ follow-up)."""
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+ config = {
+ "collection_blank": {"display_name": " "},
+ "collection_padded": {"display_name": " Library (Collection) "},
+ }
+
+ with patch.object(
+ search_engines_config, "search_config", return_value=config
+ ):
+ blank = strategy._display_tool_name("search_collection_blank")
+ padded = strategy._display_tool_name("search_collection_padded")
+
+ assert blank == "Collection"
+ assert padded == "Library (Collection)"
+
+ def test_display_tool_name_collection_non_dict_return_uses_generic_name(
+ self,
+ ):
+ """If ``search_config()`` returns a non-dict (e.g. ``None``), the
+ fallback ``Collection`` label is used instead of crashing with
+ ``AttributeError`` on ``.items()`` (#5332 follow-up, AI-reviewer)."""
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy()
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ return_value=None,
+ ) as search_config:
+ display_name = strategy._display_tool_name(
+ "search_collection_abc123"
+ )
+
+ assert display_name == "Collection"
+ assert "abc123" not in display_name
+ search_config.assert_called_once_with(
+ settings_snapshot=strategy.settings_snapshot
+ )
+
def test_display_tool_name_fetch_content(self):
"""``fetch_content`` resolves through the curated map to "the page"
(regression for the ``fetch_url`` → ``fetch_content`` rename — the
@@ -1349,6 +1565,25 @@ class TestHeartbeatMessage:
):
assert name in out
assert "more" not in out
+ assert not out.endswith("…")
+
+ def test_uses_configured_collection_label(self):
+ from local_deep_research.web_search_engines import search_engines_config
+
+ strategy = self._make_strategy(links=[{"link": "http://a.com"}])
+ strategy._tool_names = ["search_collection_abc123"]
+
+ with patch.object(
+ search_engines_config,
+ "search_config",
+ return_value={
+ "collection_abc123": {"display_name": "History (Collection)"}
+ },
+ ):
+ out = strategy._heartbeat_message(2)
+
+ assert "History (Collection)" in out
+ assert "abc123" not in out
def test_non_search_tools_use_list_friendly_labels(self):
"""`fetch_content` ("the page") and `research_subtopic`