* 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)
|
||||
|
||||
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
|
||||
if result:
|
||||
summaries.append({
|
||||
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"),
|
||||
"summary": result,
|
||||
})
|
||||
}
|
||||
|
||||
if 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,
|
||||
|
||||
Reference in New Issue
Block a user