The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(onboarding): connector suggestions come from the connectors this account can connect
alt-glitcha4cdd78047c3
diff --git a/tests/tools/test_setup_beat_tool.py b/tests/tools/test_setup_beat_tool.pyindex b2ce88613e4..2b53aab7141 100644--- a/tests/tools/test_setup_beat_tool.py+++ b/tests/tools/test_setup_beat_tool.py@@ -35,6 +35,8 @@ def machine(monkeypatch):monkeypatch.setattr("tools.setup_beat_tool._PRESENT", {"connectors": lambda: {"connected": present["connected"]},"plugins": lambda: {"installed": present["installed"]}})+ # No connector list unless a test gives one: suggestions are not checked.+ monkeypatch.setattr("tools.setup_beat_tool._connector_slugs", lambda: None)return present@@ -123,6 +125,23 @@ def test_suggest_pins_connectors_and_value_or_skip_records_without_a_card(db, deassert skipped["skipped"] is True+def test_the_offer_lists_the_real_connectors_and_an_unlisted_suggestion_shows_no_card(db, desktop, monkeypatch):+ # The model guessed GitHub from the gh CLI; this account cannot connect it, and the card showed nothing.+ monkeypatch.setattr("tools.setup_beat_tool._connector_slugs", lambda: {"slack", "linear"})+ onboarding_record.start(db, SID, FACTS)+ for beat in ("name", "theme", "layout"):+ call(db, desktop, beat=beat, skip=True)++ offer = call(db, desktop, beat="next")+ refused = call(db, desktop, beat="connectors", suggest=["github", "slack"], call_id="call_2")+ desktop.replies.append({"answer": {"connected": [], "newly_connected": []}})+ call(db, desktop, beat="connectors", suggest=["slack"], call_id="call_3")++ assert "by these slugs: linear, slack." in offer["reminder"]+ assert refused["error"] == "not connectors here" and "No card shown: github cannot" in refused["reminder"]+ assert [card["card"] for card in desktop.shown] == [{"suggested": ["slack"]}]++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"):diff --git a/tools/setup_beat_tool.py b/tools/setup_beat_tool.pyindex fb5d6976abb..55c80aa3e2a 100644--- a/tools/setup_beat_tool.py+++ b/tools/setup_beat_tool.py@@ -85,14 +85,40 @@ def _skill_resolver() -> Callable[[str], str | None]:return lambda name: catalog_plugin_skill(name) if ":" in name else (name if name in bundled else None)-def _result(step: flow.Step, beat: str | None = None) -> str:+def _result(step: flow.Step, beat: str | None = None, extra: str = "") -> str:facts = flow.Facts.from_stored(step.record["facts"])# Only a first task's reminder names skills; the skills scan is skipped for every other result.resolve_skill = _skill_resolver() if step.reminder.startswith("build_") else (lambda name: name)- text = reminder(step.reminder, step.record, facts, beat, resolve_skill)+ text = reminder(step.reminder, step.record, facts, beat, resolve_skill) + extrareturn json.dumps({**step.result, **({"reminder": text} if text else {})}, ensure_ascii=False)+def _connector_slugs() -> set[str] | None:+ """The connectors this account can connect, as the card lists them; None when the list is unreachable."""+ from tools.connectors.targets import hosted_names++ return hosted_names()+++def _suggest_from(slugs: set[str] | None) -> str:+ # The model guesses an app's connector from what is installed (GitHub from the gh CLI); the card shows+ # only listed ones, so it names its suggestions from this list.+ return f" Suggest only connectors from this list, by these slugs: {', '.join(sorted(slugs))}." if slugs else ""+++def _unlisted_suggestions(args: Mapping[str, Any]) -> str | None:+ """The refusal for connector suggestions the card cannot show, or None when every one is listed."""+ wanted = [str(slug).strip().lower() for slug in args.get("suggest") or () if str(slug).strip()]+ slugs = _connector_slugs() if wanted else None+ unlisted = [slug for slug in wanted if slugs is not None and slug not in slugs]+ if not unlisted:+ return None+ return json.dumps({"error": "not connectors here", "reminder": (+ f"No card shown: {', '.join(unlisted)} cannot be connected here. Do not mention them as connections."+ f"{_suggest_from(slugs)} Then call setup_beat(beat=\"connectors\", suggest=[...]) again, or without "+ "suggest when none fits.")}, ensure_ascii=False)++def _card(beat: str, step: flow.Step, args: Mapping[str, Any]) -> dict:facts = flow.Facts.from_stored(step.record["facts"])card = flow.BEAT_BY_ID[beat].card(facts, step.record["picks"])@@ -129,9 +155,12 @@ def setup_beat_tool(args: Mapping[str, Any], *, db=None, session_id: str = "", telse {"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.")+ if beat == "connectors" and (refused := _unlisted_suggestions(args)):+ return refusedshown = 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)+ extra = _suggest_from(_connector_slugs()) if shown.reminder == "offer_first" else ""+ return _result(shown, extra=extra)question = str(args.get("question") or "").strip() or beat_question(beat, (record.get("facts") or {}).get("locale"))reply = callback({"beat": beat, "question": question, "card": _card(beat, shown, args),"tool_call_id": tool_call_id or None})