Skip to content

The agent that grows with you

feat(agent): core Bot Mode teammate protocol — stable-tier prompt section

Teknium2b39e92e9e4f
diff --git a/agent/agent_init.py b/agent/agent_init.py
index 4249979e487..b6b1ca486ac 100644
--- a/agent/agent_init.py
+++ b/agent/agent_init.py
@@ -1906,6 +1906,10 @@ def init_agent(
except Exception:
pass
+ # Bot Mode teammate protocol section (tools/bot_mode_probe.py) — pure
+ # filesystem reads, no warm needed. Silent on non-Bot-Mode installs.
+ agent._bot_mode_protocol = bool(_agent_section.get("bot_mode_protocol", True))
+
# Per-platform prompt-hint overrides (config.yaml → platform_hints).
# Lets an enterprise admin append to or replace Hermes' built-in
# platform hint for a single messaging platform (e.g. WhatsApp) without
diff --git a/agent/system_prompt.py b/agent/system_prompt.py
index e5b70c8d901..2a32e03f157 100644
--- a/agent/system_prompt.py
+++ b/agent/system_prompt.py
@@ -584,6 +584,23 @@ def build_system_prompt_parts(agent: Any, system_message: Optional[str] = None)
# Probe failure must never block prompt build.
pass
+ # Bot Mode teammate protocol — when the desktop's Bot Mode manages this
+ # install (any profile carries ui_meta['hermes-bots']), every session of
+ # every profile learns the bot-to-bot messaging protocol, including
+ # headless `hermes -p <bot> chat` sessions started by a teammate. Silent
+ # on non-Bot-Mode installs and when the profile's SOUL.md already carries
+ # the section (legacy plugin-side append). Deterministic per (process,
+ # home) — cache-safe. Gated by config.yaml ``agent.bot_mode_protocol``
+ # (default True).
+ if getattr(agent, "_bot_mode_protocol", True):
+ try:
+ from tools.bot_mode_probe import get_bot_mode_protocol_section
+ _bot_section = get_bot_mode_protocol_section(_agent_home(agent))
+ if _bot_section:
+ post_workspace_parts.append(_bot_section)
+ except Exception:
+ pass
+
# Active-profile hint — names the Hermes profile the agent is running
# under so it doesn't conflate ~/.hermes/skills/ (default profile) with
# ~/.hermes/profiles/<active>/skills/ (this profile's). Deterministic
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 64c6a8958a3..cdfe670a11e 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -163,6 +163,9 @@ DEFAULT_CONFIG = {
# (docker/modal/ssh — they have their own probe). Set False to
# disable entirely.
"environment_probe": True,
+ # Bot Mode teammate-messaging protocol section (silent unless a
+ # profile is managed by the desktop's Bot Mode).
+ "bot_mode_protocol": True,
# Embedder-supplied environment description appended to the system
# prompt's environment-hints block. Lets a host that wraps Hermes
# (sandbox runner, managed platform) explain the runtime environment
diff --git a/tests/tools/test_bot_mode_probe.py b/tests/tools/test_bot_mode_probe.py
new file mode 100644
index 00000000000..ffec95bf689
--- /dev/null
+++ b/tests/tools/test_bot_mode_probe.py
@@ -0,0 +1,103 @@
+"""Tests for tools/bot_mode_probe.py — the Bot Mode teammate-protocol section."""
+
+import textwrap
+
+import pytest
+
+from tools import bot_mode_probe
+
+
[email protected](autouse=True)
+def _fresh_cache():
+ bot_mode_probe._reset_cache_for_tests()
+ yield
+ bot_mode_probe._reset_cache_for_tests()
+
+
+def _make_bot_profile(root, name, *, managed=True, soul=None):
+ d = root / "profiles" / name
+ d.mkdir(parents=True, exist_ok=True)
+ if managed:
+ (d / "profile.yaml").write_text(
+ textwrap.dedent(
+ """\
+ ui_meta:
+ hermes-bots:
+ shape: cloud
+ color: '#8b5cf6'
+ """
+ ),
+ encoding="utf-8",
+ )
+ if soul is not None:
+ (d / "SOUL.md").write_text(soul, encoding="utf-8")
+ return d
+
+
+def test_silent_when_no_profile_is_bot_managed(tmp_path):
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ _make_bot_profile(home, "researcher", managed=False)
+ assert bot_mode_probe.get_bot_mode_protocol_section(home) == ""
+
+
+def test_emits_for_default_when_any_profile_is_managed(tmp_path):
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ _make_bot_profile(home, "researcher", managed=True)
+
+ section = bot_mode_probe.get_bot_mode_protocol_section(home)
+ assert section.startswith("## Messaging other agents")
+ # default's callable alias is @hermes, never @default
+ assert "@hermes" in section
+ assert "@default" not in section
+ assert "`researcher`" in section
+ assert "hermes profile list" in section
+
+
+def test_emits_for_named_profile_with_own_handle(tmp_path):
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ profile_dir = _make_bot_profile(home, "coder", managed=True)
+
+ section = bot_mode_probe.get_bot_mode_protocol_section(profile_dir)
+ assert "@coder" in section
+ # teammate list excludes self, includes default
+ assert "`default`" in section
+ assert "`coder`" not in section.split("Teammates at session start:")[1]
+
+
+def test_silent_when_soul_already_carries_protocol(tmp_path):
+ """Legacy plugin-side append — never double the section."""
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ _make_bot_profile(home, "coder", managed=True)
+ (home / "SOUL.md").write_text(
+ "# Me\n\n## Messaging other agents\nold plugin text\n", encoding="utf-8"
+ )
+ assert bot_mode_probe.get_bot_mode_protocol_section(home) == ""
+
+
+def test_deterministic_across_calls(tmp_path):
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ _make_bot_profile(home, "researcher", managed=True)
+ first = bot_mode_probe.get_bot_mode_protocol_section(home)
+ # Even if the filesystem changes, the cached result must be byte-stable
+ # for the life of the process (prompt-cache invariant).
+ _make_bot_profile(home, "newbot", managed=True)
+ second = bot_mode_probe.get_bot_mode_protocol_section(home)
+ assert first == second
+
+
+def test_never_raises_on_garbage(tmp_path, monkeypatch):
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ profiles = home / "profiles" / "bad"
+ profiles.mkdir(parents=True)
+ (profiles / "profile.yaml").write_text("ui_meta: [unclosed", encoding="utf-8")
+ assert isinstance(bot_mode_probe.get_bot_mode_protocol_section(home), str)
+
+ monkeypatch.setattr(bot_mode_probe, "_roster", lambda root: (_ for _ in ()).throw(OSError("boom")))
+ bot_mode_probe._reset_cache_for_tests()
+ assert bot_mode_probe.get_bot_mode_protocol_section(home) == ""
diff --git a/tools/bot_mode_probe.py b/tools/bot_mode_probe.py
new file mode 100644
index 00000000000..7fe9078c0a6
--- /dev/null
+++ b/tools/bot_mode_probe.py
@@ -0,0 +1,153 @@
+"""Bot Mode roster probe — stable-tier system prompt section.
+
+When the desktop's Bot Mode manages this install (any profile carries a
+``ui_meta['hermes-bots']`` block in its profile.yaml), every session of every
+profile gets a short "Messaging other agents" section so bots can hand off
+@mentions and reply to bot-to-bot DMs — including headless CLI sessions
+started by another bot via ``hermes -p <name> chat``.
+
+This replaces the plugin-side SOUL.md backfill: the protocol is injected by
+the core at prompt-build time instead of appended to user-authored SOUL
+files. If the profile's SOUL.md already carries the section (created by an
+older plugin version), the probe stays silent so the text never doubles up.
+
+Silent (returns ``""``) when:
+- no profile on this install is Bot-Mode-managed (the dominant case),
+- the current profile's SOUL.md already contains the protocol heading,
+- anything at all goes wrong (never crash a prompt build).
+
+Deterministic within a process: the result is computed once and cached, so
+compression-triggered prompt rebuilds produce identical bytes.
+
+Toggle via ``agent.bot_mode_protocol`` in config.yaml (default True).
+"""
+
+from __future__ import annotations
+
+import os
+import threading
+from pathlib import Path
+
+_PROTOCOL_HEADING = "## Messaging other agents"
+
+_lock = threading.Lock()
+_cached: dict[str, str] = {}
+
+
+def _hermes_root(home: Path) -> Path:
+ """Root ~/.hermes for both the default profile and named profiles."""
+ if home.parent.name == "profiles":
+ return home.parent.parent
+ return home
+
+
+def _profile_name(home: Path) -> str:
+ if home.parent.name == "profiles":
+ return home.name
+ return "default"
+
+
+def _is_bot_managed(profile_dir: Path) -> bool:
+ """True when profile.yaml carries a ui_meta['hermes-bots'] block.
+
+ Cheap substring check before the YAML parse keeps the silent path fast.
+ """
+ meta = profile_dir / "profile.yaml"
+ try:
+ if not meta.is_file():
+ return False
+ raw = meta.read_text(encoding="utf-8", errors="replace")
+ if "hermes-bots" not in raw:
+ return False
+ import yaml
+
+ data = yaml.safe_load(raw)
+ ui_meta = data.get("ui_meta") if isinstance(data, dict) else None
+ return isinstance(ui_meta, dict) and isinstance(ui_meta.get("hermes-bots"), dict)
+ except Exception:
+ return False
+
+
+def _roster(root: Path) -> list[tuple[str, Path]]:
+ """(name, dir) for the default profile + every named profile."""
+ entries: list[tuple[str, Path]] = [("default", root)]
+ try:
+ profiles = root / "profiles"
+ if profiles.is_dir():
+ for child in sorted(profiles.iterdir()):
+ if child.is_dir():
+ entries.append((child.name, child))
+ except Exception:
+ pass
+ return entries
+
+
+def _soul_has_protocol(profile_dir: Path) -> bool:
+ try:
+ soul = profile_dir / "SOUL.md"
+ return soul.is_file() and _PROTOCOL_HEADING in soul.read_text(encoding="utf-8", errors="replace")
+ except Exception:
+ return False
+
+
+def _handle(name: str) -> str:
+ # The mention middleware aliases the default profile as @hermes.
+ return "hermes" if name == "default" else name
+
+
+def _build_section(home: Path) -> str:
+ root = _hermes_root(home)
+ me = _profile_name(home)
+
+ roster = _roster(root)
+ if not any(_is_bot_managed(d) for _n, d in roster):
+ return ""
+
+ # An older plugin build may have appended the protocol to SOUL.md
+ # already — never double it up.
+ my_dir = home if me == "default" else root / "profiles" / me
+ if _soul_has_protocol(my_dir):
+ return ""
+
+ handle = _handle(me)
+ teammates = ", ".join(f"`{n}`" for n, _d in roster if n != me) or "(none yet)"
+
+ return (
+ f"{_PROTOCOL_HEADING}\n"
+ "This install runs Bot Mode: each Hermes profile is an agent teammate with "
+ 'one canonical "Bot Chat" conversation. To message a teammate, run on the '
+ "terminal tool (background=true, notify_on_complete=true), then finish your "
+ "turn — the reply arrives later as a new message:\n"
+ "```\n"
+ f'hermes -p <agent-name> chat --in ~ -c "Bot Chat" -Q -q "Message from 🤖 {handle} (@{handle}): your message"\n'
+ "```\n"
+ f'Always open with the "Message from 🤖 {handle} (@{handle}):" prefix so they '
+ "know who is talking. When YOU receive a message with that prefix, you are "
+ "being messaged by a teammate agent — address them (not the user) and reply "
+ "concisely. When the user says \"ask <name>\" or \"tell <name> ...\", that is a "
+ "handoff: message that agent, wait for the reply, and report back, saying "
+ "which agent it came from. Run `hermes profile list` for the LIVE teammate "
+ f"list before a handoff. Teammates at session start: {teammates}."
+ )
+
+
+def get_bot_mode_protocol_section(home: str | os.PathLike | None = None, *, force_refresh: bool = False) -> str:
+ """Cached probe entry point — one filesystem pass per (process, home).
+
+ ``home`` should be the AGENT'S OWN resolved home (session-db derived),
+ not the ambient HERMES_HOME — build threads can lose the ContextVar
+ override and the env var would then name the wrong profile.
+ """
+ resolved = str(home) if home else (os.getenv("HERMES_HOME") or os.path.expanduser("~/.hermes"))
+ with _lock:
+ if force_refresh or resolved not in _cached:
+ try:
+ _cached[resolved] = _build_section(Path(resolved))
+ except Exception:
+ _cached[resolved] = ""
+ return _cached[resolved]
+
+
+def _reset_cache_for_tests() -> None:
+ with _lock:
+ _cached.clear()
diff --git a/tui_gateway/methods_profiles.py b/tui_gateway/methods_profiles.py
index 7f002300f91..53333b21963 100644
--- a/tui_gateway/methods_profiles.py
+++ b/tui_gateway/methods_profiles.py
@@ -159,7 +159,12 @@ def _(rid, params: dict) -> dict:
except Exception:
row["has_avatar"] = False
out.append(row)
- return _ok(rid, {"profiles": out})
+ # Capability flag: this backend's prompt builder injects the Bot Mode
+ # teammate-messaging protocol (tools/bot_mode_probe.py) into every
+ # session of Bot-Mode-managed installs. Clients that would otherwise
+ # append the protocol to SOUL.md (the desktop's hermes-bots plugin)
+ # must skip their SOUL writes when this is present.
+ return _ok(rid, {"profiles": out, "bot_mode_protocol": True})
except Exception as e:
return _err(rid, 5061, str(e))
diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.md
index 51921303a7c..b76170ece96 100644
--- a/website/docs/user-guide/desktop.md
+++ b/website/docs/user-guide/desktop.md
@@ -162,6 +162,27 @@ The app also surfaces the broader Hermes management surface so you don't have to
- **Messaging** — set up gateway channels.
- **Agents** and **Command Center** — orchestration surfaces for multi-agent work.
+### Bot Mode (built in)
+
+**Bot Mode** ships with the app and is on by default: a "one chat per agent"
+roster where every [Hermes profile](./profiles.md) appears as a bot with its
+own avatar (geometric face, uploaded image, AI-generated portrait, or a pixel
+pet), its own canonical **Bot Chat** conversation, and its own **Routines**
+(recurring tasks backed by Hermes cron). Create new agents from the roster —
+Name / Title / Description plus an Advanced disclosure with the full
+capabilities surface (model, SOUL, skills, toolsets, MCP servers) — group
+them into sections, and open group chats where several bots deliberate.
+
+Bots message each other: type `@researcher have a look at this` in any chat
+and the active bot hands the message off and reports back, and bots reach
+each other's Bot Chats directly (`hermes -p <bot> chat`). The backend teaches
+every session the messaging protocol automatically (config
+`agent.bot_mode_protocol`, default on) — including headless CLI sessions a
+teammate bot starts — so handoffs work without touching your SOUL.md.
+
+Don't want it? Flip it off in **Settings → Plugins → Bots** — the roster,
+routines pane, and composer middleware unregister live, no restart needed.
+
### Keyboard & navigation
- **Command palette** — press **Cmd+K** or **Cmd+P** (Ctrl+K / Ctrl+P on Windows/Linux) to jump to actions and navigate the app from the keyboard: open any page or settings section, jump to a session by title or id, switch model/theme/color mode, spawn a terminal, restart the gateway, update Hermes, and more.