Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/hermes/marmot/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ async def get_chat_info(self, chat_id: str) -> Dict[str, Any]:
"id": chat_id,
}

async def connect(self) -> bool:
async def connect(self, *, is_reconnect: bool = False) -> bool:
try:
await self._ensure_account_id()
await self._sync_welcomer_allowlist()
Expand Down
30 changes: 30 additions & 0 deletions integrations/hermes/marmot/tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def _mark_connected(self):
def _mark_disconnected(self):
self._running = False

async def connect(self, *, is_reconnect: bool = False) -> bool:
# Mirrors hermes-agent's keyword-only base signature; the gateway
# always calls connect(is_reconnect=...), so overrides must accept
# the keyword even when they ignore it (#836).
raise NotImplementedError

def build_source(self, **kwargs):
return SessionSource(platform=self.platform, **kwargs)

Expand Down Expand Up @@ -812,6 +818,30 @@ async def test_disconnect_clears_tool_progress_dedupe_cache(self):
self.assertEqual(adapter._tool_progress_events, {})
self.assertEqual(adapter._tool_progress_replies, {})

async def test_connect_accepts_gateway_is_reconnect_keyword(self):
# hermes-agent's gateway connects adapters via connect(is_reconnect=...)
# on cold boot and reconnect alike, so a signature without the
# keyword-only argument raises TypeError before the platform ever
# comes up (#836).
class FakeClient:
async def inbound_events(self, account_id_hex=None, group_id_hex=None):
await asyncio.Event().wait()
yield {} # unreachable: marks this as an async generator

for is_reconnect in (False, True):
with self.subTest(is_reconnect=is_reconnect):
adapter = self.adapter_module.MarmotPlatformAdapter(
self.config_cls(extra={"account_id_hex": "11" * 32}),
client=FakeClient(),
)
try:
self.assertTrue(await adapter.connect(is_reconnect=is_reconnect))
self.assertTrue(adapter._running)
self.assertIsNotNone(adapter._listener_task)
finally:
await adapter.disconnect()
self.assertIsNone(adapter._listener_task)

async def test_inbound_event_is_forwarded_to_hermes_message_event(self):
events = [
{
Expand Down