From 76d066773a9e506cbc7af9f00d36f9ee4323e3d8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 15 Jun 2026 22:35:58 +0200 Subject: [PATCH] Improve source key extraction robustness in chat tools --- backend/agent/tools/chat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/agent/tools/chat.py b/backend/agent/tools/chat.py index ca84a76..5aa7f76 100644 --- a/backend/agent/tools/chat.py +++ b/backend/agent/tools/chat.py @@ -52,7 +52,10 @@ def _collect_sources(blocks: List[Any]) -> List[Any]: if not isinstance(block, dict): continue for source in block.get("sources") or []: - key = str(source.get("url") if isinstance(source, dict) else source) + key = str( + (source.get("url") or source.get("source_message_id") or source.get("doc_id") or source) + if isinstance(source, dict) else source + ) if key and key not in seen: seen.add(key) sources.append(source)