new RFD: Create websocket-transport.md #476
Open
+281
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Elevator pitch
The current Agent Communication Protocol (ACP) SDK exclusively uses stdio for transport, requiring a separate forwarding process when the agent backend operates over WebSocket. This proposal introduces native WebSocket transport support directly into the ACP SDK, eliminating the need for intermediate stdio-to-WebSocket bridging processes and enabling more flexible, resource-efficient deployment architectures.
Status quo
Currently, the ACP SDK (
@agentclientprotocol/sdk) is designed around stdio-based communication. When an agent backend is implemented as a web service (e.g., using Express.js with WebSocket endpoints), the following architecture is required:ws://localhost:8931/ws/acp).Example from fount framework:
Problems with this approach:
Current Workarounds:
fount_ide_agent.mjs).What we propose to do about it
We propose extending the ACP SDK to natively support WebSocket as a transport layer, alongside the existing stdio transport.
Key Design Principles:
Proposed Client API:
Proposed Server API:
Shiny future
In the shiny future, ACP agents will be truly transport-agnostic:
Implementation details and plan
Phase 1: Core Transport Abstraction (v1.0)
Goal: Separate protocol logic from transport implementation.
Refactor Existing Code:
StdioTransportclass.AgentClientConnectionandAgentSideConnectionaccept aTransportparameter.Backward Compatibility:
StdioTransport.Phase 2: WebSocket Transport (v1.1)
Goal: Implement WebSocket transport with feature parity to stdio.
Client-Side:
WebSocketTransportclass.Server-Side:
webSocketStream(ws)helper for common WebSocket libraries (ws,uWebSockets.js).Testing:
ws, Deno native).Phase 3: Documentation & Ecosystem (v1.2)
Reference Implementations:
Migration Guide:
Best Practices:
Phase 4 (Optional): Additional Transports (v2.0)
Frequently asked questions
What alternative approaches did you consider, and why did you settle on this one?
WebSocket was chosen because:
How does this affect existing stdio-based agents?
Zero impact. The current stdio-based API remains the default:
The WebSocket transport is opt-in, activated only when explicitly configured.
What about authentication and security?
ACP over WebSocket supports multiple authentication strategies:
new WebSocket(url, ['api-key-token'])).Authorizationheader during WebSocket handshake.ws://host/acp?token=...).The SDK will document best practices for each scenario. TLS (wss://) should be used in production to encrypt all communication.
Won't this make the SDK more complex?
The complexity is encapsulated within transport implementations. The core protocol logic (
initialize,newSession,prompt) remains unchanged. Developers using the SDK only see:For advanced use cases, the transport abstraction provides clear extension points without coupling to SDK internals.
How does this compare to Language Server Protocol (LSP)?
LSP faced a similar challenge and now supports:
ACP should follow LSP's proven approach: protocol-transport independence enables the same agent implementation to work across desktop IDEs, web IDEs, mobile apps, and CLI tools.
What about connection lifecycle and error handling?
The SDK will handle common WebSocket scenarios:
disconnectevents; optionally auto-reconnect with exponential backoff.Reconnection behavior will be configurable:
Can I use this with serverless platforms?
Yes, with caveats:
The SDK will document these platform-specific patterns.