The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(setup): gate the setup toolset per session platform on every surface
alt-glitch7182a214bb84
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex 60997e229c1..9361b16a7c6 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -1132,7 +1132,8 @@ def _load_tools(agent, enabled_toolsets, disabled_toolsets):from agent.oneshot_footprint import prune_oneshot_toolsagent.tools = prune_oneshot_tools(agent.tools or [])from tools.connectors.turn import side_agent_tool_drops- drops = side_agent_tool_drops(agent)+ from toolsets import session_platform_tool_drops+ drops = side_agent_tool_drops(agent) | session_platform_tool_drops(getattr(agent, "platform", None))if drops:agent.tools = [t for t in agent.tools if t["function"]["name"] not in drops]diff --git a/apps/desktop/src/app/contrib/onboarding-handoff.ts b/apps/desktop/src/app/contrib/onboarding-handoff.tsindex 0773ff990aa..7410d21f112 100644--- a/apps/desktop/src/app/contrib/onboarding-handoff.ts+++ b/apps/desktop/src/app/contrib/onboarding-handoff.ts@@ -36,7 +36,7 @@ import {setBusy,setSessionOwnerHint} from '@/store/session'-import { patchSessionTile } from '@/store/session-states'+import { $sessionStates, patchSessionTile } from '@/store/session-states'import { BUILD_PROFILE, type HandoffDeps, type HandoffReceipt, paintHandoffBrief, startHandoff } from './handoff-leg'import { saveHandoffReceipt } from './handoff-receipt'@@ -61,11 +61,18 @@ export function useOnboardingHandoff({}: OnboardingHandoffOptions) {const setupHandoff = useStore($setupHandoff)const selectedStoredId = useStore($selectedStoredSessionId)+ const activeSessionId = useStore($activeSessionId)useEffect(() => watchPluginOutcomes(() => $setupSession.get()?.runtimeId), [])useEffect(() => {- if (!isOnboardingEnabled() || $setupHandoff.get() || !selectedStoredId) {+ if (+ !isOnboardingEnabled() ||+ $setupHandoff.get() ||+ !selectedStoredId ||+ !activeSessionId ||+ $sessionStates.get()[activeSessionId]?.storedSessionId !== selectedStoredId+ ) {return}@@ -94,7 +101,7 @@ export function useOnboardingHandoff({$setupSession.set({connectionId,profile: $activeGatewayProfile.get(),- runtimeId: $activeSessionId.get() ?? '',+ runtimeId: activeSessionId,storedId: selectedStoredId})$setupHandoff.set({ task: saved.task, brief: saved.brief, plan: saved.plan, phase: 'pending' })@@ -105,7 +112,7 @@ export function useOnboardingHandoff({message: error instanceof Error ? error.message : 'The first-build receipt could not be read.'})}- }, [selectedStoredId])+ }, [activeSessionId, selectedStoredId])// eslint-disable-next-line no-restricted-syntaxuseEffect(() => {diff --git a/hermes_cli/setup_profile.py b/hermes_cli/setup_profile.pyindex a9b1f307b43..fe5914bc93a 100644--- a/hermes_cli/setup_profile.py+++ b/hermes_cli/setup_profile.py@@ -59,9 +59,13 @@ def ensure_setup_profile() -> SetupProfile:return SetupProfile(found[0], found[1], created=False)name = _free_setup_profile_name()path = profiles_mod.create_profile(name, clone_config=True, no_alias=True, description=SETUP_PROFILE_DESCRIPTION)- _write_soul(path)- _enable_setup_toolset(path)- (path / profiles_mod.SETUP_PROFILE_MARKER).write_text("{}\n", encoding="utf-8")+ try:+ _write_soul(path)+ _enable_setup_toolset(path)+ (path / profiles_mod.SETUP_PROFILE_MARKER).write_text("{}\n", encoding="utf-8")+ except BaseException:+ profiles_mod.delete_profile(name, yes=True)+ raisereturn SetupProfile(name, path, created=True)diff --git a/model_tools.py b/model_tools.pyindex 06692961ec3..eb84ae5a814 100644--- a/model_tools.py+++ b/model_tools.py@@ -324,9 +324,10 @@ def _select_tool_names(enabled_toolsets: Optional[List[str]], disabled_toolsets:enabled.append("kanban")_apply_toolset_selection(tools, enabled, quiet_mode, disable=False)else:- from toolsets import get_all_toolsets+ from toolsets import TOOLSET_SESSION_PLATFORMS, get_all_toolsetsfor ts_name in get_all_toolsets():- tools.update(resolve_toolset(ts_name))+ if ts_name not in TOOLSET_SESSION_PLATFORMS:+ tools.update(resolve_toolset(ts_name))# Disabled toolsets are always subtracted LAST, so a tool in a disabled# toolset is stripped even when a composite (hermes-cli) re-enables it.# This ensures that even if a composite toolset (like hermes-cli) is enabled, any tools belonging to adiff --git a/tests/tools/test_connectors_catalog.py b/tests/tools/test_connectors_catalog.pyindex ef924cb87b5..4322710ca01 100644--- a/tests/tools/test_connectors_catalog.py+++ b/tests/tools/test_connectors_catalog.py@@ -101,19 +101,6 @@ def _approve(env=None):for t in payload["targets"] if t["state"] == "pending"]}-def test_only_a_desktop_session_keeps_the_setup_toolset():- import model_tools- from tui_gateway import server-- for platform, expected in (("desktop", True), ("tui", False)):- selection = server._with_session_toolsets(["setup", "web"], platform)- names = model_tools._select_tool_names(selection, None, quiet_mode=True)- assert ("manage_catalog" in names) is expected, platform- # The setup guide's one tool is sent directly, never hidden behind tool_search.- from tools.tool_search import is_deferrable_tool_name- assert not is_deferrable_tool_name("manage_catalog")--@pytest.mark.parametrize("args", [{"action": "install", "items": [{"kind": "plugin", "id": "x"}], "profile": "work"},{"action": "install", "items": [{"kind": "plugin", "id": "x", "sha": "b" * 40}]},diff --git a/tools/mcp_tool_agent.py b/tools/mcp_tool_agent.pyindex 94f711b32aa..d33af1512c5 100644--- a/tools/mcp_tool_agent.py+++ b/tools/mcp_tool_agent.py@@ -52,9 +52,10 @@ def _tool_defs_content_changed(agent, new_defs: list) -> bool:return False-def _drop_side_agent_tools(agent, new_defs: list, new_names: set) -> tuple:+def _drop_session_tools(agent, new_defs: list, new_names: set) -> tuple:from tools.connectors.turn import side_agent_tool_drops- drops = side_agent_tool_drops(agent)+ from toolsets import session_platform_tool_drops+ drops = side_agent_tool_drops(agent) | session_platform_tool_drops(getattr(agent, "platform", None))if not drops:return new_defs, new_namesreturn [entry for entry in new_defs if _def_name(entry) not in drops], new_names - drops@@ -76,7 +77,7 @@ def _publish_tool_snapshot(current = {_def_name(t) for t in current_defs}if prefix_registered is not None:new_defs, new_names = _merge_preserving_prefix(current_defs, new_defs, prefix_registered)- new_defs, new_names = _drop_side_agent_tools(agent, new_defs, new_names)+ new_defs, new_names = _drop_session_tools(agent, new_defs, new_names)# Record the generation even when unchanged so an in-flight older caller can't clobber.agent._tool_snapshot_generation = max(published_gen, snapshot_generation)# Same NAME set: no change for MCP-reload callers. Content-aware callers@@ -173,7 +174,7 @@ def persist_agent_tool_names(agent) -> None:def _config_permitted_names(agent) -> set:"""Tool names this agent's toolset selection allows before ``check_fn``: all a pin may carryforward. A client-surface toolset counts as allowed (only its client can add it, so its absence- here is no config choice); ``disabled_toolsets`` and role reservations still strip it."""+ here is no config choice); ``disabled_toolsets`` still strip it."""from model_tools import _select_tool_namesfrom toolsets import CLIENT_SURFACE_TOOLSETSenabled = getattr(agent, "enabled_toolsets", None)@@ -227,7 +228,7 @@ def restore_agent_tool_prefix(agent, saved) -> bool:merged = _drop_gated_carried_tools(merged, carried)merged_names = {_def_name(t) for t in merged}_reinject_authorized_dynamic_tools(agent, merged, merged_names)- merged, merged_names = _drop_side_agent_tools(agent, merged, merged_names)+ merged, merged_names = _drop_session_tools(agent, merged, merged_names)changed = merged != fresh_defsif changed:with _agent_tools_lock:diff --git a/toolsets.py b/toolsets.pyindex aba525b7ade..23d57c7eb93 100644--- a/toolsets.py+++ b/toolsets.py@@ -389,7 +389,8 @@ def resolve_toolset(name: str, visited: Set[str] = None, *, include_registry: boif name in {"all", "*"}:all_tools: Set[str] = set()for toolset_name in get_toolset_names():- all_tools.update(resolve_toolset(toolset_name, visited.copy(), include_registry=include_registry))+ if toolset_name not in TOOLSET_SESSION_PLATFORMS:+ all_tools.update(resolve_toolset(toolset_name, visited.copy(), include_registry=include_registry))return sorted(all_tools)# Diamond include or cycle: [] silently — the tools are collected via another path.@@ -452,6 +453,11 @@ def get_toolset_names() -> List[str]:return sorted(set(TOOLSETS.keys()) | set(_plugin_display_names()))+def session_platform_tool_drops(platform: Optional[str]) -> frozenset:+ return frozenset(tool for name, platforms in TOOLSET_SESSION_PLATFORMS.items() if platform not in platforms+ for tool in resolve_toolset(name))++def validate_toolset(name: str) -> bool:return (name in {"all", "*"} or name in TOOLSETSor name in _get_plugin_toolset_names() or name in _get_registry_toolset_aliases())diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 9c93025dc2e..f6c67f36d79 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -1947,14 +1947,12 @@ def _with_session_toolsets(selection, platform: str | None) -> list[str]:[project]`` is a no-op on desktop/TUI, the only surfaces where the client toolsets exist(#54433). ``desktop_ui`` is kept regardless: it is the client's own control surface, not amodel toolset."""- from toolsets import TOOLSET_SESSION_PLATFORMSsurface = _gui_surface_toolsets(platform) if platform is not None else set()- kept = [name for name in selection if platform in TOOLSET_SESSION_PLATFORMS.get(name, {platform})]- fold_in = surface - set(kept)+ fold_in = surface - set(selection)disabled = set(_load_disabled_toolsets() or [])if disabled:fold_in -= disabled - {"desktop_ui"}- return [*kept, *sorted(fold_in)]+ return [*selection, *sorted(fold_in)]def _tui_notice(text: str) -> None:@@ -2015,6 +2013,10 @@ def _load_enabled_toolsets(platform: str | None = None) -> list[str] | None:from agent.coding_context import coding_selectionselection = coding_selection(platform=session_platform)if selection is not None:+ from hermes_cli.config import load_config+ from hermes_cli.tools_config import _get_platform_tools+ from toolsets import TOOLSET_SESSION_PLATFORMS+ selection += sorted(_get_platform_tools(load_config(), "cli") & TOOLSET_SESSION_PLATFORMS.keys())return sorted(_with_session_toolsets(selection, session_platform))try:from toolsets import validate_toolsetdiff --git a/website/docs/reference/tools-reference.md b/website/docs/reference/tools-reference.mdindex bb9da2c864a..5f5fd9ad1fb 100644--- a/website/docs/reference/tools-reference.md+++ b/website/docs/reference/tools-reference.md@@ -182,11 +182,11 @@ Tools for driving desktop [Projects](../user-guide/cli.md) — named, multi-fold## `setup` toolset-Enabled by the desktop setup profile's own config (`platform_toolsets.cli`); only desktop sessions keep it. Not listed by `hermes tools`.+Enabled by the desktop setup profile's own config (`platform_toolsets.cli`). Only desktop sessions get its tool; CLI, `hermes -z`, cron, kanban and messaging sessions never do. `all` does not include it. Not listed by `hermes tools`.| Tool | Description | Requires environment ||------|-------------|----------------------|-| `manage_catalog` | Setup profile only (the `setup` toolset), desktop chat only. `search` lists catalog plugins and hub skills matching `query` (optionally one `kind`) with `id`, `kind`, `display`, `tier`, `platforms` and `installed` (present in the `default` profile); it changes nothing. `install` takes `items: [{kind, id}]` and shows one approval card with a row per item (Install, Advanced, Skip); an id the catalog does not know, or a plugin this OS cannot run, is drawn failed with the reason. An approved row installs into `default` (or the profile chosen under Advanced) at the catalog's reviewed commit, with the same kill list, security scan and live activation as the Plugins tab, so the plugin's MCP tools and skills are usable in that profile's open chats at once. The result lists each row as `connected` (with `tools` and `skill`), `skipped`, `failed` (with `detail`) or `not_connected`. The model cannot pass a source, commit, profile or setting. Anywhere else the call returns the `hermes plugins install` / `hermes skills install` command to run instead. | — |+| `manage_catalog` | Only through the `setup` toolset named in a profile's config (`all` does not include it), desktop sessions only. `search` lists catalog plugins and hub skills matching `query` (optionally one `kind`) with `id`, `kind`, `display`, `tier`, `platforms` and `installed` (present in the `default` profile); it changes nothing. `install` takes `items: [{kind, id}]` and shows one approval card with a row per item (Install, Advanced, Skip); an id the catalog does not know, or a plugin this OS cannot run, is drawn failed with the reason. An approved row installs into `default` (or the profile chosen under Advanced) at the catalog's reviewed commit, with the same kill list, security scan and live activation as the Plugins tab, so the plugin's MCP tools and skills are usable in that profile's open chats at once. The result lists each row as `connected` (with `tools` and `skill`), `skipped`, `failed` (with `detail`) or `not_connected`. The model cannot pass a source, commit, profile or setting. Anywhere else the call returns the `hermes plugins install` / `hermes skills install` command to run instead. | — |## `session_search` toolsetdiff --git a/website/docs/reference/toolsets-reference.md b/website/docs/reference/toolsets-reference.mdindex 7c5537055c7..943dbcbffc8 100644--- a/website/docs/reference/toolsets-reference.md+++ b/website/docs/reference/toolsets-reference.md@@ -77,7 +77,7 @@ Or in-session:| `safe` | `image_generate`, `vision_analyze`, `web_extract`, `web_search` (via `includes`) | Read-only research + media generation. No file writes, no terminal, no code execution. || `search` | `web_search` | Web search only (without extract). || `session_search` | `session_search` | Search past conversation sessions. |-| `setup` | `manage_catalog` | Onboarding-only surface of the desktop setup profile: search the plugin catalog and skills hub, and install items through the approval card. The setup profile's own config enables it (`platform_toolsets.cli`), and only desktop sessions keep it. Not listed by `hermes tools`. |+| `setup` | `manage_catalog` | Onboarding-only surface of the desktop setup profile: search the plugin catalog and skills hub, and install items through the approval card. The setup profile's own config enables it (`platform_toolsets.cli`), and only desktop sessions get its tool. `all` does not include it. Not listed by `hermes tools`. || `skills` | `skill_manage`, `skill_view`, `skills_list` | Skill CRUD and browsing. || `spotify` | `spotify_albums`, `spotify_devices`, `spotify_library`, `spotify_playback`, `spotify_playlists`, `spotify_queue`, `spotify_search` | Native Spotify control (playback, queue, search, playlists, albums, library). Registered by the bundled `spotify` plugin. || `terminal` | `process_manage`, `terminal` | Shell command execution and background process management. |