acpmux: a cmux-tui daemon's sub-session MCP server runs under acp (cloud VMs)

Merged
TE
1mo ago
+344-5

Summary

On a cloud VM, agents never got the cmux-subsessions tools (start_session and the rest). The VM's acpmux daemon runs from cmux-tui (started as acpmux, a link, and Linux's current_exe resolves the link), so it wrote the server command as <cmux-tui> subsession-mcp. cmux-tui only runs acpmux when argv0 is acpmux or the first word is acp (main.rs argv0 check, then run_main's acp route), so that command fell through to the cmux CLI and the MCP server never started.

The daemon already knows its prefix: daemon::daemon_prefix() is acp when it runs inside cmux-tui, and HostLauncher::current starts agent hosts with it. agent_tools::resolve now puts the same prefix before the command word of every server that is this acpmux binary: subsession-mcp, secret-mcp, offer-mcp and the helper v2 bridge cua-mcp. A standalone acpmux (the app's bundled copy) has an empty prefix and keeps the bare word. The per-workspace display filter now finds the cua-mcp bridge by its word anywhere in its args instead of only as the first one.

Not changed: router serve (daemon/router_owner/fifo.rs) and the hand's daemon start (hand/daemon.rs) also start current_exe without the prefix. They aren't on this path; noting them for a follow-up.

Testing

  • cmux-tui/crates/cmux-tui/tests/acp_subsession_mcp.rs (new): starts a real daemon from the cmux-tui test binary, both as cmux-tui acp daemon start and through a link named acpmux, starts a chat with the stand-in agent, reads the mcpServers the agent got, runs the cmux-subsessions command with its env, and checks initialize, that tools/list has start_session, and that list_sessions reaches the daemon. On Linux it also asserts the link resolves to cmux-tui (the VM case).
  • acpmux unit test own_servers_run_under_the_daemon_prefix: with an empty prefix the four servers keep their bare word; with acp each is acp <word>; per-workspace displays still drop the bridge.

Ran on huge-blue (Linux x86_64, Rust 1.95.0), cargo test --locked:

Command5bbc608 (test only)334de4a (fix)
-p cmux-tui --test acp_subsession_mcp0 passed, 2 failed2 passed
-p acpmux --lib agent_tools6 passed (incl. own_servers_run_under_the_daemon_prefix)
-p acpmux --test agent_tools --test cua_v2_stale_endpoint --test agent_displays3 passed

The red failure is the bug itself. Through the acpmux link the server came out as {"command": ".../debug/cmux-tui", "args": ["subsession-mcp"]}, so Linux resolved the link to cmux-tui as expected, and both cases failed with left: ["subsession-mcp"], right: ["acp", "subsession-mcp"]. With the fix, both cases start the server, tools/list has start_session, and list_sessions answers.

Running the built binary directly shows what an agent saw before:

$ echo '<initialize>' | ACPMUX_SESSION_ID=x cmux-tui subsession-mcp
cmux: unknown resource scope "subsession-mcp".      (exit 2)
$ echo '<initialize>' | ACPMUX_SESSION_ID=x cmux-tui acp subsession-mcp
{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"tools":{}},"instructions":"Sub-sessions are ...

Observed / Not run

  • Observed: the runs above. The new test runs the daemon from a cmux-tui binary through an acpmux link on Linux, which is the VM's setup. It doesn't use a real VM.
  • Not run: clippy and the full workspace suite (CI runs them), macOS (the standalone acpmux path keeps an empty prefix, which the unit test covers), and a live cloud VM.

Changelog

Fixed: Agents on a cloud machine can start and manage sub-sessions again (the cmux-subsessions tools start).

🤖 Generated with Claude Code

Agent session: cosmic-gray