Skip to content

Add app-server transport layer with websocket support#10693

Open
maxj-oai wants to merge 2 commits intomainfrom
maxj/listen
Open

Add app-server transport layer with websocket support#10693
maxj-oai wants to merge 2 commits intomainfrom
maxj/listen

Conversation

@maxj-oai
Copy link
Contributor

@maxj-oai maxj-oai commented Feb 5, 2026

  • Adds --listen to codex app-server with two listen modes:
    • stdio:// (default, existing behavior)
    • ws://IP:PORT (new websocket transport)
  • Refactors message routing to be connection-aware:
    • Tracks per-connection session state (initialize/experimental capability)
    • Routes responses/errors to the originating connection
    • Broadcasts server notifications/requests to initialized connections
  • Updates initialization semantics to be per connection (not process-global), and updates app-server docs accordingly.
  • Adds websocket accept/read/write handling (JSON-RPC per text frame, ping/pong handling, connection lifecycle events).

Testing

  • Unit tests for transport URL parsing and targeted response/error routing.
  • New websocket integration test validating:
    • per-connection initialization requirements
    • no cross-connection response leakage
    • same request IDs on different connections route independently.

@maxj-oai maxj-oai requested a review from owenlin0 February 5, 2026 00:57
@maxj-oai maxj-oai changed the title Add app-server transport layer with websocket listen URL support Add app-server transport layer with websocket support Feb 5, 2026
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cd76800f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 80 to +86
let outgoing_message =
OutgoingMessage::Request(request.request_with_id(outgoing_message_id.clone()));
if let Err(err) = self.sender.send(outgoing_message).await {
if let Err(err) = self
.sender
.send(OutgoingEnvelope::Broadcast {
message: outgoing_message,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route server requests to the originating connection

With websocket support, send_request_with_id now broadcasts server-initiated requests (approvals, user input, auth refresh) to all initialized connections, and the first response wins while other responses are dropped. This means a second client can receive and approve/deny a command or tool call that was triggered by a different client, causing cross-connection data leakage and incorrect approvals. These requests should be targeted to the connection that initiated the action (e.g., carry a ConnectionId through the request flow) instead of broadcasting.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentional - all connected clients are eligible to receive / reply to requests from server->client

Copy link
Contributor

@JaviSoto JaviSoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super familiar with the code, so someone else should take a look. It looks good to me overall. I particularly like the --listen stdio://|ws://IP:PORT API! 🙏

Lazy question: are the changes to the app-server messages you made backwards compatible? Just wanna make sure that existing clients don't break

@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Feb 5, 2026
@maxj-oai
Copy link
Contributor Author

maxj-oai commented Feb 5, 2026

@JaviSoto this doesn't change any of the app-server messages yet - just allows multiple connections and broadcast + response routing semantics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants