refactor(gateway): route first-contact note through first_contact_turn_note
_hmwa_first_contact_notes re-implemented the branch logic of agent.onboarding.first_contact_turn_note (profile_build mode check, is_seen, mark_seen, plain-intro fallback) that the TUI already uses, so the gateway and TUI paths could drift apart. #123987 deduplicated only the note literal. Call the shared helper instead; it already falls back to PLAIN_INTRO_NOTE on error, so the local try/except goes away. The has_any_sessions() gate stays. Suggested in review of #123987 by jonpol01.
This commit is contained in:
@@ -1424,24 +1424,15 @@ class GatewayTurnMixin:
|
||||
if history:
|
||||
return
|
||||
if not await self.async_session_store.has_any_sessions():
|
||||
from agent.onboarding import PLAIN_INTRO_NOTE
|
||||
_intro_note = PLAIN_INTRO_NOTE
|
||||
# onboarding.profile_build == "ask" (default) and not yet offered: swap the plain intro for
|
||||
# a consent-gated profile-build directive. Fires at most once.
|
||||
try:
|
||||
from agent.onboarding import (
|
||||
PROFILE_BUILD_FLAG, is_seen, mark_seen, profile_build_directive,
|
||||
profile_build_mode,
|
||||
)
|
||||
_onb_cfg = _load_gateway_config()
|
||||
if profile_build_mode(_onb_cfg) == "ask" and not is_seen(_onb_cfg, PROFILE_BUILD_FLAG):
|
||||
turn_sidecar_notes.append(profile_build_directive().strip())
|
||||
mark_seen(_hermes_home / "config.yaml", PROFILE_BUILD_FLAG)
|
||||
else:
|
||||
turn_sidecar_notes.append(_intro_note)
|
||||
except Exception as _pb_err:
|
||||
logger.debug("Profile-build onboarding directive failed, using plain intro: %s", _pb_err)
|
||||
turn_sidecar_notes.append(_intro_note)
|
||||
# Same branch logic as the TUI (profile-build offer once when "ask", else plain intro);
|
||||
# first_contact_turn_note already falls back to the plain intro on error.
|
||||
from agent.onboarding import first_contact_turn_note
|
||||
note = first_contact_turn_note(
|
||||
_load_gateway_config(), _hermes_home / "config.yaml",
|
||||
session_history_empty=True, install_has_prior_sessions=False,
|
||||
)
|
||||
if note:
|
||||
turn_sidecar_notes.append(note)
|
||||
|
||||
# One-time prompt if no home channel is set (webhooks deliver to configured targets instead).
|
||||
if not source.platform or source.platform in (Platform.LOCAL, Platform.WEBHOOK):
|
||||
|
||||
Reference in New Issue
Block a user