From d8fd45e9a81875e2878229c56fa459322905a405 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 18 Jul 2026 12:07:51 -0700 Subject: [PATCH] fix(gateway): getattr-guard _status_text for bare-instance adapter tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gateway tests build adapters via object.__new__() without __init__ (the documented bare-instance pattern), so the new _status_text dict must be accessed through getattr guards in set_status_text, the _keep_typing finally cleanup, and the Slack send_typing read — same treatment as other post-hoc __init__ attributes. Fixes CI shard 2/8 (test_active_session_text_merge). --- gateway/platforms/base.py | 16 +++++++++++++--- plugins/platforms/slack/adapter.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index df65495fe..1391395c3 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -2328,10 +2328,17 @@ class BasePlatformAdapter(ABC): Cheap, in-memory only: the next typing refresh renders the new text. No-op storage on adapters that never read ``_status_text``. """ + # getattr-guard: many gateway tests build bare adapters via + # object.__new__() without running __init__ (see AGENTS.md pitfall + # on new __init__ attributes breaking tests). + store = getattr(self, "_status_text", None) + if store is None: + store = {} + self._status_text = store if text: - self._status_text[str(chat_id)] = text + store[str(chat_id)] = text else: - self._status_text.pop(str(chat_id), None) + store.pop(str(chat_id), None) # Whether this adapter can deliver an ASYNC notification back to the agent # AFTER a turn ends — i.e. wake a fresh turn to surface a background @@ -3976,7 +3983,10 @@ class BasePlatformAdapter(ABC): except Exception: pass self._typing_paused.discard(chat_id) - self._status_text.pop(str(chat_id), None) + # getattr-guard: bare object.__new__() adapters in tests lack + # _status_text (same class of issue as _typing_paused, but that + # one is always present because those tests predate it). + getattr(self, "_status_text", {}).pop(str(chat_id), None) async def _stop_typing_refresh( self, diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index b097d651c..9c158a7f5 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -1604,7 +1604,7 @@ class SlackAdapter(BasePlatformAdapter): } try: _status = ( - self._status_text.get(str(chat_id)) + getattr(self, "_status_text", {}).get(str(chat_id)) or getattr(self.config, "typing_status_text", None) or "is thinking..." )