Skip to content

The agent that grows with you

test(honcho): cover bot:<connection>/<profile> authors end to end

Erosikaa2c65ace0a94
diff --git a/tests/honcho_plugin/test_a2a_sessions.py b/tests/honcho_plugin/test_a2a_sessions.py
index 62c4cf67df0..6e52c63116c 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 c9c2d271ab9..1664e4c85c9 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:<connection>/<profile>``; 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:")