Skip to content

The agent that grows with you

fix(cli): the CLI's first message reaches the model as typed

emozilla43c12710093d
diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.py
index ec221165540..c8b38fb1233 100644
--- a/hermes_cli/cli_chat_turn_mixin.py
+++ b/hermes_cli/cli_chat_turn_mixin.py
@@ -90,7 +90,6 @@ class CLIChatTurnMixin:
from agent.message_sanitization import _sanitize_surrogates
message = _sanitize_surrogates(message)
- self._chat_stage_first_contact_note(agent, message if isinstance(message, str) else "")
self._chat_stage_user_message(agent, message)
if isinstance(message, TimelineNotification):
message = str(message) # UI metadata is on the staged row, never in model content.
@@ -231,28 +230,6 @@ class CLIChatTurnMixin:
primary = profile_name_for_home(get_hermes_home()) or "default"
self._queue_prompt_turn(build_initiate_setup_prompt("cli", names, primary), "/initiate-setup")
- def _chat_stage_first_contact_note(self, agent, message: str) -> None:
- from cli import logger
- if self.conversation_history:
- return
- try:
- from agent.onboarding import first_contact_turn_note
- from hermes_cli.config import load_config
- from hermes_constants import get_hermes_home
-
- db = self._session_db
- note = first_contact_turn_note(
- load_config(), get_hermes_home() / "config.yaml",
- session_history_empty=True,
- install_has_prior_sessions=db is not None and db.session_count_ge(2 if agent._session_db_created else 1),
- message=message,
- )
- if note:
- prior = getattr(agent, "_gateway_turn_context_notes", "") or ""
- agent._gateway_turn_context_notes = f"{prior}\n\n{note}" if prior else note
- except Exception: # health: allow BLE001 -- the note is optional; a failure leaves the first turn as it was
- logger.debug("first-contact onboarding note failed", exc_info=True)
-
def _chat_stage_user_message(self, agent, message):
"""Append the staged user dict to the transcript under the agent's persist lock."""
# Copy before appending: mutating ``agent._session_messages`` in this UI-only step
diff --git a/tests/hermes_cli/test_cli_first_message.py b/tests/hermes_cli/test_cli_first_message.py
new file mode 100644
index 00000000000..5f06bdb9857
--- /dev/null
+++ b/tests/hermes_cli/test_cli_first_message.py
@@ -0,0 +1,48 @@
+"""A fresh install's first CLI message reaches the model exactly as typed.
+
+The first-contact note (the profile-build offer or the plain intro) is sent by the messaging gateway and
+the TUI/desktop backend. The CLI never sent one. A one-shot ``hermes chat -q`` in a fresh home, which is
+how kanban workers and scripted runs start, must not gain that note or record
+``onboarding.seen.profile_build_offered`` in the profile's config.
+"""
+
+from __future__ import annotations
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+import yaml
+
+from agent.onboarding import PROFILE_BUILD_FLAG, is_seen
+from tests.fakes.fake_llm_provider import FakeLLMServer, Text, write_hermes_home
+
+ROOT = Path(__file__).parents[2]
+PROMPT = "work kanban task t_1"
+
+
+def test_first_cli_message_in_a_fresh_home_reaches_the_model_unchanged(tmp_path):
+ home = tmp_path / "hermes"
+ with FakeLLMServer([Text("done")]) as srv:
+ write_hermes_home(
+ home, srv.base_url,
+ extra_config="updates:\n check: false\nmodels_dev:\n url: http://127.0.0.1:9/api.json\n",
+ )
+ env = {**os.environ, "HERMES_HOME": str(home), "PYTHONUTF8": "1"}
+ env["PYTHONPATH"] = str(ROOT) + os.pathsep + env.get("PYTHONPATH", "")
+ for name in ("HERMES_GUEST_ONBOARDING", "HERMES_DESKTOP"):
+ env.pop(name, None)
+ proc = subprocess.run(
+ [sys.executable, "-m", "hermes_cli.main", "chat", "-q", PROMPT],
+ cwd=ROOT, env=env, stdin=subprocess.DEVNULL, capture_output=True,
+ text=True, encoding="utf-8", timeout=240, check=False,
+ )
+ requests = srv.main_requests()
+
+ assert proc.returncode == 0, proc.stderr[-3000:]
+ assert requests, f"the model was never called; stderr tail: {proc.stderr[-2000:]}"
+ users = [m["content"] for m in requests[0]["messages"] if m.get("role") == "user"]
+ assert users == [PROMPT]
+ config = yaml.safe_load((home / "config.yaml").read_text(encoding="utf-8")) or {}
+ assert not is_seen(config, PROFILE_BUILD_FLAG)
diff --git a/tests/tui_gateway/test_foreground_notification_snapshot.py b/tests/tui_gateway/test_foreground_notification_snapshot.py
index 2769ce4bbf5..21e64026b78 100644
--- a/tests/tui_gateway/test_foreground_notification_snapshot.py
+++ b/tests/tui_gateway/test_foreground_notification_snapshot.py
@@ -103,7 +103,6 @@ def test_cli_real_chat_binds_refreshes_and_restores_snapshot(tmp_path, monkeypat
def _init_agent(self, **kwargs): return True
def _chat_route_images(self, message, images): return message
def _chat_expand_context_references(self, message): return message, None
- def _chat_stage_first_contact_note(self, agent, message): pass
def _chat_stage_user_message(self, agent, message): agent._pending_cli_user_message = {}
def _reset_stream_state(self): pass
def _chat_setup_turn_audio(self, *args): pass
diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md
index 00c7a88910f..94f1135113b 100644
--- a/website/docs/user-guide/configuration.md
+++ b/website/docs/user-guide/configuration.md
@@ -3063,7 +3063,7 @@ onboarding:
seen: {} # internal latch — leave empty
```
-- `profile_build` — controls the offer on the first message ever, in the CLI, the TUI, the desktop app and messaging direct messages (never in a group chat). `"ask"` (default) offers to build a user profile; the offer is **opt-in and consent-gated** — the agent asks before any lookup, never reads connected accounts silently, and saves confirmed facts to user memory. In the Microsoft Store desktop app the offer is instead one closing line that points at `/initiate-setup` (`/initiate_setup` on Telegram, `/hermes initiate-setup` on Slack). The offer is skipped when the first message is `/initiate-setup` itself, and always in the desktop app's setup profile. `"off"` stops only the offer; the agent still gives a plain intro. The offer fires at most once per profile. `/initiate-setup` sends a short block of facts about the computer; see [What the setup chat knows about your computer](./desktop.md#what-the-setup-chat-knows-about-your-computer).
+- `profile_build` — controls the offer on the first message ever, in the TUI, the desktop app and messaging direct messages (never in a group chat). `"ask"` (default) offers to build a user profile; the offer is **opt-in and consent-gated** — the agent asks before any lookup, never reads connected accounts silently, and saves confirmed facts to user memory. In the Microsoft Store desktop app the offer is instead one closing line that points at `/initiate-setup` (`/initiate_setup` on Telegram, `/hermes initiate-setup` on Slack). The offer is skipped when the first message is `/initiate-setup` itself, and always in the desktop app's setup profile. `"off"` stops only the offer; the agent still gives a plain intro. The offer fires at most once per profile. `/initiate-setup` sends a short block of facts about the computer; see [What the setup chat knows about your computer](./desktop.md#what-the-setup-chat-knows-about-your-computer).
- `seen` — internal state. Hermes latches each shown hint here so it never fires again; the first-message offer is also recorded here once shown. Don't hand-edit it — wipe the whole `onboarding` section if you want to re-see all hints.
## Dashboard