The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(onboarding): the first message offers /initiate-setup only under guest onboarding
alt-glitchcf351e320cac
diff --git a/agent/onboarding.py b/agent/onboarding.pyindex 52efe5f6a5e..c8afe28a0a0 100644--- a/agent/onboarding.py+++ b/agent/onboarding.py@@ -174,13 +174,42 @@ def first_contact_turn_note(and not is_seen(config, PROFILE_BUILD_FLAG)):mark_seen(config_path, PROFILE_BUILD_FLAG)- return SETUP_OFFER_NOTE.format(command=command)+ from hermes_cli.anon_auth import guest_enabled++ # /initiate-setup is the offer only where the setup flow ships; elsewhere keep the memory profile offer.+ return SETUP_OFFER_NOTE.format(command=command) if guest_enabled() else profile_build_directive().strip()return PLAIN_INTRO_NOTEexcept Exception as e:logger.debug("first_contact_turn_note failed, using plain intro: %s", e)return PLAIN_INTRO_NOTE+def profile_build_directive() -> str:+ """System-note directive appended to the very first message ever.++ Short opt-in profile-build flow persisting to the user-profile memory store;+ phrased so the agent ASKS before any lookup and never silently reads+ connected accounts.+ """+ return (+ "\n\n"+ "[System note: This is the user's very first message ever. " + TASK_FIRST_CLAUSE+ + "What this note asks: after a one-sentence introduction (mention /help "+ "shows commands), OFFER — do not assume — to build a short profile of them so you can be more useful, and "+ "explain they can decline or do it later. If and ONLY IF they accept:\n"+ " 1. Ask for whatever they're comfortable sharing (name, what they do, how they like you to work). "+ "Volunteered facts come first.\n"+ " 2. Before ANY external lookup, say what you intend to look up and get explicit consent for that step. Never "+ "read their connected accounts (email, calendar, etc.) silently — ask each time.\n"+ " 3. With consent, you may use web_search to confirm public details (e.g. employer, public profiles) from the "+ "data points they gave.\n"+ " 4. Save each confirmed, durable fact with the memory tool using target=\"user\" — keep entries compact and "+ "high-signal.\n"+ "If they decline at any point, stop immediately and continue normally. Keep the whole exchange light and "+ "conversational, not an interrogation.]"+ )++def is_seen(config: Mapping[str, Any], flag: str) -> bool:"""True if the user has already been shown this first-touch hint."""seen = _onboarding_section(config).get("seen")@@ -214,6 +243,6 @@ __all__ = ["BUSY_INPUT_FLAG", "TOOL_PROGRESS_FLAG", "OPENCLAW_RESIDUE_FLAG", "PROFILE_BUILD_FLAG","PLAIN_INTRO_NOTE", "SETUP_OFFER_NOTE", "first_contact_turn_note","busy_input_hint_gateway", "busy_input_hint_cli", "tool_progress_hint_gateway", "tool_progress_hint_cli",- "openclaw_residue_hint_cli", "detect_openclaw_residue", "profile_build_mode",+ "openclaw_residue_hint_cli", "detect_openclaw_residue", "profile_build_mode", "profile_build_directive","is_seen", "mark_seen",]diff --git a/tests/agent/test_onboarding.py b/tests/agent/test_onboarding.pyindex 2ce75075c96..ce757ff8908 100644--- a/tests/agent/test_onboarding.py+++ b/tests/agent/test_onboarding.py@@ -3,6 +3,7 @@from __future__ import annotationsimport hermes_yaml as yaml+import pytestfrom agent.onboarding import (BUSY_INPUT_FLAG,@@ -98,13 +99,20 @@ class TestProfileBuildMode:class TestFirstContactTurnNote:- def test_returns_setup_offer_and_marks_seen(self, tmp_path):+ @pytest.mark.parametrize("guest", [False, True])+ def test_first_contact_offer_follows_the_onboarding_gate(self, tmp_path, monkeypatch, guest):+ # The /initiate-setup offer ships with guest onboarding; everyone else keeps the memory profile offer.from agent.onboarding import (PROFILE_BUILD_FLAG,SETUP_OFFER_NOTE,first_contact_turn_note,+ profile_build_directive,)+ if guest:+ monkeypatch.setenv("HERMES_GUEST_ONBOARDING", "1")+ else:+ monkeypatch.delenv("HERMES_GUEST_ONBOARDING", raising=False)cfg_path = tmp_path / "config.yaml"cfg = {"onboarding": {"profile_build": "ask"}}note = first_contact_turn_note(@@ -114,7 +122,8 @@ class TestFirstContactTurnNote:install_has_prior_sessions=False,message="hello",)- assert note == SETUP_OFFER_NOTE.format(command="/initiate-setup")+ expected = SETUP_OFFER_NOTE.format(command="/initiate-setup") if guest else profile_build_directive().strip()+ assert note == expectedloaded = yaml.safe_load(cfg_path.read_text())assert loaded["onboarding"]["seen"][PROFILE_BUILD_FLAG] is Truediff --git a/tests/tui_gateway/test_first_contact_onboarding.py b/tests/tui_gateway/test_first_contact_onboarding.pyindex 1b05137256b..70d0a0177af 100644--- a/tests/tui_gateway/test_first_contact_onboarding.py+++ b/tests/tui_gateway/test_first_contact_onboarding.py@@ -13,7 +13,7 @@ import typesimport pytest-from agent.onboarding import PROFILE_BUILD_FLAG, SETUP_OFFER_NOTE+from agent.onboarding import PROFILE_BUILD_FLAG, SETUP_OFFER_NOTE, profile_build_directivefrom hermes_yaml import safe_dump, safe_loadfrom tui_gateway import server@@ -42,8 +42,9 @@ def _stage(session, agent, history_empty):def test_stages_setup_offer_on_first_contact(monkeypatch, onboarding_home):- """Fresh install + empty history: the opt-in directive is staged on the agent- and the offered flag is persisted before the turn runs."""+ """Fresh install + empty history under guest onboarding: the /initiate-setup offer is staged+ on the agent and the offered flag is persisted before the turn runs."""+ monkeypatch.setenv("HERMES_GUEST_ONBOARDING", "1")monkeypatch.setattr(server, "_install_has_prior_sessions", lambda _s: False)agent = types.SimpleNamespace()@@ -54,6 +55,17 @@ def test_stages_setup_offer_on_first_contact(monkeypatch, onboarding_home):assert loaded["onboarding"]["seen"][PROFILE_BUILD_FLAG] is True+def test_stages_profile_build_offer_without_guest_onboarding(monkeypatch, onboarding_home):+ """Without guest onboarding the first message keeps main's memory profile offer."""+ monkeypatch.delenv("HERMES_GUEST_ONBOARDING", raising=False)+ monkeypatch.setattr(server, "_install_has_prior_sessions", lambda _s: False)++ agent = types.SimpleNamespace()+ _stage(_session(agent), agent, history_empty=True)++ assert agent._gateway_turn_context_notes == profile_build_directive().strip()++def test_skips_first_contact_when_prior_sessions_exist(monkeypatch, onboarding_home):"""An install that already holds conversations must not re-offer; nothing isstaged and the config is untouched."""