The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): the default profile's live MCP servers stay connected across the in-place switch
Tekniumc5708b1003b5
diff --git a/gateway/run_profile_reconcile.py b/gateway/run_profile_reconcile.pyindex 6eacf64dc6f..7af86f636d9 100644--- a/gateway/run_profile_reconcile.py+++ b/gateway/run_profile_reconcile.py@@ -365,8 +365,11 @@ class GatewayProfileReconcileMixin:# that detail) instead of "only one profile exists".record_multiplex_decision(MultiplexDecision(False, "guard", blocker))return False+ from hermes_constants import hermes_home_key+ from tools.mcp_tool_scope import rekey_unscoped_connectionsfrom tui_gateway.launch_profile_policy import activate_multi_profile_hostingactivate_multi_profile_hosting()+ rekey_unscoped_connections(hermes_home_key(launch))self.config.multiplex_profiles = Trueself.config._runtime_profile_homes = (("default", launch),)registry = getattr(self, "session_authorities", None)diff --git a/tools/mcp_tool_scope.py b/tools/mcp_tool_scope.pyindex 6276c33ebc2..c615c173ff1 100644--- a/tools/mcp_tool_scope.py+++ b/tools/mcp_tool_scope.py@@ -61,3 +61,29 @@ def _resolve_server_key(name: str, scope: Optional[str] = None, *, current: boolif scope in scopes and _key_name(key) == name and key in _core._servers:return keyreturn own+++# Ledgers keyed by connection key (``tools.mcp_tool``); ``_server_scope_keys`` keeps its owner value.+_KEYED_LEDGERS = (+ "_servers", "_server_scope_keys", "_server_tool_scopes", "_server_connect_errors",+ "_lazy_server_configs", "_lazy_server_fingerprints", "_lazy_server_tool_names",+ "_server_connect_retry_after", "_server_connect_failures", "_server_error_counts",+ "_server_breaker_opened_at", "_server_errors_all_application", "_server_trust_levels",+ "_tool_read_only_hints")+_KEYED_SETS = ("_server_connecting", "_parallel_safe_servers")+++def rekey_unscoped_connections(scope: str) -> None:+ """Move every bare-name connection under ``(scope, name)``. A single-profile process keys its+ connections by bare name; once it starts multiplexing, the launch profile's lookups resolve+ ``(launch scope, name)``, so without this its live servers read as disconnected until a restart."""+ with _core._lock:+ for attr in _KEYED_LEDGERS:+ ledger = getattr(_core, attr)+ for key in [k for k in ledger if isinstance(k, str)]:+ ledger[(scope, key)] = ledger.pop(key)+ for attr in _KEYED_SETS:+ keys = getattr(_core, attr)+ bare = {k for k in keys if isinstance(k, str)}+ keys.difference_update(bare)+ keys.update((scope, k) for k in bare)