Skip to content

The agent that grows with you

fix(gateway): /initiate-setup on a local session names the session's own surface and tools

Tekniumbb3ab78c1187
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py
index 4fce9b61e70..8c92c1a5480 100644
--- a/gateway/slash_commands.py
+++ b/gateway/slash_commands.py
@@ -1165,14 +1165,21 @@ class GatewaySlashCommandsMixin(
from model_tools import get_tool_definitions
def build() -> str:
+ from gateway.session_authorities import active_authority
+ from gateway.session_policy import policy_for_source
with self._profile_scope_for_source(source):
- enabled, disabled = self._resolve_turn_toolsets(
- _load_gateway_config(), source, _platform_config_key(source.platform))
+ config = _load_gateway_config()
+ enabled, disabled = self._resolve_turn_toolsets(config, source, _platform_config_key(source.platform))
+ # A local session runs its own surface (desktop/tui/cli) and toolsets, as its turns do.
+ policy = policy_for_source(self, source)
+ if policy is not None:
+ enabled = list(policy.current_toolsets(policy.config(active_authority(self), secrets=False)))
tools = get_tool_definitions(enabled_toolsets=enabled, disabled_toolsets=disabled, quiet_mode=True,
skip_tool_search_assembly=True)
return build_initiate_setup_prompt(
- source.platform.value, [tool["function"]["name"] for tool in tools],
- primary_profile(get_hermes_home()))
+ policy.platform if policy is not None else source.platform.value,
+ [tool["function"]["name"] for tool in tools], primary_profile(get_hermes_home()),
+ source.chat_id if policy is not None else None)
return await self._hm_rewrite_turn_to_prompt(
event, source, "initiate-setup", t("gateway.initiate_setup.ack"), build)
diff --git a/tests/gateway/test_session_authoring_commands.py b/tests/gateway/test_session_authoring_commands.py
index 4dec5ae1ed5..e80bf59b0d1 100644
--- a/tests/gateway/test_session_authoring_commands.py
+++ b/tests/gateway/test_session_authoring_commands.py
@@ -110,7 +110,9 @@ def test_local_session_authoring_commands_run_the_gateway_handler(tmp_path):
assert send('learn')['notice'], out['learn']
init = send('init')
assert str(work) in init['message'] and 'UPDATE the existing AGENTS.md' in init['message'], init
- assert send('initiate-setup')['notice'], out['initiate-setup']
+ setup = send('initiate-setup')
+ # The session's own surface (a `cli` launch runs the cli surface), not the LOCAL transport name.
+ assert setup['notice'] and '"surface": "cli"' in setup['message'], setup
assert send('moa compare')['message'] == 'compare', out['moa compare']
assert out['moa']['type'] == 'exec' and '/moa' in out['moa']['output'], out['moa']
assert out['blueprint']['type'] == 'exec' and out['blueprint']['output'], out['blueprint']