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(cit): render Decimal and date scalars in citation identities (#7554)

Masyarakat AI9b7159610c64
diff --git a/changelog.d/7536.bugfix.md b/changelog.d/7536.bugfix.md
new file mode 100644
index 0000000000..1736d52dcb
--- /dev/null
+++ b/changelog.d/7536.bugfix.md
@@ -0,0 +1 @@
+Citation identities render `Decimal`, `date` (covering `datetime`), and `time` titles as their plain text instead of the `[non-text value omitted]` placeholder.
diff --git a/src/local_deep_research/citation_handlers/standard_citation_handler.py b/src/local_deep_research/citation_handlers/standard_citation_handler.py
index c9eeb09c11..f42dc9d9f3 100644
--- a/src/local_deep_research/citation_handlers/standard_citation_handler.py
+++ b/src/local_deep_research/citation_handlers/standard_citation_handler.py
@@ -2,7 +2,8 @@
Standard citation handler - the original implementation.
"""
-from datetime import datetime, timezone
+from datetime import date, datetime, time, timezone
+from decimal import Decimal
from typing import Any, Dict, List, Union
from langchain_core.documents import Document
@@ -15,7 +16,9 @@ def _identity_text(value: Any) -> str:
"""Render scalar metadata; containers could hide secrets from the scrubber."""
if value is None:
return ""
- if isinstance(value, (str, int, float)):
+ # datetime is a date, so date covers both; containers (dict, list, tuple,
+ # set) stay on the placeholder path — that is the #7464 security fix.
+ if isinstance(value, (str, int, float, Decimal, date, time)):
return str(value)
return "[non-text value omitted]"
diff --git a/tests/citation_handlers/test_standard_source_metadata.py b/tests/citation_handlers/test_standard_source_metadata.py
index d994170c46..8f8c5187da 100644
--- a/tests/citation_handlers/test_standard_source_metadata.py
+++ b/tests/citation_handlers/test_standard_source_metadata.py
@@ -337,6 +337,49 @@ def test_topic_and_summary_prompts_use_safe_identities_and_numbered_citations():
assert source["link"].endswith("=example-secret")
+def test_standard_formatter_renders_scalar_metadata_besides_builtin_numbers():
+ """Decimal, date, and time titles keep their identity; containers do not."""
+ from datetime import date, datetime, time
+ from decimal import Decimal
+
+ handler = StandardCitationHandler(Mock())
+ for value, rendered in [
+ (Decimal("3.14"), "3.14"),
+ (datetime(2026, 6, 14, 10, 0), "2026-06-14 10:00:00"),
+ (date(2026, 6, 14), "2026-06-14"),
+ (time(10, 0), "10:00:00"),
+ ]:
+ document = Document(
+ page_content="Evidence",
+ metadata={
+ "index": 5,
+ "title": value,
+ "source": "https://example.org/p",
+ },
+ )
+ assert handler._format_sources([document]) == (
+ f"[5] Title: {rendered}\nURL: https://example.org/p\nContent: Evidence"
+ )
+ # Containers keep the placeholder (#7464's security fix must not regress).
+ for container in [
+ {"api_key": "secret"},
+ ["secret"],
+ ("secret",),
+ {"secret"},
+ ]:
+ document = Document(
+ page_content="Evidence",
+ metadata={
+ "index": 6,
+ "title": container,
+ "source": "https://example.org/p",
+ },
+ )
+ assert "Title: [non-text value omitted]" in handler._format_sources(
+ [document]
+ )
+
+
@pytest.mark.parametrize(
("title", "source", "expected_title", "expected_url"),
[