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(utilities): skip a non-dict entry in format_links_to_markdown (#6429)

Ehsan012011523550
diff --git a/src/local_deep_research/utilities/search_utilities.py b/src/local_deep_research/utilities/search_utilities.py
index 6472af734b..7fa96b813a 100644
--- a/src/local_deep_research/utilities/search_utilities.py
+++ b/src/local_deep_research/utilities/search_utilities.py
@@ -354,6 +354,10 @@ def format_links_to_markdown(all_links: List[Dict]) -> str:
group_to_collection: dict[tuple[str, str], str] = {}
group_to_display: dict[tuple[str, str], str] = {}
for link in all_links:
+ # Same skip as count_distinct_sources, so a malformed entry
+ # costs one bibliography line rather than the whole block.
+ if not isinstance(link, dict):
+ continue
raw = source_url_field(link)
# Skipped, not coerced. These dicts reach here straight from
# engine output on the non-LangGraph strategies, and
@@ -404,6 +408,8 @@ def format_links_to_markdown(all_links: List[Dict]) -> str:
# Emit each unique source once, in first-seen order.
seen: set[tuple[str, str]] = set()
for link in all_links:
+ if not isinstance(link, dict):
+ continue
raw = source_url_field(link)
if not isinstance(raw, str):
continue
diff --git a/tests/utilities/test_search_utilities_formatting.py b/tests/utilities/test_search_utilities_formatting.py
index 3fa197a4f7..1533dda0a5 100644
--- a/tests/utilities/test_search_utilities_formatting.py
+++ b/tests/utilities/test_search_utilities_formatting.py
@@ -1328,6 +1328,22 @@ class TestCountDistinctSources:
== 0
)
+ def test_renderer_skips_a_non_dict_entry_too(self):
+ from local_deep_research.utilities.search_utilities import (
+ count_distinct_sources,
+ format_links_to_markdown,
+ )
+
+ links = [
+ {"title": "P", "link": "https://ex.test/p", "index": "1"},
+ "not a dict",
+ None,
+ {"title": "O", "link": "https://o.test/q", "index": "2"},
+ ]
+
+ assert count_distinct_sources(links) == 2
+ assert format_links_to_markdown(links).count("URL:") == 2
+
class TestSourceUrlField:
"""Which field identifies a source, for grouping.