The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): a remote default is never offered as @default to a local bot
Teknium3ee827222691
diff --git a/tests/tools/test_bot_mode_hermes_handle.py b/tests/tools/test_bot_mode_hermes_handle.pyindex 4dd43bdc67c..3b9b37c868d 100644--- a/tests/tools/test_bot_mode_hermes_handle.py+++ b/tests/tools/test_bot_mode_hermes_handle.py@@ -44,3 +44,29 @@ def test_roster_shows_one_hermes_handle(tmp_path, real_hermes):assert ("`@default`" in teammates) is real_hermesyou = bot_mode_probe.get_bot_mode_protocol_section(root).split("Your teammates")[0]assert ("You are `@default`" if real_hermes else "You are `@hermes`") in you+++def test_remote_default_is_never_offered_as_a_bare_form_a_local_profile_answers_to(tmp_path, monkeypatch):+ """A remote default beside a real remote 'hermes' profile is published as handle 'default'.+ Local resolution accepts the folder id 'default' (this install's own default), so the roster a+ named local bot sees must not offer bare @default for the remote row: the DM it invites was+ admitted locally instead of relayed. Collision forms come from the install root, not the+ sender's own profile home."""+ _capture_spawn(monkeypatch)+ monkeypatch.setattr(bot_relay, "_hermes_cli", lambda: "hermes")+ monkeypatch.setattr(bot_mode_dm, "_dm_dir", lambda: tmp_path)+ root = _managed_home(tmp_path, teammates=("researcher",))+ sender = root / "profiles" / "researcher"+ authority = _canonical_target(monkeypatch, root)+ bot_relay.write_remote_roster(sender, [+ {"profile": "default", "handle": "default", "title": "Remote Main", "connection_id": "box", "connection_label": "Box"},+ {"profile": "hermes", "handle": "hermes", "connection_id": "box", "connection_label": "Box"},+ ])++ remote = bot_mode_probe.get_bot_mode_protocol_section(sender).split("OTHER connected machines")[1]+ offered = next(line for line in remote.splitlines() if "Remote Main" in line).split("`")[1].removeprefix("@")+ ack = json.loads(bot_mode_dm.message_agent_tool(target=offered, message="ping", agent=_FakeAgent(sender)))++ assert offered != "default" and ack["status"] == "queued", (offered, ack)+ assert authority.calls == []+ assert [(e["target_connection"], e["target_profile"]) for e in bot_relay.claim_pending_envelopes(sender)] == [("box", "default")]diff --git a/tools/bot_mode_probe.py b/tools/bot_mode_probe.pyindex b43064523bc..115f6679235 100644--- a/tools/bot_mode_probe.py+++ b/tools/bot_mode_probe.py@@ -236,11 +236,14 @@ def _remote_roster(root: Path) -> list[dict]:return _swallow(_read, [])-def local_taken_forms(root: Path) -> set[str]:- """Bare forms this gateway's own profiles answer to (handles + friendly-name slugs); a remote- row must not be offered under any of them, since local resolution wins (``_resolve_local_name``)."""+def local_taken_forms(home: Path) -> set[str]:+ """Bare forms this install's own profiles answer to: folder ids, @handles and friendly-name+ slugs. A remote row must not be offered under any of them, since local resolution wins+ (``_resolve_local_name`` accepts the folder id ``default`` even while the default shows as+ @hermes). Read from the install root, so a named profile's home sees its siblings too."""+ root = _hermes_root(home)names = [name for name, _d in _roster(root)]- return {_handle(name, names) for name in names} | set(local_alias_map(root))+ return set(names) | {_handle(name, names) for name in names} | set(local_alias_map(root))def _remote_paragraph(root: Path) -> str: