Commit Graph

14 Commits

Author SHA1 Message Date
Teknium
4b8c01f691 fix(multiplex): key tool-side and agent-side memos by profile home
Camofox VNC one-shot, computer-use aux-vision verdict, tirith binary path, MCP
discovery lock path, remote-backend probe text, learned image token costs,
auxiliary per-task semaphores and the custom-endpoint /models memo all held one
profile's config-derived value for the whole process. The skill-sync debounce
Timer ran with empty ContextVars, so a secondary's write pushed as the launch
profile (and cancelled its pending push).

Each memo is now keyed by hermes_home_key() (or credential fingerprint for the
per-key catalog) under an override; the timer is per home and runs its callback
inside the scheduling turn's copied context. Unscoped slots are unchanged.
2026-09-12 01:35:05 -07:00
Teknium
ceaf622c6d fix(mcp): same-named MCP servers with different credentials connect per profile; owner /reload-mcp keeps adopters' tools
Under gateway.multiplex_profiles every connection ledger in tools/mcp_tool.py
(_servers, _server_scope_keys/_server_tool_scopes, connecting/error/cooldown
maps, the circuit breaker, lazy schema-cache configs, trust metadata) was keyed
by the bare server NAME. The common per-tenant layout — each profile names its
server `github`/`notion` with its own token — gave only the first profile a
connection: the second profile's register_mcp_servers saw the name as "already
connected", refused to adopt it (different credentials, 4ddbcbd35e), and left
the profile silently tool-less with a healthy-looking `configured` status
(#106005 Bug 1/2, #91654). Siblings of the same bug: profile A's failing `x`
put profile B's healthy `x` into A's 10-minute connect cooldown and A's open
circuit breaker short-circuited B's calls; toolsets._resolve_toolset_memo was
not scope-keyed, so B resolved A's `mcp-<server>` tool names.

Keys are now the connection key from the new tools/mcp_tool_scope.py: the bare
name outside a multiplexer (single-profile processes are unchanged) and
(owner_scope, name) under one. Call-time lookups (_resolve_server_key) prefer
the calling scope's own connection, then a shared connection it adopted, so
identical-route profiles still share one subprocess. _select_new_servers,
the cooldown/breaker/trust maps, lazy registration and get_mcp_status all read
and write through the composite key; teardown resolves a task's key by
identity (the MCP loop has no profile context). The toolset memo key includes
registry.current_scope_key().

An owner's scoped /reload-mcp tore down its connection and, with it, every
adopting profile's tool overlay; nothing re-ran the adopters' discovery until
they reloaded. shutdown_mcp_servers(scope=) now records the orphaned adopters
and register_mcp_servers re-registers them under their own home + secret scope
once the owner's rediscovery pass completes.

Docs: multi-profile-gateways.md states the per-profile connection rule.

Fixes #106005
Fixes #91654
Co-authored-by: Bergmann89 <info@bergmann89.de>
Co-authored-by: Izzy-Gottz <srulynj@gmail.com>
2026-09-11 15:27:23 -07:00
Teknium
f4d4831e70 simplify(compat): tools/mcp_tool facade — drop 13 re-export blocks (127 names) + shutil re-import; siblings read sibling-defined names directly (_core kept for facade state) 2026-09-03 13:28:47 -07:00
Teknium
e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium
036907e328 refactor(tools): fold single-use locals into call sites in MCP stdio/loop/elicitation paths 2026-09-03 00:08:40 -07:00
Teknium
f7a4ccc081 refactor(tools): flatten identity-header/loop-stop control flow, inline SSE client factory 2026-09-03 00:01:18 -07:00
Teknium
a8f0249a31 refactor(tools): inline pgid capture, merge tool-loop guard branches, drop single-use locals 2026-09-02 23:47:41 -07:00
Teknium
672cd01c7c refactor(tools): fold legacy HTTP transport into streamable path, tighten MCP classifier/sampling bodies 2026-09-02 23:35:14 -07:00
Teknium
6a7d04e89d refactor(tools): collapse defensive layers and compact prose in MCP transport/loop/sampling/errors 2026-09-02 22:53:26 -07:00
Teknium
1ad360b3aa refactor(tools): compact MCP transport/loop/sampling/errors helpers, defensive collapse 2026-09-02 22:16:12 -07:00
Teknium
e59090acee refactor(mcp): flatten _LockCookie.release nested try ladders (same best-effort semantics) 2026-09-02 16:59:27 -07:00
Teknium
a0f15d1f2a refactor(mcp): _running_loop helper for the loop-up check 2026-09-02 16:58:35 -07:00
Teknium
a09512c3ad refactor(mcp): move loop start/stop + reconnect signalling into mcp_tool_loop.py (writes via origin module) 2026-09-02 16:14:37 -07:00
Teknium
d4602539d8 refactor(mcp): move discovery lock + loop scheduling into mcp_tool_loop.py 2026-09-02 15:52:38 -07:00