Skip to content

The agent that grows with you

fix(onboarding): the look-around offer comes before the connectors card

alt-glitche7a9c915871b
diff --git a/agent/onboarding_flow.py b/agent/onboarding_flow.py
index 689e99ce41f..a2356e61faf 100644
--- a/agent/onboarding_flow.py
+++ b/agent/onboarding_flow.py
@@ -56,11 +56,13 @@ class Facts:
@dataclass(frozen=True)
class Shown:
- """``options``: the model's build picks, ``[{id, label}]``; empty brings back the card already shown."""
+ """``options``: the model's build picks, ``[{id, label}]``; empty brings back the card already shown.
+ ``suggest``: the connector slugs the model pins after it looked around."""
beat: str
tool_call_id: str = ""
options: Any = None
+ suggest: Any = None
@dataclass(frozen=True)
@@ -234,6 +236,10 @@ def _build_picks_error(record: dict, event: Shown, facts: Facts) -> str | None:
return None
+def _has_suggestions(suggest: Any) -> bool:
+ return isinstance(suggest, list | tuple) and any(str(slug).strip() for slug in suggest)
+
+
def _shown(record: dict, event: Shown, facts: Facts, now: float) -> Step:
if not BEAT_BY_ID[event.beat].when(facts, record["picks"]):
record["beats"][event.beat] = SKIPPED
@@ -241,14 +247,17 @@ def _shown(record: dict, event: Shown, facts: Facts, now: float) -> Step:
if event.beat == "build" and (error := _build_picks_error(record, event, facts)):
# No ``beat``: no card was shown, so the transcript draws nothing for this refusal.
return Step(record, {"error": error})
+ if event.beat == "connectors" and record["look_around"] == "not_offered":
+ # The offer reaches the model only here, so it is offered now; suggestions mean it already looked.
+ record["look_around"] = "offered"
+ if not _has_suggestions(event.suggest):
+ return Step(record, {"error": "offer first"}, "offer_first")
# A later card on screen means the user moved on from an earlier card left open.
for earlier in BEAT_IDS[:BEAT_IDS.index(event.beat)]:
if record["beats"][earlier] == SHOWN:
record["beats"][earlier] = DONE
if record["beats"][event.beat] != DONE:
record["beats"][event.beat] = SHOWN
- if event.beat == "connectors" and record["look_around"] == "not_offered":
- record["look_around"] = "offered"
record["waiting"] = {"beat": event.beat, "tool_call_id": event.tool_call_id, "since": now}
return Step(record, {})
diff --git a/agent/onboarding_text.py b/agent/onboarding_text.py
index 3a77998c32b..0db5765fd5d 100644
--- a/agent/onboarding_text.py
+++ b/agent/onboarding_text.py
@@ -77,6 +77,7 @@ How it works:
- If they ask you to pick (a colour, a layout), pick from what you know and say why in one line.
- If they skip a beat in words, call setup_beat(beat=<that beat>, skip=true), take the default, and never ask it again in the same form. If they want to stop altogether, say in one line that the Skip setup button ends it, then carry on; only they can end it, with that button.
- Off-script requests are done now, then you bring the card back.
+- You may look around this computer when they say yes: installed apps, developer tools, the OS and the hardware, read with the terminal. Never personal files, documents, browser data or messages without a specific ask. A yes to looking is an off-script request: act on it at any beat.
Voice: every word you write is spoken to the user. Never think out loud. Never mention beats, cards, tools, reminders or a script, and never call this setup or onboarding (the Skip setup button's name is the one exception). One or two short, plain sentences per message: warm, like the front desk of somewhere good. No thanks, no praise, no stock lines, no em dashes, no exclamation marks. Write in the user's language when the locale is not English, labels included.
@@ -102,7 +103,8 @@ _LOOK_AROUND = (
"Before the card, offer once to look around this computer and suggest what to connect. Only on yes, and "
"only installed apps, developer tools, the OS and the hardware; never personal files, documents, browser "
"data or messages without a specific ask. Then show the card with what you suggest: "
- 'setup_beat(beat="connectors", suggest=[<connector slugs>]).')
+ 'setup_beat(beat="connectors", suggest=[<connector slugs>]). If they say no, show it with '
+ 'setup_beat(beat="connectors").')
# How a typed answer settles each beat without the card.
_TYPED_ANSWER = {
@@ -218,8 +220,7 @@ def _next(record: Mapping[str, Any]) -> str:
def _after_layout(record, facts) -> str:
label = {"sidebar-left": "Basic", "terminal-deck": "Elite"}.get(record["picks"]["layout"], record["picks"]["layout"])
- offer = f" {_LOOK_AROUND}" if record["look_around"] == "not_offered" else ""
- return f"Layout {label} is on, already applied. Do not call set_theme for it again. {_next(record)}{offer}"
+ return f"Layout {label} is on, already applied. Do not call set_theme for it again. {_next(record)}"
def _after_connectors(record, facts) -> str:
@@ -250,6 +251,7 @@ _REMINDERS = {
"after_theme": lambda r, f: (f"Accent {r['picks']['accent'] or 'Nous blue'} is on, already applied. Do not call "
f"set_theme for it again. React in three words or fewer. {_next(r)}"),
"after_layout": _after_layout,
+ "offer_first": lambda r, f: f"The connectors card is not shown yet. {_LOOK_AROUND}",
"after_connectors": _after_connectors,
"after_plugins": _after_plugins,
"after_tour": lambda r, f: f"The tour is already running; do not start it again. {_next(r)}",
diff --git a/tests/agent/test_onboarding_flow.py b/tests/agent/test_onboarding_flow.py
index 9a74b10602a..68834cafe03 100644
--- a/tests/agent/test_onboarding_flow.py
+++ b/tests/agent/test_onboarding_flow.py
@@ -14,7 +14,7 @@ from agent.onboarding_flow import (
TimedOut, apply, new_record, next_beat,
)
from agent.onboarding_first_tasks import eligible_tasks
-from agent.onboarding_text import opening_prompt, reminder, turn_note
+from agent.onboarding_text import _LOOK_AROUND, opening_prompt, reminder, turn_note
NOTES = [{"id": "notes", "label": "Notes to wiki"}]
@@ -50,7 +50,8 @@ def answer_all(facts: Facts) -> list:
first = eligible_tasks(facts, record["picks"])[0]
answer = answers.get(beat) or {"build": first.id}
options = [{"id": first.id, "label": first.label}] if beat == "build" else None
- for event in (Shown(beat, f"call_{beat}", options), Answered(beat, answer)):
+ suggest = ["slack"] if beat == "connectors" else None
+ for event in (Shown(beat, f"call_{beat}", options, suggest), Answered(beat, answer)):
events.append(event)
record = apply(record, event, facts).record
return [*events, Done()]
@@ -155,22 +156,73 @@ def test_run_hrs0_off_script_questions_keep_one_card_and_continue_settles_it():
assert steps[-1].record["beats"]["connectors"] == DONE
-def test_run_3ofn_pick_for_me_applies_layout_and_offers_the_look_around_once():
- """3ofn: "look around and pick one for me" ended in Elite through set_theme; the look-around
- offer rides the layout result once."""
+LAYOUT_SET = Applied("set_theme", {"layout": "terminal-deck"}, {"success": True, "applied": {"layout": "terminal-deck"}})
+TO_LAYOUT = (Shown("name"), Answered("name", {"name": "Sid"}), Shown("theme"), Answered("theme", {"accent": "Ember"}),
+ Shown("layout"))
+
+
+def test_run_3ofn_pick_for_me_applies_layout_and_the_look_around_offer_waits_for_the_connectors_card():
+ """3ofn: "look around and pick one for me" ended in Elite through set_theme. The offer no longer
+ rides the layout result: it comes back on the first try to show the connectors card."""
facts = MACHINES["mac"]
- steps = run(facts, Shown("name"), Answered("name", {"name": "Sid"}), Shown("theme"),
- Answered("theme", {"accent": "Ember"}), Shown("layout"),
- Said("layout", "look around and pick one for me"),
- Applied("set_theme", {"layout": "terminal-deck"}, {"success": True, "applied": {"layout": "terminal-deck"}}),
- Shown("connectors"))
-
- layout_done = steps[-2].record
- assert "look around" in reminder("after_layout", layout_done, facts)
- assert steps[-1].record["look_around"] == "offered"
+ steps = run(facts, *TO_LAYOUT, Said("layout", "look around and pick one for me"), LAYOUT_SET)
+
+ assert steps[-1].record["beats"]["layout"] == DONE and steps[-1].record["look_around"] == "not_offered"
assert "look around" not in reminder("after_layout", steps[-1].record, facts)
+def test_vesper_batched_set_theme_and_next_gets_the_offer_then_the_second_next_shows_connectors():
+ """Vesper run 1: set_theme(layout) and setup_beat(next) in one batch put the connectors card up before
+ the offer was made, and the run recorded it as offered."""
+ facts = MACHINES["windows_laptop"]
+ steps = run(facts, *TO_LAYOUT, LAYOUT_SET, Shown("connectors", "call_a"), Shown("connectors", "call_b"))
+
+ refused, shown = steps[-2], steps[-1]
+ assert refused.result == {"error": "offer first"} and "beat" not in refused.result
+ assert refused.reminder == "offer_first" and refused.record["look_around"] == "offered"
+ assert refused.record["beats"]["connectors"] == PENDING and refused.record["waiting"] is None
+ assert _LOOK_AROUND in reminder(refused.reminder, refused.record, facts)
+ assert shown.result == {} and shown.record["beats"]["connectors"] == SHOWN
+ assert shown.record["waiting"]["tool_call_id"] == "call_b"
+
+
+def test_showing_connectors_directly_before_the_offer_is_refused():
+ facts = MACHINES["mac"]
+ step = run(facts, Shown("connectors", "call_1"))[-1]
+
+ assert step.result == {"error": "offer first"} and step.reminder == "offer_first"
+ assert step.record["beats"]["connectors"] == PENDING and step.record["waiting"] is None
+ assert step.record["look_around"] == "offered"
+
+
+def test_suggestions_mean_the_model_already_looked_so_the_card_shows_at_once():
+ facts = MACHINES["mac"]
+ step = run(facts, Shown("connectors", "call_1", suggest=["slack", "linear"]))[-1]
+
+ assert step.result == {} and step.record["beats"]["connectors"] == SHOWN
+ assert step.record["look_around"] == "offered"
+ # Blank slugs are not suggestions.
+ assert run(facts, Shown("connectors", "call_1", suggest=[" "]))[-1].result == {"error": "offer first"}
+
+
[email protected]("state", ["declined", "accepted"])
+def test_a_settled_look_around_state_shows_the_card_and_stays(state):
+ facts = MACHINES["mac"]
+ record = {**new_record(facts), "look_around": state}
+ step = apply(record, Shown("connectors", "call_1"), facts)
+
+ assert step.result == {} and step.record["beats"]["connectors"] == SHOWN
+ assert step.record["look_around"] == state
+
+
+def test_the_opening_prompt_grants_the_look_and_bounds_it():
+ text = opening_prompt(MACHINES["mac"])
+
+ assert "look around this computer when they say yes" in text
+ assert "installed apps, developer tools, the OS and the hardware" in text
+ assert "Never personal files" in text and "act on it at any beat" in text
+
+
def test_skip_setup_while_a_card_waits_ends_the_run_and_refuses_later_beats():
facts = MACHINES["windows_laptop"]
steps = run(facts, Shown("name"), Answered("name", {"name": "Sid"}), Shown("theme"), End(), Shown("theme"))
diff --git a/tests/tools/test_setup_beat_tool.py b/tests/tools/test_setup_beat_tool.py
index deabcc05dcd..a180d2694ed 100644
--- a/tests/tools/test_setup_beat_tool.py
+++ b/tests/tools/test_setup_beat_tool.py
@@ -94,8 +94,9 @@ def test_no_answer_closes_the_card_and_typed_words_come_back_as_said(db, desktop
def test_a_card_closed_by_words_a_value_or_the_deadline_reports_what_is_connected_and_installed(db, desktop):
onboarding_record.start(db, SID, FACTS)
timed_out = call(db, desktop, beat="plugins")
+ call(db, desktop, beat="connectors", call_id="call_2") # refused once: the look-around offer
desktop.replies.append({"said": "done"})
- said = call(db, desktop, beat="connectors", call_id="call_2")
+ said = call(db, desktop, beat="connectors", call_id="call_3")
continued = call(db, desktop, beat="connectors", value="continue")
assert timed_out["installed"] == ["blender"] and said["connected"] == ["slack"]
@@ -115,6 +116,21 @@ def test_suggest_pins_connectors_and_value_or_skip_records_without_a_card(db, de
assert skipped["skipped"] is True
+def test_next_to_the_connectors_card_before_the_offer_is_refused_without_a_card(db, desktop):
+ onboarding_record.start(db, SID, FACTS)
+ for beat in ("name", "theme", "layout"):
+ call(db, desktop, beat=beat, skip=True)
+
+ refused = call(db, desktop, beat="next")
+ desktop.replies.append({"answer": {"connected": [], "newly_connected": []}})
+ shown = call(db, desktop, beat="next", call_id="call_2")
+
+ assert refused["error"] == "offer first" and "beat" not in refused
+ assert "offer once to look around" in refused["reminder"]
+ assert [card["beat"] for card in desktop.shown] == ["connectors"]
+ assert shown["answer"] == {"connected": [], "newly_connected": []} and shown["next"] == "plugins"
+
+
def test_skip_setup_during_a_card_returns_skipped_all(db, desktop):
onboarding_record.start(db, SID, FACTS)
diff --git a/tools/setup_beat_tool.py b/tools/setup_beat_tool.py
index f7d9d2b2144..e2d0fb93488 100644
--- a/tools/setup_beat_tool.py
+++ b/tools/setup_beat_tool.py
@@ -120,7 +120,7 @@ def setup_beat_tool(args: Mapping[str, Any], *, db=None, session_id: str = "", t
else {"error": "Onboarding is over in this chat; it is a normal chat now."})
if callback is None:
return tool_error("setup_beat cards show only in the Hermes desktop app.")
- shown = records.advance(db, session_id, flow.Shown(beat, tool_call_id, args.get("options")))
+ shown = records.advance(db, session_id, flow.Shown(beat, tool_call_id, args.get("options"), args.get("suggest")))
if shown.result: # refused, or a beat this machine skips
return _result(shown)
question = str(args.get("question") or "").strip() or QUESTIONS[beat]