From 03f24c1edd87c81f5ceb511b45f26b27ef637f63 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 27 Mar 2026 21:27:51 -0700 Subject: [PATCH] fix: session_search fallback preview on summarization failure (salvage #3413) (#3478) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #3409: Add fallback to session_search to prevent false negatives on summarization failure Fixes #3409. When the auxiliary summarizer fails or returns None, the tool now returns a raw fallback preview of the matched session instead of silently dropping it and returning an empty list * fix: clean up fallback logic — separate exception handling from preview Restructure the loop: handle exceptions first (log + nullify), build entry dict once, then branch on result truthiness. Removes duplicated field assignments and makes the control flow linear. --------- Co-authored-by: devorun <130918800+devorun@users.noreply.github.com> --- tools/session_search_tool.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/session_search_tool.py b/tools/session_search_tool.py index d7cabcc9e..3ff36f940 100644 --- a/tools/session_search_tool.py +++ b/tools/session_search_tool.py @@ -392,23 +392,30 @@ def session_search( }, ensure_ascii=False) summaries = [] - for (session_id, match_info, _, _), result in zip(tasks, results): + for (session_id, match_info, conversation_text, _), result in zip(tasks, results): if isinstance(result, Exception): logging.warning( "Failed to summarize session %s: %s", - session_id, - result, - exc_info=True, + session_id, result, exc_info=True, ) - continue + result = None + + entry = { + "session_id": session_id, + "when": _format_timestamp(match_info.get("session_started")), + "source": match_info.get("source", "unknown"), + "model": match_info.get("model"), + } + if result: - summaries.append({ - "session_id": session_id, - "when": _format_timestamp(match_info.get("session_started")), - "source": match_info.get("source", "unknown"), - "model": match_info.get("model"), - "summary": result, - }) + entry["summary"] = result + else: + # Fallback: raw preview so matched sessions aren't silently + # dropped when the summarizer is unavailable (fixes #3409). + preview = (conversation_text[:500] + "\n…[truncated]") if conversation_text else "No preview available." + entry["summary"] = f"[Raw preview — summarization unavailable]\n{preview}" + + summaries.append(entry) return json.dumps({ "success": True,