Skip to content

fix(remote): send integer ACP protocolVersion on the /acp initialize - #46

Merged
brettchien merged 1 commit into
mainfrom
fix/acp-initialize-protocol-version-u16
Aug 14, 2026
Merged

brettchien merged 1 commit into
mainfrom
fix/acp-initialize-protocol-version-u16

Conversation

@brettchien

Copy link
Copy Markdown
Contributor

Follow-up to #45. With the handshake fixed, the /acp connection now gets past the WS upgrade but stalls at initialize.

Root cause

Studio's outer ACP initialize sends "protocolVersion": "2024-11-05" — an MCP-style date string. ACP versions its wire protocol with a u16 integer, and the gateway deserializes the field as u16. Verified live on the same connection:

"protocolVersion": "2024-11-05"  -> {"error":{"code":-32602,
    "message":"...invalid type: string \"2024-11-05\", expected u16"}}
"protocolVersion": 1             -> {"result":{"agentCapabilities":…}}   ✅

(ACP ≠ MCP: MCP uses a date-string protocol version; ACP uses an integer.)

Fix

  • The outer /acp handshake sends acp::ACP_PROTOCOL_VERSION (u16 = 1), a new constant in acp-tunnel.
  • The tunnelled inner MCP initialize (relayed to the oab-mcp sidecar in handle_inner) still uses the MCP date string — that one is MCP and is correct; a comment marks the distinction so they aren't accidentally unified.
  • Regression test asserts ACP_PROTOCOL_VERSION serializes to a JSON number, not a string.

Verification

  • Live: with protocolVersion: 1, initialize -> session/new completes and returns a sessionId against wss://orca-acp.brettchien.cc/acp (server side confirmed by Jellyfish).
  • cargo test -p acp-tunnel — 20 passed (incl. new acp_protocol_version_is_an_integer_not_an_mcp_date_string).
  • studio-desktop compilation left to CI (desktop.yml).

Together with #45 this makes the end-to-end remote reverse-MCP connection succeed.

🤖 Generated with Claude Code

Even with the #45 handshake fix, the remote `/acp` connection still fails
at `initialize`: Studio sends `"protocolVersion": "2024-11-05"` (an
MCP-style date string), but ACP versions the wire protocol with a **u16
integer**. The gateway deserializes the field as `u16`, so the string is
rejected:

    "protocolVersion": "2024-11-05"  -> error -32602
        "invalid type: string \"2024-11-05\", expected u16"
    "protocolVersion": 1             -> result { agentCapabilities … }  (verified live)

Fix: the outer `/acp` handshake now sends `acp::ACP_PROTOCOL_VERSION`
(u16 = 1). The *tunnelled* inner MCP `initialize` (relayed to the
`oab-mcp` sidecar in `handle_inner`) correctly keeps the MCP date string —
that one is MCP, not ACP, and is left untouched. A comment marks the
distinction so the two are not "unified" by mistake, and a regression
test asserts `ACP_PROTOCOL_VERSION` serializes to a JSON number.

Verified live against wss://orca-acp.brettchien.cc/acp: with pv=1 the
full initialize -> session/new completes and returns a sessionId
(server side confirmed by Jellyfish). acp-tunnel unit tests pass;
studio-desktop compilation left to CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@brettchien
brettchien merged commit 0b0f0bc into main Aug 14, 2026
2 checks passed
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