* 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>
This commit is contained in:
@@ -392,23 +392,30 @@ def session_search(
|
|||||||
}, ensure_ascii=False)
|
}, ensure_ascii=False)
|
||||||
|
|
||||||
summaries = []
|
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):
|
if isinstance(result, Exception):
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Failed to summarize session %s: %s",
|
"Failed to summarize session %s: %s",
|
||||||
session_id,
|
session_id, result, exc_info=True,
|
||||||
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:
|
if result:
|
||||||
summaries.append({
|
entry["summary"] = result
|
||||||
"session_id": session_id,
|
else:
|
||||||
"when": _format_timestamp(match_info.get("session_started")),
|
# Fallback: raw preview so matched sessions aren't silently
|
||||||
"source": match_info.get("source", "unknown"),
|
# dropped when the summarizer is unavailable (fixes #3409).
|
||||||
"model": match_info.get("model"),
|
preview = (conversation_text[:500] + "\n…[truncated]") if conversation_text else "No preview available."
|
||||||
"summary": result,
|
entry["summary"] = f"[Raw preview — summarization unavailable]\n{preview}"
|
||||||
})
|
|
||||||
|
summaries.append(entry)
|
||||||
|
|
||||||
return json.dumps({
|
return json.dumps({
|
||||||
"success": True,
|
"success": True,
|
||||||
|
|||||||
Reference in New Issue
Block a user