Skip to content

The agent that grows with you

refactor: read retry deadlines only from the ledger

Teknium7e77401ad011
diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py
index 5757ef260e1..6fc79fcc84c 100644
--- a/gateway/platforms/base.py
+++ b/gateway/platforms/base.py
@@ -3771,7 +3771,7 @@ class BasePlatformAdapter(ABC):
schedule = getattr(self.gateway_runner, "_schedule_flood_redelivery", None)
if callable(schedule):
schedule(event.source.platform,
- profile=getattr(delivery_adapter, "_owner_profile", None), error=error)
+ profile=getattr(delivery_adapter, "_owner_profile", None))
except Exception:
logger.debug("delivery ledger update failed", exc_info=True)
diff --git a/gateway/run_startup.py b/gateway/run_startup.py
index 933b5893d62..24d187b84b7 100644
--- a/gateway/run_startup.py
+++ b/gateway/run_startup.py
@@ -304,10 +304,9 @@ class GatewayStartupMixin:
except Exception:
logger.debug(log_fmt, obligation_id, exc_info=True)
- def _schedule_flood_redelivery(self, platform, *, profile: Optional[str] = None, error: str = "",
- wait_seconds: Optional[float] = None):
+ def _schedule_flood_redelivery(self, platform, *, profile: Optional[str] = None) -> None:
"""Wake one deadline-driven ledger worker per bot identity, never sleep in a send."""
- from gateway.delivery_ledger import flood_retry_delay, flood_wait_seconds, pending_flood_retries
+ from gateway.delivery_ledger import flood_retry_delay, pending_flood_retries
target = platform if isinstance(platform, Platform) else Platform(str(platform))
key = (target.value, profile or "default")
pending = getattr(self, "_flood_redelivery_tasks", None)
@@ -351,14 +350,12 @@ class GatewayStartupMixin:
background = getattr(self, "_background_tasks", None)
if background is not None:
self._track_task_in(background, task)
- return flood_retry_delay(wait_seconds if wait_seconds is not None else flood_wait_seconds(error))
async def _arm_flood_timers_for_waiting_rows(self) -> None:
"""Recover adopted, newly refused and unsent released rows without blocking the loop."""
from gateway.delivery_ledger import pending_flood_retries
for row in await asyncio.to_thread(pending_flood_retries):
- self._schedule_flood_redelivery(row["platform"], profile=row["profile"],
- wait_seconds=row["not_before"] - time.time())
+ self._schedule_flood_redelivery(row["platform"], profile=row["profile"])
async def _redeliver_claimed_obligations(self, claimed: list) -> int:
"""Redeliver final responses for claimed rows (network half of the split): runs inside the
diff --git a/website/docs/user-guide/messaging/index.md b/website/docs/user-guide/messaging/index.md
index 7f00c17787f..dcbb981f3c4 100644
--- a/website/docs/user-guide/messaging/index.md
+++ b/website/docs/user-guide/messaging/index.md
@@ -246,7 +246,7 @@ Semantics are honest at-least-once:
may not have received it) is redelivered with a visible
"♻️ Recovered reply — … may be a duplicate" prefix. Ambiguity is labeled,
never silently resent.
-- A final send refused by a **platform rate limit** is retried automatically
+- A final send refused by **flood control** (such as Telegram rate limits) is retried automatically
after the recorded penalty expires, without requiring a reconnect or restart.
A restart during the penalty adopts the stored reply without spending a retry
attempt or re-running the agent. Retries retain the original bot profile, chat