The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: harden _await_disconnect_step against outer cancellation + add claim keys
kshitije5e96e8bb57a
diff --git a/gateway/run.py b/gateway/run.pyindex ddb7de0e185..125185aeaa8 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -7270,6 +7270,12 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew"config": platform_config,"attempts": 0,"next_retry": time.monotonic(),+ "credential_claim": self._adapter_credential_claim(+ adapter.platform, adapter+ ),+ "listener_claim": self._adapter_listener_claim(+ adapter.platform, adapter+ ),}logger.info("%s queued for background reconnection",diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.pyindex 59da0a5a089..eea8e316ff7 100644--- a/plugins/platforms/telegram/adapter.py+++ b/plugins/platforms/telegram/adapter.py@@ -4318,10 +4318,19 @@ class TelegramAdapter(BasePlatformAdapter):via ``_consume_abandoned_task``."""task = asyncio.ensure_future(awaitable)- if timeout <= 0:- done, _pending = await asyncio.wait({task})- else:- done, _pending = await asyncio.wait({task}, timeout=timeout)+ try:+ if timeout <= 0:+ done, _pending = await asyncio.wait({task})+ else:+ done, _pending = await asyncio.wait({task}, timeout=timeout)+ except asyncio.CancelledError:+ # Outer cancellation (e.g. the fatal handler's outer timeout) must+ # not orphan the inner task — asyncio.wait does NOT cancel its+ # futures when itself cancelled (#80598). Mirror the pattern used+ # by GatewayRunner._await_adapter_cleanup_with_timeout.+ task.cancel()+ task.add_done_callback(_consume_abandoned_task)+ raiseif task in done:# Intentional cancels (heartbeat / identity / lifecycle) surface as# CancelledError — swallow so disconnect keeps advancing.