fix: email poller marks calendar extraction processed on LLM failure (#4622)

Move calendar processed-marker insert into the LLM success path (else branch).
Previously, the INSERT ran even after a transient LLM failure, causing the
poller to skip retrying calendar extraction on subsequent runs.

Minimal change: only touches the try/except/else control flow in
_auto_summarize_pass_single() — preserves existing formatting and line endings.
This commit is contained in:
Rudra Sarker
2026-06-24 00:32:30 +06:00
committed by GitHub
parent e9136f801a
commit 08994a0a96
+17 -14
View File
@@ -694,20 +694,23 @@ async def _auto_summarize_pass_single(days_back: int = 1, account_id: str | None
logger.warning(f"[cal-extract] JSON parse failed: {je} on raw={cal_extract[:200]!r}") logger.warning(f"[cal-extract] JSON parse failed: {je} on raw={cal_extract[:200]!r}")
except Exception as e: except Exception as e:
logger.warning(f"[cal-extract] Meeting extraction LLM call failed for uid={uid}: {e}") logger.warning(f"[cal-extract] Meeting extraction LLM call failed for uid={uid}: {e}")
# Record we processed this email so we don't re-LLM next run else:
try: # Record we processed this email so we don't re-LLM next run.
_cc = _sql3.connect(SCHEDULED_DB) # Only mark as processed on success ? transient LLM failures
_cc.execute( # are retried on the next poll run (matches summary/reply pattern).
"INSERT OR REPLACE INTO email_calendar_extractions " try:
"(message_id, owner, uid, events_created, created_at) VALUES (?, ?, ?, ?, ?)", _cc = _sql3.connect(SCHEDULED_DB)
(message_id, account_owner or "", uid.decode() if isinstance(uid, bytes) else str(uid), _cc.execute(
_cal_run_count, datetime.utcnow().isoformat()) "INSERT OR REPLACE INTO email_calendar_extractions "
) "(message_id, owner, uid, events_created, created_at) VALUES (?, ?, ?, ?, ?)",
_cc.commit() (message_id, account_owner or "", uid.decode() if isinstance(uid, bytes) else str(uid),
_cc.close() _cal_run_count, datetime.utcnow().isoformat())
_cal_existing.add(message_id) )
except Exception as ce: _cc.commit()
logger.debug(f"Could not cache calendar extraction: {ce}") _cc.close()
_cal_existing.add(message_id)
except Exception as ce:
logger.debug(f"Could not cache calendar extraction: {ce}")
if need_urgent: if need_urgent:
try: try: