Skip to content

The agent that grows with you

feat: setup profile sessions get the setup toolset by profile role; nothing else can grant it (#119491)

Siddharth Balyan333898b353c2
diff --git a/model_tools.py b/model_tools.py
index f0e56c19e2f..9a068d5a1b4 100644
--- a/model_tools.py
+++ b/model_tools.py
@@ -326,6 +326,11 @@ def _select_tool_names(enabled_toolsets: Optional[List[str]], disabled_toolsets:
from toolsets import get_all_toolsets
for ts_name in get_all_toolsets():
tools.update(resolve_toolset(ts_name))
+ # A role-reserved toolset (``setup``) reaches only a profile carrying that role, whatever the config,
+ # CLI flag, env pin or "all" asked for; this is the one point every surface's selection passes.
+ from toolsets import profile_role_toolsets
+ for ts_name in profile_role_toolsets()[1]:
+ tools.difference_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 a
diff --git a/toolsets.py b/toolsets.py
index 1b2da7f579f..5d031fe418f 100644
--- a/toolsets.py
+++ b/toolsets.py
@@ -1,5 +1,6 @@
"""Toolset helpers: get/resolve/validate named tool groups (static TOOLSETS + registry-registered)."""
+from pathlib import Path
from typing import Dict, List, Any, Set, Optional, Tuple
@@ -141,6 +142,16 @@ TOOLSETS = {
"annotate_preview", "read_window_below", "focus_pane", "react_to_message",
"gui_tour", "show_tip"],
),
+ # Enabled per SESSION whose PROFILE carries ``role: setup`` in its backend-written
+ # profile.yaml (tui_gateway/server.py::_load_enabled_toolsets); stripped from every
+ # other profile's selection whatever the config, env pin or client asked for
+ # (model_tools._select_tool_names). Never configurable, never in `hermes tools`.
+ "setup": _ts(
+ "Onboarding-only surface for the setup profile: catalog plugin/skill install "
+ "requests through the approval card",
+ [],
+ role="setup",
+ ),
"clarify": _ts("Ask the user clarifying questions (multiple-choice or open-ended)", ["clarify"]),
"code_execution": _ts("Run Python scripts that call tools programmatically (reduces LLM round trips)", ["execute_code"]),
"delegation": _ts("Spawn subagents with isolated context for complex subtasks", ["delegate_task"]),
@@ -436,6 +447,18 @@ def get_toolset_names() -> List[str]:
return sorted(set(TOOLSETS.keys()) | set(_plugin_display_names()))
+def profile_role_toolsets(profile_home: Optional[Path] = None) -> Tuple[Set[str], Set[str]]:
+ """``(granted, denied)`` for the profile at *profile_home* (default: the in-scope home; a session's
+ home override, when bound, IS its profile dir): toolsets reserved for the role in its backend-written
+ ``profile.yaml``, and toolsets reserved for any other role. An ordinary profile is granted none."""
+ from hermes_cli.profiles import read_profile_meta
+ from hermes_constants import get_hermes_home
+ role = read_profile_meta(Path(profile_home or get_hermes_home())).get("role")
+ granted = {name for name, spec in TOOLSETS.items() if role is not None and spec.get("role") == role}
+ denied = {name for name, spec in TOOLSETS.items() if spec.get("role") not in (None, role)}
+ return granted, denied
+
+
def validate_toolset(name: str) -> bool:
return (name in {"all", "*"} or name in TOOLSETS
or name in _get_plugin_toolset_names() or name in _get_registry_toolset_aliases())
diff --git a/tui_gateway/server.py b/tui_gateway/server.py
index ac907b6f1a4..56a188d5fe9 100644
--- a/tui_gateway/server.py
+++ b/tui_gateway/server.py
@@ -1829,6 +1829,17 @@ def _gui_surface_toolsets(platform: str) -> set[str]:
return {"project", "desktop_ui"} if platform == "desktop" else {"project"}
+def _with_session_toolsets(selection, platform: str | None) -> list[str]:
+ """*selection* plus what the session carries whatever its config says (the client surface's
+ toolsets when *platform* is given; the ones its PROFILE's role reserves, from the backend-written
+ profile.yaml under the session's home override), minus toolsets reserved for another role."""
+ from toolsets import profile_role_toolsets
+ granted, denied = profile_role_toolsets()
+ surface = _gui_surface_toolsets(platform) if platform is not None else set()
+ kept = [name for name in selection if name not in denied]
+ return [*kept, *sorted((surface | granted) - set(kept))]
+
+
def _tui_notice(text: str) -> None:
print(text, file=sys.stderr, flush=True)
@@ -1887,7 +1898,7 @@ def _load_enabled_toolsets(platform: str | None = None) -> list[str] | None:
from agent.coding_context import coding_selection
selection = coding_selection(platform=session_platform)
if selection is not None:
- return sorted({*selection, *_gui_surface_toolsets(session_platform)})
+ return sorted(_with_session_toolsets(selection, session_platform))
try:
from toolsets import validate_toolset
except Exception:
@@ -1895,7 +1906,8 @@ def _load_enabled_toolsets(platform: str | None = None) -> list[str] | None:
if explicit and validate_toolset is not None:
resolved = _resolve_explicit_toolsets(explicit, validate_toolset)
if resolved is not False:
- return resolved
+ # An operator pin replaces the surface fold-in but never strips the profile's own role toolsets.
+ return resolved if resolved is None else _with_session_toolsets(resolved, None)
fallback_notice = "[tui] no valid HERMES_TUI_TOOLSETS entries; using configured CLI toolsets"
try:
from hermes_cli.config import load_config
@@ -1909,7 +1921,7 @@ def _load_enabled_toolsets(platform: str | None = None) -> list[str] | None:
enabled = _get_platform_tools(cfg, "cli", include_default_mcp_servers=True)
if fallback_notice is not None:
_tui_notice(fallback_notice)
- return sorted(enabled | _gui_surface_toolsets(session_platform)) if enabled else None
+ return sorted(_with_session_toolsets(enabled, session_platform)) if enabled else None
except Exception:
if fallback_notice is not None:
_tui_notice("[tui] no valid HERMES_TUI_TOOLSETS entries and configured CLI toolsets could not be loaded; enabling all toolsets")
diff --git a/website/docs/reference/toolsets-reference.md b/website/docs/reference/toolsets-reference.md
index 279c6a4d6c3..03b34044a83 100644
--- a/website/docs/reference/toolsets-reference.md
+++ b/website/docs/reference/toolsets-reference.md
@@ -77,6 +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` | (none yet) | Onboarding-only surface of the desktop setup profile (catalog install requests through the approval card). Granted by the backend to sessions whose profile carries `role: setup` in its `profile.yaml`; stripped from every other profile even when a config list, `HERMES_TUI_TOOLSETS`, or `all` names it. Not configurable and 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. |