Skip to content

The agent that grows with you

fix(onboarding): only the setup handoff skips the first-contact note, not text that quotes its marker

alt-glitchdcc3609bd89f
diff --git a/agent/onboarding.py b/agent/onboarding.py
index afd0370afe1..ad78ab2ccf7 100644
--- a/agent/onboarding.py
+++ b/agent/onboarding.py
@@ -159,6 +159,7 @@ def first_contact_turn_note(
install_has_prior_sessions: bool,
message: str,
command: str = "/initiate-setup",
+ setup_handoff: bool = False,
) -> Optional[str]:
"""Return a one-shot sidecar note for the install's first-ever message.
@@ -166,16 +167,16 @@ def first_contact_turn_note(
and the offer has not been latched yet, return the opt-in
directive and persist ``onboarding.seen.profile_build_offered``. Otherwise
return the plain intro note. Returns ``None`` when this is not the first
- contact (non-empty session history or prior sessions exist on the install).
+ contact (non-empty session history or prior sessions exist on the install). ``setup_handoff``
+ marks the task chat setup started (``start_chat``), told by the caller, never read from the text.
"""
- from agent.first_task_prompt import MARKER as FIRST_TASK_MARKER
from agent.initiate_setup_prompt import HEADER
from hermes_cli.profiles import SETUP_PROFILE_MARKER
if not session_history_empty or install_has_prior_sessions or message.startswith(HEADER):
return None
# The task chat setup hands off to is the user's first chat in their own profile; setup already ran.
- if FIRST_TASK_MARKER in message:
+ if setup_handoff:
return None
# The setup chat opens with its own welcome, whatever its first message says.
if (config_path.parent / SETUP_PROFILE_MARKER).is_file():
diff --git a/tests/agent/test_onboarding.py b/tests/agent/test_onboarding.py
index b9ca8422d51..260626a2b8f 100644
--- a/tests/agent/test_onboarding.py
+++ b/tests/agent/test_onboarding.py
@@ -156,10 +156,26 @@ class TestFirstContactTurnNote:
session_history_empty=True,
install_has_prior_sessions=False,
message=f"Set up Blender for me{MARKER}skill text",
+ setup_handoff=True,
)
assert note is None
assert not cfg_path.exists() or PROFILE_BUILD_FLAG not in cfg_path.read_text()
+ def test_a_first_message_quoting_the_handoff_marker_still_gets_the_offer(self, tmp_path, monkeypatch):
+ # Only start_chat marks a handoff; a user who types the marker text is still a first contact.
+ from agent.first_task_prompt import MARKER
+ from agent.onboarding import SETUP_OFFER_NOTE, first_contact_turn_note
+
+ monkeypatch.setenv("HERMES_GUEST_ONBOARDING", "1")
+ note = first_contact_turn_note(
+ {"onboarding": {"profile_build": "ask"}},
+ tmp_path / "config.yaml",
+ session_history_empty=True,
+ install_has_prior_sessions=False,
+ message=f"what does this mean?{MARKER}",
+ )
+ assert note == SETUP_OFFER_NOTE.format(command="/initiate-setup")
+
def test_returns_none_when_not_first_contact(self, tmp_path):
from agent.onboarding import first_contact_turn_note
diff --git a/tests/tui_gateway/test_first_contact_onboarding.py b/tests/tui_gateway/test_first_contact_onboarding.py
index 70d0a0177af..c13cde76f0e 100644
--- a/tests/tui_gateway/test_first_contact_onboarding.py
+++ b/tests/tui_gateway/test_first_contact_onboarding.py
@@ -141,3 +141,16 @@ def test_installs_prior_sessions_probe_counts_the_install(monkeypatch):
monkeypatch.setattr(server, "_session_db", lambda _s: _Ctx(_DB(2)))
assert server._install_has_prior_sessions(fresh) is True
+
+
+def test_the_task_chat_setup_hands_off_to_gets_no_note(monkeypatch, onboarding_home):
+ """start_chat marks the session it opens from setup; the prompt turn passes that on."""
+ monkeypatch.setenv("HERMES_GUEST_ONBOARDING", "1")
+ monkeypatch.setattr(server, "_install_has_prior_sessions", lambda _s: False)
+
+ agent = types.SimpleNamespace()
+ session = {**_session(agent), "setup_handoff": True}
+ _stage(session, agent, history_empty=True)
+
+ assert getattr(agent, "_gateway_turn_context_notes", None) is None
+ assert PROFILE_BUILD_FLAG not in (onboarding_home / "config.yaml").read_text()
diff --git a/tui_gateway/prompt_turn.py b/tui_gateway/prompt_turn.py
index 33d3f3b01e4..0c4bba765b1 100644
--- a/tui_gateway/prompt_turn.py
+++ b/tui_gateway/prompt_turn.py
@@ -644,6 +644,7 @@ def _stage_first_contact_onboarding_note(session: dict, agent, history_empty: bo
session_history_empty=history_empty,
install_has_prior_sessions=_install_has_prior_sessions(session),
message=message,
+ setup_handoff=bool(session.get("setup_handoff")),
)
if not note:
return
diff --git a/tui_gateway/start_chat.py b/tui_gateway/start_chat.py
index 6dd3dc38156..49f1d00d18d 100644
--- a/tui_gateway/start_chat.py
+++ b/tui_gateway/start_chat.py
@@ -74,6 +74,8 @@ def start_chat(args: dict, caller_id: str | None = None) -> str:
if "error" in created:
return _rejected(created["error"]["message"], retryable=True)
result = created["result"]
+ if from_setup: # its first turn skips the first-contact note: setup already ran
+ server._sessions[result["session_id"]]["setup_handoff"] = True
mark_seen(target_home / "config.yaml", PROFILE_BUILD_FLAG)
submitted = server._methods["prompt.submit"](None, {"session_id": result["session_id"], "text": message})
if "error" in submitted: