~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(langgraph-agent): route fetch_content calls through the "📖 Reading" branch (#5011)
S6e9c789a18ca
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 3996adf7f7..f54a8fce4c 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@@ -167,7 +167,7 @@ _TOOL_DISPLAY_NAMES = {"search_zenodo": "Zenodo","search_nasa_ads": "NASA ADS","search_local": "your library",- "fetch_url": "the page",+ "fetch_content": "the page","research_subtopic": "subtopic researcher",}@@ -577,6 +577,59 @@ class LangGraphAgentStrategy(BaseSearchStrategy):return _tool_display_name(f"search_{self._search_engine_name}")return _tool_display_name(tool_name)+ def _format_tool_call_progress(self, tc, display_name: str) -> str:+ """Format a single tool call as a user-facing progress message.++ Extracted from the ``analyze_topic`` stream loop so the per-tool-type+ emoji + argument-extraction can be unit-tested without driving the full+ LangGraph stream. Behavior is preserved from the original inline block.++ - ``fetch_content`` → ``📖 Reading the page: "<url>"`` (URL arg).+ - ``research_subtopic`` → ``🔬 Investigating subtopic: "<…>"``+ (accepts ``subtopics`` list, ``subtopic``, or ``query`` for+ forward-compat with older signatures).+ - All other tools (specialized engines, ``web_search``) →+ ``🔍 Searching <Display Name>: "<query>"`` (falls back to+ ``url`` if ``query`` is absent).++ All arg extractions are truncated to 80 chars to keep the chat-progress+ line bounded.+ """+ tc_args = tc.get("args", {})+ raw_name = tc.get("name", "")+ # `fetch_content` carries a URL arg; the search tools carry a query+ # arg. Either way, show the meaningful arg in quotes so the user+ # sees what the agent is actually looking up.+ if raw_name == "fetch_content":+ target = str(tc_args.get("url", ""))[:80]+ return f'📖 Reading {display_name}: "{target}"'+ if raw_name == "research_subtopic":+ # Tool signature is `subtopics: list[str]`. Accept either key for+ # forward-compat and stringify a list as a comma list.+ raw_sub = tc_args.get(+ "subtopics",+ tc_args.get(+ "subtopic",+ tc_args.get("query", ""),+ ),+ )+ if isinstance(raw_sub, list):+ sub = ", ".join(str(s) for s in raw_sub)[:80]+ else:+ sub = str(raw_sub)[:80]+ return f'🔬 Investigating subtopic: "{sub}"'+ # Search-style tool — query arg (or URL if query missing). Use a+ # loop-local name here — do NOT reassign the `query` parameter, which+ # is still needed downstream by _synthesize_from_collector()/+ # _finalize() as the original research question.+ tc_query = str(+ tc_args.get(+ "query",+ tc_args.get("url", ""),+ )+ )[:80]+ return f'🔍 Searching {display_name}: "{tc_query}"'+def _build_egress_context(self):"""Construct the frozen ``EgressContext`` for this run.@@ -976,52 +1029,13 @@ class LangGraphAgentStrategy(BaseSearchStrategy):if tool_calls:for tc in tool_calls:- tc_args = tc.get("args", {})- raw_name = tc["name"]+ raw_name = tc.get("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- # in quotes so the user sees what the- # agent is actually looking up.- if raw_name == "fetch_url":- target = str(tc_args.get("url", ""))[- :80- ]- msg_text = f'📖 Reading {display_name}: "{target}"'- elif raw_name == "research_subtopic":- # Tool signature is `subtopics: list[str]`.- # Accept either key for forward-compat- # and stringify list as a comma list.- raw_sub = tc_args.get(- "subtopics",- tc_args.get(- "subtopic",- tc_args.get("query", ""),- ),- )- if isinstance(raw_sub, list):- sub = ", ".join(- str(s) for s in raw_sub- )[:80]- else:- sub = str(raw_sub)[:80]- msg_text = f'🔬 Investigating subtopic: "{sub}"'- else:- # Use a loop-local name here — do NOT- # reassign the `query` parameter, which- # is still needed downstream by- # _synthesize_from_collector()/_finalize()- # as the original research question.- tc_query = str(- tc_args.get(- "query",- tc_args.get("url", ""),- )- )[:80]- msg_text = f'🔍 Searching {display_name}: "{tc_query}"'+ msg_text = self._format_tool_call_progress(+ tc, display_name+ )self._update_progress(msg_text,min(85, progress),diff --git a/tests/strategies/test_langgraph_agent_strategy.py b/tests/strategies/test_langgraph_agent_strategy.pyindex d0811230f3..94198ecdd8 100644--- a/tests/strategies/test_langgraph_agent_strategy.py+++ b/tests/strategies/test_langgraph_agent_strategy.py@@ -6,6 +6,7 @@ Tests cover:- Tool factory functions- Strategy instantiation and configuration- Citation offset handling for detailed report mode+ - Tool-call progress formatting (TestToolCallProgressFormatting)- Error handling paths- Egress-scope tool filtering (TestEgressScopeFiltering at end of file)"""@@ -364,6 +365,140 @@ class TestLangGraphAgentStrategy:strategy = self._make_strategy()assert strategy._display_tool_name("search_pubmed") == "PubMed"+ 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+ strategy used to key the dict entry on the legacy ``fetch_url`` name+ while the actual tool the model sees is ``fetch_content``)."""+ strategy = self._make_strategy()+ assert strategy._display_tool_name("fetch_content") == "the page"+++# ---------------------------------------------------------------------------+# Tool-call progress formatting+#+# Regression coverage for the ``fetch_url`` → ``fetch_content`` rename:+# prior to the fix, the display-renderer branch in ``analyze_topic``+# keyed on ``raw_name == "fetch_url"``, which never matched because the+# tool the model actually invokes is ``fetch_content``. Every fetch fell+# through to the generic search-style renderer and emitted+# "🔍 Searching Fetch Content: …" instead of "📖 Reading the page: …".+# ---------------------------------------------------------------------------+++class TestToolCallProgressFormatting:+ """Pin the per-tool emoji + argument extraction in+ ``LangGraphAgentStrategy._format_tool_call_progress``.+ """++ 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 _tc(self, name, **args):+ return {"name": name, "args": args, "id": "tc_test"}++ # ---- fetch_content ------------------------------------------------------++ def test_fetch_content_renders_reading_page_with_url(self):+ """fetch_content (the actual tool name) must take the+ ``📖 Reading the page`` branch — previously keyed on the legacy+ ``fetch_url`` name and never matched."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("fetch_content", url="https://example.org/a"),+ "the page",+ )+ assert out == '📖 Reading the page: "https://example.org/a"'++ def test_fetch_content_missing_url_renders_empty_quotes(self):+ """Missing URL arg → empty quoted target, not a crash and not a+ fall-through to the search-style renderer."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("fetch_content"), "the page"+ )+ assert out == '📖 Reading the page: ""'++ def test_fetch_content_url_is_truncated_to_80_chars(self):+ strategy = self._make_strategy()+ long_url = "https://example.org/" + ("a" * 200)+ out = strategy._format_tool_call_progress(+ self._tc("fetch_content", url=long_url), "the page"+ )+ # 80 chars of URL inside the quoted target.+ quoted = out.split(chr(34))[1]+ assert len(quoted) == 80++ def test_legacy_fetch_url_name_now_falls_through_to_search(self):+ """The legacy ``fetch_url`` name no longer matches the curated+ fetch branch — it falls through to the search-style renderer.+ Pins that the rename is complete and one-sided."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("fetch_url", url="https://example.org"), "fetch_url"+ )+ # Falls through to the else branch — search-style prefix.+ assert out.startswith("🔍 Searching ")+ assert "https://example.org" in out++ # ---- research_subtopic --------------------------------------------------++ def test_research_subtopic_with_subtopics_list(self):+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("research_subtopic", subtopics=["alpha", "beta"]),+ "subtopic researcher",+ )+ assert out == '🔬 Investigating subtopic: "alpha, beta"'++ def test_research_subtopic_with_query_fallback(self):+ """Forward-compat: an older ``query`` arg is accepted."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("research_subtopic", query="legacy topic"),+ "subtopic researcher",+ )+ assert out == '🔬 Investigating subtopic: "legacy topic"'++ # ---- search / specialized engines --------------------------------------++ def test_search_tool_uses_query_arg(self):+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("search_pubmed", query="covid"),+ "PubMed",+ )+ assert out == '🔍 Searching PubMed: "covid"'++ def test_web_search_falls_back_to_url_when_query_missing(self):+ """Generic web_search — should pick the URL if query is absent+ (preserves the legacy fallback behaviour)."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("web_search", url="https://example.org"),+ "DuckDuckGo",+ )+ assert out == '🔍 Searching DuckDuckGo: "https://example.org"'++ def test_unknown_tool_uses_search_prefix(self):+ """A tool that isn't fetch_content or research_subtopic gets the+ generic search prefix (default render path)."""+ strategy = self._make_strategy()+ out = strategy._format_tool_call_progress(+ self._tc("search_arxiv", query="transformers"),+ "arXiv",+ )+ assert out == '🔍 Searching arXiv: "transformers"'+# ---------------------------------------------------------------------------# Citation offset for detailed report mode