The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): subtract disabled_toolsets from the client-surface fold-in
Bartok9903a57c54091
diff --git a/tests/tui_gateway/test_tui_gateway_server.py b/tests/tui_gateway/test_tui_gateway_server.pyindex 9de8e9b63d5..a64e5ca31f8 100644--- a/tests/tui_gateway/test_tui_gateway_server.py+++ b/tests/tui_gateway/test_tui_gateway_server.py@@ -2365,6 +2365,60 @@ def test_load_enabled_toolsets_folds_project_into_focus_posture(monkeypatch):assert server._load_enabled_toolsets("tui") == ["coding", "figma", "project"]+def test_load_enabled_toolsets_honors_disabled_project_on_focus_path(monkeypatch):+ """#54433: focus/coding posture must not re-add `project` when disabled."""+ monkeypatch.delenv("HERMES_TUI_TOOLSETS", raising=False)++ import agent.coding_context as cc++ monkeypatch.setattr(cc, "coding_selection", lambda **_: ["coding", "figma"])+ monkeypatch.setattr(server, "_load_disabled_toolsets", lambda: ["project"])++ result = server._load_enabled_toolsets("tui")+ assert result == ["coding", "figma"]+ assert "project" not in result+++def test_load_enabled_toolsets_honors_disabled_project_on_configured_fallback(+ monkeypatch,+):+ """#54433: configured/fallback path must not re-add disabled `project`."""+ monkeypatch.delenv("HERMES_TUI_TOOLSETS", raising=False)++ import agent.coding_context as cc+ import hermes_cli.tools_config as tools_config_mod++ monkeypatch.setattr(cc, "coding_selection", lambda **_: None)+ monkeypatch.setattr(+ tools_config_mod,+ "_get_platform_tools",+ lambda *_args, **_kwargs: {"memory", "web"},+ )+ monkeypatch.setattr(server, "_load_disabled_toolsets", lambda: ["project"])++ result = server._load_enabled_toolsets("tui")+ assert result == ["memory", "web"]+ assert "project" not in result+++def test_with_session_toolsets_keeps_desktop_ui_when_project_disabled(monkeypatch):+ """#54433: a disabled name is subtracted from the client-surface fold-in, but+ ``desktop_ui`` — the client's own control surface — survives the subtraction."""+ monkeypatch.setattr(server, "_load_disabled_toolsets", lambda: ["project"])++ assert server._with_session_toolsets(["memory"], "desktop") == [+ "memory",+ "desktop_ui",+ ]+ # Nothing disabled: the fold-in keeps both client-surface toolsets.+ monkeypatch.setattr(server, "_load_disabled_toolsets", lambda: None)+ assert server._with_session_toolsets(["memory"], "desktop") == [+ "memory",+ "desktop_ui",+ "project",+ ]++def test_load_enabled_toolsets_rejects_disabled_mcp_env(monkeypatch, capsys):monkeypatch.setenv("HERMES_TUI_TOOLSETS", "mcp-off")monkeypatch.setitem(diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex d49b1dc29c0..26f133a60b0 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -1870,12 +1870,22 @@ def _gui_surface_toolsets(platform: str) -> set[str]:def _with_session_toolsets(selection, platform: str | None) -> list[str]:"""*selection* plus what the session carries whatever its config says (the client surface'stoolsets 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."""+ profile.yaml under the session's home override), minus toolsets reserved for another role.++ The fold-in happens after ``_get_platform_tools`` already subtracted ``agent.disabled_toolsets``,+ so the same subtraction is applied to the fold-in itself — otherwise ``disabled_toolsets:+ [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 a+ model toolset."""from toolsets import profile_role_toolsetsgranted, 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))]+ fold_in = (surface | granted) - set(kept)+ disabled = set(_load_disabled_toolsets() or [])+ if disabled:+ fold_in -= disabled - {"desktop_ui"}+ return [*kept, *sorted(fold_in)]def _tui_notice(text: str) -> None: