Skip to content

The agent that grows with you

fix(send_message): the out-of-process fallback discovers plugins first

Tekniumf066fa708c0f
diff --git a/gateway/platforms/ADDING_A_PLATFORM.md b/gateway/platforms/ADDING_A_PLATFORM.md
index dfb8c71d137..aa4759c7d1a 100644
--- a/gateway/platforms/ADDING_A_PLATFORM.md
+++ b/gateway/platforms/ADDING_A_PLATFORM.md
@@ -137,7 +137,7 @@ If your platform supports interactive button/menu messages, implement these for
| `send_model_picker(...)` | Interactive `/model` picker. Used by Telegram, Discord, and Slack (Socket Mode). |
| `send_choice_picker(...)` | Flat single-level picker for finite-choice commands (`/reasoning`, `/fast`). Implemented by Telegram (inline keyboard), Discord (select menu), and Matrix (reactions). Platforms without it fall back to the text status card automatically. |
-See `gateway/platforms/telegram.py`, `discord.py`, and `plugins/platforms/whatsapp_cloud/adapter.py` for reference implementations. The button-callback id convention (`cl:<id>:<idx>`, `appr:<id>:<choice>`, `sc:<choice>:<id>`) is shared across adapters — match it so the gateway-side resolvers work without modification.
+See `plugins/platforms/telegram/adapter.py`, `plugins/platforms/discord/adapter.py`, and `plugins/platforms/whatsapp_cloud/adapter.py` for reference implementations. The button-callback id convention (`cl:<id>:<idx>`, `appr:<id>:<choice>`, `sc:<choice>:<id>`) is shared across adapters — match it so the gateway-side resolvers work without modification.
### Required function
diff --git a/tests/tools/test_send_message_tool.py b/tests/tools/test_send_message_tool.py
index 0bd1cf95f98..c76d52ec5af 100644
--- a/tests/tools/test_send_message_tool.py
+++ b/tests/tools/test_send_message_tool.py
@@ -1572,6 +1572,29 @@ class TestSendViaAdapterStandaloneFallback:
assert set(result) == {"error"}
assert "boom!" in result["error"]
+ @pytest.mark.asyncio
+ async def test_fresh_process_discovers_plugins_before_the_fallback(self, monkeypatch):
+ """No gateway and nothing registered yet (cron/CLI process): the fallback runs plugin
+ discovery, so a platform without a dedicated route still reaches its standalone sender."""
+ from tools.send_message_tool import _send_via_adapter
+ from gateway.platform_registry import platform_registry
+
+ sent = []
+
+ async def send(pconfig, chat_id, message, **kwargs):
+ sent.append((chat_id, message))
+ return {"success": True, "platform": "fakeplatform", "chat_id": chat_id}
+
+ monkeypatch.setattr("gateway.run._gateway_runner_ref", lambda: None)
+ monkeypatch.setattr("hermes_cli.plugins.discover_plugins",
+ lambda *a, **k: platform_registry.register(self._make_entry(send)))
+ try:
+ result = await _send_via_adapter(_FakePlatform("fakeplatform"), SimpleNamespace(extra={}), "chat-1", "hi")
+ finally:
+ platform_registry.unregister("fakeplatform")
+
+ assert result["success"] is True and sent == [("chat-1", "hi")]
+
class TestSendTelegramThreadNotFoundRetry:
"""Tests for thread-not-found retry behaviour in _send_telegram (#27012)."""
diff --git a/tools/send_message_tool.py b/tools/send_message_tool.py
index 5c3cfa5a0fc..cee7755fa6d 100644
--- a/tools/send_message_tool.py
+++ b/tools/send_message_tool.py
@@ -566,8 +566,8 @@ async def _send_via_adapter(platform, pconfig, chat_id, chunk, *, thread_id=None
return {"success": True, "message_id": result.message_id}
return {"error": f"Adapter send failed: {_bounded_send_error(result.error)}"}
try:
- from gateway.platform_registry import platform_registry
- sender = platform_registry.get(platform_name).standalone_sender_fn
+ # Discover first: a fresh process (cron/CLI) has not registered plugin platforms yet.
+ sender, _ = _plugin_standalone_sender(platform_name)
except Exception:
sender = None
if sender is None: