fix: log swallowed exceptions in detect_threads try/except (T80.3)

The broad ``except Exception`` around detect_threads silently dropped
programmer errors (wrong kwargs, import-time failures, etc), making
diagnostics painful. Log at DEBUG with full exc_info so the failure
surfaces in local logs without breaking the close pipeline's
failure-tolerant contract.

Adds test_detect_threads_failure_is_logged using caplog.
This commit is contained in:
Joseph Doherty
2026-04-26 21:49:17 -04:00
parent dae481eb92
commit 9d06eaf57a
2 changed files with 56 additions and 1 deletions
+8 -1
View File
@@ -29,6 +29,7 @@ keeps moving.
from __future__ import annotations
import json
import logging
import uuid
from datetime import datetime, timezone
from sqlite3 import Connection
@@ -39,6 +40,8 @@ from chat.eventlog.log import append_and_apply
from chat.llm.classify import classify
from chat.llm.client import LLMClient
_log = logging.getLogger(__name__)
class ScenePOVSummary(BaseModel):
"""Classifier output: one witness's view of a closing scene.
@@ -589,7 +592,11 @@ async def apply_scene_close_summary(
open_threads=list_open_threads(conn, chat_id),
timeout_s=timeout_s,
)
except Exception:
except Exception as exc:
# T80.3: log the swallowed exception at DEBUG so a
# programmer-error flap (e.g. wrong kwarg name) surfaces in
# local logs without breaking the close pipeline.
_log.debug("detect_threads failed: %s", exc, exc_info=True)
from chat.services.thread_detection import ThreadDetectionResult
thread_result = ThreadDetectionResult()