The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): unbounded-wait branch owned by _wait_bounded_or_release; update-notification adapter guard
Tekniumd1727ec9f989
diff --git a/gateway/run_notifications.py b/gateway/run_notifications.pyindex ad314224046..caaeed14636 100644--- a/gateway/run_notifications.py+++ b/gateway/run_notifications.py@@ -610,14 +610,12 @@ class GatewayNotificationsMixin:platform = Platform(platform_str)adapter = self.adapters.get(platform)-- if not adapter and chat_id:+ if chat_id and not adapter:# The update finished, but the target platform has not reconnected yet (common right# after the restart that `hermes update` triggers). A definitive skip would delete the# markers and silently lose the notification; preserve them for a later retry.return _defer("Update notification deferred: %s adapter not connected yet", platform_str)-- if adapter and chat_id:+ if chat_id:metadata = self._pending_marker_metadata(platform, chat_id, pending, adapter)from tools.ansi_strip import strip_ansioutput = strip_ansi(output).strip()diff --git a/gateway/run_startup.py b/gateway/run_startup.pyindex 62b758fb496..d8d3a1d2d08 100644--- a/gateway/run_startup.py+++ b/gateway/run_startup.py@@ -141,7 +141,11 @@ class GatewayStartupMixin:) -> set:"""``asyncio.wait`` (which, unlike wait_for/gather+timeout, does NOT cancel on timeout) withthe gate-release warning + late-failure callback every boot gate uses. Returns ``done``.- ``warn_fmt`` takes ``%.0fs`` (timeout) and optionally ``%d`` (pending count)."""+ ``warn_fmt`` takes ``%.0fs`` (timeout) and optionally ``%d`` (pending count). A non-positive+ ``timeout`` opts out of the bound ("wait forever")."""+ if timeout <= 0:+ await asyncio.gather(*tasks, return_exceptions=True)+ return set(tasks)done, pending = await asyncio.wait(tasks, timeout=timeout)if pending:args = (timeout, len(pending)) if warn_fmt.count("%") > 1 else (timeout,)@@ -164,22 +168,15 @@ class GatewayStartupMixin:from gateway.run import _startup_restore_drain_timeout_secstasks = list(getattr(self, "_startup_restore_tasks", []) or [])if tasks:- timeout = _startup_restore_drain_timeout_secs()- if timeout > 0:- # Tasks that outlive the gate get a late-failure callback: their normal done-callback- # only discards them from _background_tasks, so a LATER failure would be swallowed.- done = await self._wait_bounded_or_release(- set(tasks), timeout,- "Startup-restore gate released after %.0fs with %d boot auto-resume turn(s) "- "still running; draining inbound queue now (resume slots already claimed, so no "- "duplicate agents). Slow turn(s) continue in the background.",- "background startup auto-resume task failed after gate release",- level=logging.DEBUG,- )- else:- # Non-positive timeout => opt out of the bound ("wait forever").- await asyncio.gather(*tasks, return_exceptions=True)- done = set(tasks)+ # Tasks that outlive the gate get a late-failure callback: their normal done-callback+ # only discards them from _background_tasks, so a LATER failure would be swallowed.+ done = await self._wait_bounded_or_release(+ set(tasks), _startup_restore_drain_timeout_secs(),+ "Startup-restore gate released after %.0fs with %d boot auto-resume turn(s) "+ "still running; draining inbound queue now (resume slots already claimed, so no "+ "duplicate agents). Slow turn(s) continue in the background.",+ "background startup auto-resume task failed after gate release", level=logging.DEBUG,+ )report = self._late_failure_callback("startup auto-resume task failed", level=logging.DEBUG)for task in done:report(task)@@ -229,16 +226,16 @@ class GatewayStartupMixin:boot_task = asyncio.create_task(_boot_sends())timeout = _startup_restore_drain_timeout_secs()- if timeout > 0:- await self._wait_bounded_or_release(- {boot_task}, timeout,- "Boot-path sends still running after %.0fs; releasing inbound gate so other "- "platforms are not frozen. Restart notification / obligation redelivery continue "- "in the background.",- "background boot-path send failed after gate release: see traceback", track=True,- )- else:- await boot_task+ if timeout <= 0:+ await boot_task # unbounded: a failing send surfaces here (unlike the gate path)+ return+ await self._wait_bounded_or_release(+ {boot_task}, timeout,+ "Boot-path sends still running after %.0fs; releasing inbound gate so other "+ "platforms are not frozen. Restart notification / obligation redelivery continue "+ "in the background.",+ "background boot-path send failed after gate release: see traceback", track=True,+ )async def _clear_resume_pending_for_claimed_obligations(self, claimed: list, *, require_success: bool = False