The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): clear resume_pending for all claimed ledger rows before any redelivery send
Kshitij Kapoor41e29a601e8b
diff --git a/gateway/run.py b/gateway/run.pyindex 8092f3f435d..7d3eadccffe 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -12109,6 +12109,25 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatewif not claimed:return 0+ # Clear resume_pending for EVERY claimed row up front, before any+ # send. Claiming already spent one of the row's redelivery attempts —+ # the answer is in the ledger, so the resume path must never re-run+ # these turns. Doing this per-row as the loop reaches each send left+ # a window: when a slow/flood-limited send held the loop past the+ # inbound-gate timeout, _schedule_resume_pending_sessions could+ # replay turns for rows the loop had not reached yet (#91969).+ for row in claimed:+ session_key = row.get("session_key") or ""+ if not session_key:+ continue+ try:+ await self.async_session_store.clear_resume_pending(session_key)+ except Exception:+ logger.debug(+ "clear_resume_pending failed for %s", session_key,+ exc_info=True,+ )+redelivered = 0for row in claimed:try:@@ -12131,21 +12150,6 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew{"thread_id": row["thread_id"]} if row.get("thread_id") else None)- # Clear resume_pending BEFORE the send. The answer is already in- # the ledger — a hung/flood-limited send must not also replay the- # turn when the inbound gate times out and schedules resume- # (#91969). Failed sends already skipped resume; this just does- # that bookkeeping first.- session_key = row.get("session_key") or ""- if session_key:- try:- await self.async_session_store.clear_resume_pending(session_key)- except Exception:- logger.debug(- "clear_resume_pending failed for %s", session_key,- exc_info=True,- )-try:result = await adapter.send(chat_id=row["chat_id"],