From a2c65ace0a94feb4b4a8feb53bddaa8aaf51bd0d Mon Sep 17 00:00:00 2001 From: Erosika Date: Tue, 8 Sep 2026 16:29:23 -0400 Subject: [PATCH] test(honcho): cover bot:/ authors end to end Two senders named coder on different connections get different peers and different a2a sessions, and a userPeerAliases entry keyed by the full connection-qualified id wins. --- tests/honcho_plugin/test_a2a_sessions.py | 11 +++++++++++ tests/honcho_plugin/test_turn_author_peers.py | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/honcho_plugin/test_a2a_sessions.py b/tests/honcho_plugin/test_a2a_sessions.py index 62c4cf67df..6e52c63116 100644 --- a/tests/honcho_plugin/test_a2a_sessions.py +++ b/tests/honcho_plugin/test_a2a_sessions.py @@ -13,6 +13,7 @@ from unittest.mock import MagicMock from plugins.memory.honcho import HonchoMemoryProvider from plugins.memory.honcho.client import HonchoClientConfig from plugins.memory.honcho.session import HonchoSessionManager +from tools.bot_relay import delivery_turn_author BOT_AUTHOR = {"id": "bot:coder", "name": "coder", "is_bot": True} HUMAN_AUTHOR = {"id": "111222", "name": "Alice", "is_bot": False} @@ -129,6 +130,16 @@ class TestA2aRouting: assert ivy._a2a_session_key(BOT_AUTHOR) != holly._a2a_session_key(BOT_AUTHOR) assert ivy._a2a_session_key(BOT_AUTHOR).startswith("Bot-Chat:a2a:ivy:bot-coder-") + def test_same_named_senders_on_two_connections_get_two_sessions(self): + """A relayed envelope's author carries the sender's connection, and the a2a key keeps it.""" + provider = _provider() + east = delivery_turn_author("coder", "coder", "east") + west = delivery_turn_author("coder", "coder", "west") + + assert east["id"] == "bot:east/coder" + assert provider._a2a_session_key(east) != provider._a2a_session_key(west) + assert provider._a2a_session_key(east).startswith("Bot-Chat:a2a:hermes-assistant:bot-east-coder-") + def test_long_session_key_stays_within_the_honcho_limit(self): provider = _provider() provider._session_key = "x" * 95 diff --git a/tests/honcho_plugin/test_turn_author_peers.py b/tests/honcho_plugin/test_turn_author_peers.py index c9c2d271ab..1664e4c85c 100644 --- a/tests/honcho_plugin/test_turn_author_peers.py +++ b/tests/honcho_plugin/test_turn_author_peers.py @@ -117,6 +117,15 @@ class TestResolveAuthorPeerId: peer = mgr.resolve_author_peer_id("telegram:dm1", "bot:coder") assert peer != "coder" and peer.startswith("coder-") + def test_connection_qualified_bot_author_keeps_its_connection(self): + """The Desktop relays ``bot:/``; two connections' ``coder`` are two agents.""" + mgr = _manager(_config(user_peer_aliases={"bot:local/coder": "coder-here"}), runtime_id="7654321") + east = mgr.resolve_author_peer_id("Bot-Chat", "bot:east/coder", is_bot=True) + west = mgr.resolve_author_peer_id("Bot-Chat", "bot:west/coder", is_bot=True) + assert east != west + assert east.startswith("east-coder-") and west.startswith("west-coder-") + assert mgr.resolve_author_peer_id("Bot-Chat", "bot:local/coder", is_bot=True) == "coder-here" + def test_bot_author_without_a_profile_keeps_the_raw_id(self): mgr = _manager(_config(), runtime_id="7654321") peer = mgr.resolve_author_peer_id("telegram:dm1", "bot:")