The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(acp): an editor MCP server's tools stay frozen when re-registered outside its session
Tekniumde53503a3d8e
diff --git a/tests/acp_adapter/test_session_mcp_frozen.py b/tests/acp_adapter/test_session_mcp_frozen.pyindex 4cfa1f915cc..21d0c7242a5 100644--- a/tests/acp_adapter/test_session_mcp_frozen.py+++ b/tests/acp_adapter/test_session_mcp_frozen.py@@ -38,6 +38,40 @@ def test_editor_manifest_stays_frozen_across_live_refresh(server_spec, tmp_path)pass+def test_editor_freeze_follows_the_connection_owner_not_the_callers_scope(server_spec, tmp_path):+ """Under a multiplexer the ledger key is ``(editor scope, name)``. A re-registration that runs+ outside the session's context still publishes into the editor scope the key names, so the+ freeze must be judged by that same owner, never by the bare name in the caller's scope."""+ import threading+ from agent.secret_scope import reset_multiplex_context, set_multiplex_context+ from tools.registry import registry+ from tools.mcp_tool import _servers+ from tools.mcp_tool_registration import _register_server_tools+ authority = owner()+ p = policy(authority, 'owner-scope', server_spec, tmp_path)+ with policy_scope(p, authority=authority):+ names = [n for n in registry.get_all_tool_names() if n.startswith('mcp__')]+ schemas = {n: registry.get_schema(n) for n in names}+ server = next(s for key, s in _servers.items() if key[-1].startswith('editor_'))+ server._tools[0].description = 'changed after first discovery'+ outcome = []++ def foreign_caller():+ token = set_multiplex_context(True)+ try:+ _register_server_tools(server.name, server, server._config)+ outcome.append('registered')+ except RuntimeStoreError as exc:+ outcome.append(exc.reason)+ finally:+ reset_multiplex_context(token)+ thread = threading.Thread(target=foreign_caller)+ thread.start()+ thread.join(20)+ assert outcome == ['acp_mcp_schema_changed']+ assert schemas == {n: registry.get_schema(n) for n in names}++def test_silent_editor_discovery_is_bounded_and_reaps_only_itself(server_spec, tmp_path):from tools.registry import registryauthority = owner()diff --git a/tools/mcp_tool_registration.py b/tools/mcp_tool_registration.pyindex a7f9581e540..a400cdffc53 100644--- a/tools/mcp_tool_registration.py+++ b/tools/mcp_tool_registration.py@@ -406,7 +406,9 @@ def _register_server_tools(name: str, server: "MCPServerTask", config: dict) ->_record_tool_trust_metadata(name, config, server._tools, key)candidates = _tool_candidates(name, server._tools, should_register, server.tool_timeout)candidates += _utility_candidates(name, _select_utility_schemas(name, server, config), server.tool_timeout)- if (_core._server_registry_scope(name) or '').startswith('editor-session:'):+ # Judged by the connection's owner scope (the ``(scope, name)`` key the registration below+ # publishes into), never by the bare name resolved in the caller's context.+ if (_core._server_registry_scope(key) or '').startswith('editor-session:'):import jsonfrom hermes_state_runtime import RuntimeStoreErrormanifest = json.dumps({c.registry_name: c.schema for c in candidates}, sort_keys=True)