From 08994a0a966529fde19b1391f58032ad2137fc67 Mon Sep 17 00:00:00 2001 From: Rudra Sarker <78224940+rudra496@users.noreply.github.com> Date: Wed, 24 Jun 2026 00:32:30 +0600 Subject: [PATCH] fix: email poller marks calendar extraction processed on LLM failure (#4622) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- routes/email_pollers.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/routes/email_pollers.py b/routes/email_pollers.py index 7fca02c72..e0eaf4269 100644 --- a/routes/email_pollers.py +++ b/routes/email_pollers.py @@ -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}") except Exception as 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 - try: - _cc = _sql3.connect(SCHEDULED_DB) - _cc.execute( - "INSERT OR REPLACE INTO email_calendar_extractions " - "(message_id, owner, uid, events_created, created_at) VALUES (?, ?, ?, ?, ?)", - (message_id, account_owner or "", uid.decode() if isinstance(uid, bytes) else str(uid), - _cal_run_count, datetime.utcnow().isoformat()) - ) - _cc.commit() - _cc.close() - _cal_existing.add(message_id) - except Exception as ce: - logger.debug(f"Could not cache calendar extraction: {ce}") + else: + # Record we processed this email so we don't re-LLM next run. + # Only mark as processed on success ? transient LLM failures + # are retried on the next poll run (matches summary/reply pattern). + try: + _cc = _sql3.connect(SCHEDULED_DB) + _cc.execute( + "INSERT OR REPLACE INTO email_calendar_extractions " + "(message_id, owner, uid, events_created, created_at) VALUES (?, ?, ?, ?, ?)", + (message_id, account_owner or "", uid.decode() if isinstance(uid, bytes) else str(uid), + _cal_run_count, datetime.utcnow().isoformat()) + ) + _cc.commit() + _cc.close() + _cal_existing.add(message_id) + except Exception as ce: + logger.debug(f"Could not cache calendar extraction: {ce}") if need_urgent: try: