Skip to content

The agent that grows with you

test(gateway): pin the clarify text-fallback push and trim to two invariants

kshitijk4poor483a8b3af2e7
diff --git a/tests/gateway/test_exec_approval_timeout_notice.py b/tests/gateway/test_exec_approval_timeout_notice.py
index 5cf54458d00..952a25fb914 100644
--- a/tests/gateway/test_exec_approval_timeout_notice.py
+++ b/tests/gateway/test_exec_approval_timeout_notice.py
@@ -30,7 +30,6 @@ class _ButtonAdapter:
def __init__(self, *, editable: bool = True) -> None:
self.sends: List[str] = []
self.edits: List[tuple] = []
- self.send_metadata: List[Any] = []
self._editable = editable
def pause_typing_for_chat(self, chat_id: str) -> None:
@@ -41,7 +40,6 @@ class _ButtonAdapter:
async def send(self, chat_id: str, message: str, **k: Any) -> SendResult:
self.sends.append(message)
- self.send_metadata.append(k.get("metadata"))
return SendResult(success=True, message_id="m2")
async def edit_message(self, chat_id: str, message_id: str, content: str, **k: Any) -> SendResult:
@@ -49,12 +47,6 @@ class _ButtonAdapter:
return SendResult(success=self._editable, error=None if self._editable else "cannot edit")
-class _PlainAdapter(_ButtonAdapter):
- """No native buttons (``send_exec_approval is None`` per-class): plain-text fallback."""
-
- send_exec_approval = None
-
-
def _runner(adapter):
from gateway.run_turn_runner import TurnRunner
@@ -121,14 +113,3 @@ def test_other_settle_reasons_post_nothing(pending_entry, reason):
pending_entry.settle(reason)
assert adapter.edits == [] and adapter.sends == []
-
-
-
-def test_text_fallback_is_an_interim_approval_prompt(pending_entry):
- """#132516: the plain-text fallback carries the is_approval_prompt marker (Telegram pushes
- it, WeCom routes it via the control lane) and stays interim — ``notify`` is the turn-final
- marker A2A resolves the caller's task on, so it must not ride an approval prompt."""
- adapter = _PlainAdapter()
- _runner(adapter)._approval_notify_sync(dict(pending_entry.data))
-
- assert adapter.send_metadata == [{"thread_id": "t1", "is_approval_prompt": True, "_interim_send": True}]
diff --git a/tests/plugins/platforms/telegram/test_notification_kwargs.py b/tests/plugins/platforms/telegram/test_notification_kwargs.py
index 67259b4045e..9eadef334ac 100644
--- a/tests/plugins/platforms/telegram/test_notification_kwargs.py
+++ b/tests/plugins/platforms/telegram/test_notification_kwargs.py
@@ -20,3 +20,24 @@ def test_notification_kwargs(mode, metadata, expected):
adapter = object.__new__(TelegramAdapter)
adapter._notifications_mode = mode
assert adapter._notification_kwargs(metadata) == expected
+
+
+def test_clarify_text_fallback_pushes_in_important_mode():
+ """A failed native clarify card retries as base numbered text via adapter.send(); that
+ human-decision prompt must not go out with disable_notification=True."""
+ import asyncio
+ from types import SimpleNamespace
+ from unittest.mock import AsyncMock, MagicMock
+
+ from gateway.config import PlatformConfig
+ from gateway.run_turn_runner_clarify_delivery import text_fallback_coro
+
+ adapter = TelegramAdapter(PlatformConfig(enabled=True, token="t", extra={}))
+ adapter._bot, adapter._app = AsyncMock(), MagicMock()
+ adapter._bot.send_message = AsyncMock(return_value=SimpleNamespace(message_id=1))
+ adapter._notifications_mode = "important"
+
+ asyncio.run(text_fallback_coro(
+ adapter, chat_id="123", question="Which env?", choices=None, clarify_id="c1", session_key="s", metadata=None))
+
+ assert adapter._bot.send_message.await_args.kwargs.get("disable_notification") is None