The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): keep Kanban workers and tool sessions on the profile's toolsets
kshitijk4poor7656546eaed4
diff --git a/gateway/session_kanban.py b/gateway/session_kanban.pyindex 826883f9a89..a8b251be579 100644--- a/gateway/session_kanban.py+++ b/gateway/session_kanban.py@@ -53,7 +53,8 @@ def build_kanban_policy(connection, params, config):if value:params_policy[name] = valueprivate = {}- policy = build_policy(params_policy, config, private_secrets=private)+ # A worker's task worktree is no client pick of the coding posture: it keeps the profile's toolsets.+ policy = build_policy(params_policy, config, private_secrets=private, workspace_posture=False)if policy.model is None:from gateway.run import _resolve_gateway_modelpolicy = replace(policy, model=_resolve_gateway_model(policy.config()))diff --git a/gateway/session_policy.py b/gateway/session_policy.pyindex d43b4a70ded..eee7ac9e8a7 100644--- a/gateway/session_policy.py+++ b/gateway/session_policy.py@@ -258,7 +258,7 @@ def present_sections(config):return config-def build_policy(params, config, *, private_secrets=None, profile_terminal=True):+def build_policy(params, config, *, private_secrets=None, profile_terminal=True, workspace_posture=True):from agent.runtime_cwd import resolve_agent_cwdfrom tools.terminal_scope import build_profile_terminal_scope, default_terminal_scopefrom hermes_constants import get_hermes_home@@ -296,8 +296,9 @@ def build_policy(params, config, *, private_secrets=None, profile_terminal=True)config.setdefault('model', {})['selection_profile'] = list(profile_target(config))_apply_launch_overrides(params, config)# Only a folder the client named is a workspace: the daemon's own directory (the fallback above, used by- # hosted rooms) must not switch a session into the coding posture.- named = 'cwd' in params and 'toolsets' not in params+ # hosted rooms) must not switch a session into the coding posture, nor may a caller that opts out.+ # ``tool`` is a third-party integration, not a person's workspace.+ named = workspace_posture and source != 'tool' and 'cwd' in params and 'toolsets' not in paramsposture = _coding_posture(config, source, cwd) if named else Noneenabled = _resolve_toolsets(params, config, source, safe_mode, posture)terminal = build_profile_terminal_scope(get_hermes_home()) if profile_terminal else default_terminal_scope()diff --git a/tests/gateway/test_session_kanban.py b/tests/gateway/test_session_kanban.pyindex bce67f614b8..a3b3f8e5969 100644--- a/tests/gateway/test_session_kanban.py+++ b/tests/gateway/test_session_kanban.py@@ -19,6 +19,7 @@ def test_claim_freezes_task_policy_and_rejects_forgery(tmp_path, monkeypatch):monkeypatch.setattr('hermes_cli.profiles.resolve_profile_env', lambda name: str(tmp_path) if name == 'default' else str(tmp_path / name))workspace = tmp_path / 'workspace'workspace.mkdir()+ (workspace / 'pyproject.toml').write_text('[project]\nname = "task"\n') # a code worktreefrom contextlib import closingkb.create_board('owned') # explicit creation; connect() never creates a board (#43243)with closing(connect(board='owned')) as conn:@@ -31,7 +32,8 @@ def test_claim_freezes_task_policy_and_rejects_forgery(tmp_path, monkeypatch):connection = SimpleNamespace(authority=SimpleNamespace(profile_id=str(tmp_path)), actor=actor, native_owner=True)params = dict(board='owned', task_id=task.id, run_id=task.current_run_id, claim_lock=task.claim_lock)from gateway.session_kanban import build_kanban_policy- config = {'model': {'default': 'loop-model', 'provider': 'custom'}, 'platform_toolsets': {'cli': ['terminal', 'file']}}+ config = {'model': {'default': 'loop-model', 'provider': 'custom'}, 'platform_toolsets': {'cli': ['terminal', 'file']},+ 'agent': {'coding_context': 'focus'}} # the worktree must not collapse a worker into the coding posturepolicy, _secrets = build_kanban_policy(connection, params, config)context = json.loads(policy.kanban_json)assert policy.source == 'kanban' and policy.cwd == str(workspace)diff --git a/tests/gateway/test_session_policy_coding_posture.py b/tests/gateway/test_session_policy_coding_posture.pyindex a5c9be0ffb4..b1cc5eb9572 100644--- a/tests/gateway/test_session_policy_coding_posture.py+++ b/tests/gateway/test_session_policy_coding_posture.py@@ -86,3 +86,15 @@ def test_a_profile_default_listing_coding_is_not_replayed_as_a_workspace(tmp_patassert not policy.coding_posture and 'web' in policy.toolsetsassert policy.current_toolsets(config) == policy.toolsets+[email protected]('params', [{'source': 'tool'}, {'source': 'cli', 'toolsets': ['terminal']}])+def test_tool_sources_and_picks_keep_their_toolsets_in_a_workspace(project, params):+ from gateway.session_policy import build_policy+ policy = build_policy({**params, 'cwd': str(project)}, FOCUS)+ assert not policy.coding_posture and policy.toolsets == ('terminal',)+++def test_a_caller_can_opt_out_of_the_workspace_posture(project):+ from gateway.session_policy import build_policy+ policy = build_policy({'source': 'cli', 'cwd': str(project)}, FOCUS, workspace_posture=False)+ assert policy.toolsets == ('terminal',)