Skip to content

feat: add session-scoped ACP MCP support with Bub instance tools - #69

Draft
lodyai[bot] wants to merge 4 commits into
mainfrom
fix/bub-instance-tools
Draft

lodyai[bot] wants to merge 4 commits into
mainfrom
fix/bub-instance-tools

Conversation

@lodyai

@lodyai lodyai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

ACP previously ignored the mcpServers supplied by clients. Bub's new instance-tool API also snapshots REGISTRY when constructing an Agent, so late MCP discovery and ACP's temporary global replacements could miss existing agents or affect newly created ones.

This change connects client-supplied MCP servers for each ACP session and binds all dynamic tools to the actual runtime Agent. It implements the ACP session MCP contract on Bub's instance-tool API.

  • Advertise HTTP/SSE MCP capabilities and support stdio, Streamable HTTP, and SSE through a direct bub-mcp>=0.3.0 dependency. Preserve arguments, environment variables, headers, and the session working directory.
  • Give each ACP connection a separate Agent for each session. Bind session tools after configured MCP tools, without modifying global REGISTRY; static @tool registration remains supported.
  • Replace the server list on session/load and session/resume; an omitted or empty list clears it. Wait for discovery and active prompts before replacing existing connections. Failed setup closes newly opened clients and preserves previous connections.
  • Share session connections across HTTP/WebSocket agents, cancel active turns on session close, and clean up pending discovery and clients on shutdown. Complete ASGI cleanup before reporting shutdown completion; call FastMCP close() to terminate keep-alive stdio transports. Keep MCP configuration in memory only.
  • Add MCPChannel.connect(), preserve original tool bindings across repeated overrides, and close partially connected clients when discovery is cancelled.
  • Adapt Agent Plugins, Extism, and OTel to the new runtime interfaces; bump bub-mcp to 0.3.0 and lock Bub to e4578a44354c773447cef854892742af9eb7cc13 (feat: support embedding Agent with instance tools, skills, and storage bub#311).

Validation:

  • uv run --locked pytest packages -q: 601 passed, 3 skipped.
  • BUB_RUN_ISOLATED_ABLATION=1 uv run --locked pytest packages/bub-agent-plugins/tests/test_isolated_ablation.py -q: 1 passed (one of the above skips).
  • Remaining two Extism example skips require unavailable compilation toolchains.
  • Ruff checks, formatting checks for changed Python files, and git diff --check passed.

Regression coverage includes real stdio MCP execution and PID-verified child termination, model-visible session isolation, late discovery, configured/session tool collisions, reload/clear behavior, failed setup, cancellation, HTTP resource sharing, and cleanup before shutdown completion. Resolving Bub's default agent still uses BuiltinImpl._get_agent() because upstream does not expose a public default-agent getter.

The ACP MCP ablation report records seven groups with three isolated repetitions each, using real stdio servers and a deterministic model schema probe. The full implementation passed 12/12 calls and 18/18 isolation observations, with zero retained children. Global-registration and shared-Agent variants reproduced availability/isolation failures. The old __aexit__() cleanup retained all 9 children despite reporting zero connected clients; close() fixes that failure. Raw observations, the pre-fix diagnostic, and a reproduction command are checked in. This is an integration ablation, not a model quality benchmark.

@lodyai lodyai Bot changed the title fix: adapt plugins to Bub instance-scoped tools feat: add session-scoped ACP MCP support with Bub instance tools Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant