The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(discord): log the liveness-probe exit at INFO unconditionally
kshitijk4poorac39011c2e7f
diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.pyindex f5de391ec83..bc09762100a 100644--- a/plugins/platforms/discord/adapter.py+++ b/plugins/platforms/discord/adapter.py@@ -1754,12 +1754,8 @@ class DiscordAdapter(DiscordMediaMixin, BasePlatformAdapter):client = self._clientif not self._running or client is None or self._disconnecting:# The probe must never disappear silently (#118487): an exit here leaves the- # gateway alive with no watchdog, so say why before going away. Teardown- # (stopped or disconnecting) is expected; a still-running adapter losing- # its client mid-flight is not, and an operator must be able to spot it.- expected_exit = not self._running or self._disconnecting- logger.log(- logging.INFO if expected_exit else logging.WARNING,+ # gateway with no watchdog, so say why before going away.+ logger.info("[%s] Discord liveness probe exiting (running=%s, client=%s, disconnecting=%s)",self.name, self._running, client is not None, self._disconnecting,)diff --git a/tests/gateway/test_discord_liveness.py b/tests/gateway/test_discord_liveness.pyindex 0098b227b3e..adb5495293c 100644--- a/tests/gateway/test_discord_liveness.py+++ b/tests/gateway/test_discord_liveness.py@@ -357,43 +357,6 @@ async def test_disconnect_cancels_liveness_task(monkeypatch):assert adapter._liveness_task is None-async def test_unexpected_probe_exit_logs_warning(monkeypatch, caplog):- """A probe that dies while the adapter is still running must say so at WARNING (#118487).-- Teardown exits (stopped / disconnecting) are routine INFO; a still-running- adapter losing its client mid-flight leaves the gateway with no watchdog,- and an operator must be able to spot that in a default log level.- """- adapter = _make_adapter(monkeypatch, interval=0.01, threshold=3)- adapter.set_fatal_error_handler(AsyncMock())- bots = []-- def factory(**kwargs):- bot = _LiveBot(intents=kwargs["intents"], allowed_mentions=kwargs.get("allowed_mentions"))- bot.fetch_user = AsyncMock()- bots.append(bot)- return bot-- monkeypatch.setattr(adapter, "_read_websocket_health", lambda client: (True, "healthy"))-- with caplog.at_level("INFO", logger="plugins.platforms.discord.adapter"):- await _connect(adapter, monkeypatch, factory)- task = adapter._liveness_task- assert task is not None and not task.done()- caplog.clear()- adapter._client = None # client vanishes while the adapter keeps running- await _wait_until(task.done, "liveness probe did not exit after losing its client")-- exits = [r for r in caplog.records if "probe exiting" in r.getMessage()]- assert len(exits) == 1- assert exits[0].levelname == "WARNING"- assert "probe exiting (running=True, client=False" in exits[0].getMessage()-- adapter._client = bots[0]- await adapter.disconnect()--@pytest.mark.asyncio@pytest.mark.parametrize("reason", ["socket_closed", "client_closed"])async def test_closed_transport_first_strike_forces_reconnect(monkeypatch, caplog, reason):