Skip to content

Add capi.disableWebSocketResponses session option#1711

Open
dereklegenzoff wants to merge 1 commit into
mainfrom
dereklegenzoff/capi-disable-websocket-responses
Open

Add capi.disableWebSocketResponses session option#1711
dereklegenzoff wants to merge 1 commit into
mainfrom
dereklegenzoff/capi-disable-websocket-responses

Conversation

@dereklegenzoff

Copy link
Copy Markdown

Why

WebSocket transport is now the default for the CAPI (Copilot API) Responses API whenever a model advertises the ws:/responses endpoint. That breaks for users behind proxies or in network environments where WebSockets fail, so they need a way to opt out and fall back to the HTTP Responses transport.

This is the SDK-side follow-up to runtime PR github/copilot-agent-runtime#10551 ("CLI: Graduate WebSocket Responses flag, add SDK opt-out"), explicitly requested in review by @SteveSandersonMS, who noted that session create/resume calls are hand-written and not driven by any runtime-side Zod schema, so the SDK needs to supply this option itself.

What

Adds the nested session option capi: { disableWebSocketResponses?: boolean } to session create and resume across all six SDK languages. When true, the session uses the HTTP Responses transport instead of WebSockets. It is equivalent to setting the COPILOT_CLI_DISABLE_WEBSOCKET_RESPONSES environment variable.

The option is scoped under a capi namespace (not a top-level option) by design: a single session can host multiple providers (CAPI + BYOK), so transport choice is conceptually provider-level.

Wire shape: session.create / session.resume params gain capi: { disableWebSocketResponses: true }, omitted entirely when unset.

Approach

The field is a hand-written pass-through that mirrors the existing provider (BYOK) nested option exactly, wired into both the create and resume RPC params. Session create/resume options are hand-written in every language (not codegen-driven), so this ships independently of the runtime release.

Per-language summary (each mirrors the existing provider option):

  • Node.js (reference): CapiSessionOptions interface + SessionConfigBase.capi, wired in create + resume, re-exported, with a test.
  • Python: CapiSessionOptions TypedDict + camelCase wire helper, capi kwarg on create/resume, exported.
  • Go: CapiSessionOptions struct + Capi on configs and wire requests, set in create + resume builders.
  • Java: new CapiSessionOptions (fluent setters + Jackson) + field on both configs/requests, wired in SessionRequestBuilder for create + resume.
  • .NET: CapiSessionOptions class + Capi on SessionConfigBase, copy-constructor, positional in both request records, registered in the serializer context.
  • Rust: CapiSessionOptions (#[non_exhaustive] + builders) + capi on configs and wire types, converted in into_wire.

Compatibility

The CLI treats this field as a harmless no-op until a runtime that includes github/copilot-agent-runtime#10551 is installed, so the SDK change is safe to land ahead of the runtime release.

Deferred follow-ups (by design)

  1. No @github/copilot dependency bump / codegen re-run yet. The current schema does not contain a generated CapiSessionOptions; once #10551 is published, an optional bump + codegen re-run can produce a generated type. The hand-written pass-through is sufficient in the meantime.
  2. No session.options.update (live update) wiring. This PR covers session create and resume only.

Testing

Ran the per-language unit suites for each change (Node.js, Python, Go, Java, Rust passing locally; .NET reviewed against existing serialization/clone test patterns). e2e suites that require the replay-proxy harness were out of scope for local verification.

Refs github/copilot-agent-runtime#10551

Add the capi.disableWebSocketResponses opt-out to session create/resume
across all six SDK languages, so consumers in proxy/WebSocket-blocked
environments can fall back to the HTTP Responses transport for the CAPI
Responses API.

SDK-side follow-up to github/copilot-agent-runtime#10551, which makes
WebSocket transport the default for CAPI and adds this opt-out. The field
is a hand-written pass-through mirroring the existing provider (BYOK)
nested option, wired into session.create and session.resume.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 17, 2026 19:26
@dereklegenzoff dereklegenzoff requested a review from a team as a code owner June 17, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a provider-scoped session option capi.disableWebSocketResponses to the session create and resume request shapes across all SDK languages, allowing users to opt out of the default WebSocket-based CAPI Responses transport and fall back to HTTP (useful in proxy-restricted environments).

Changes:

  • Introduces CapiSessionOptions (language-idiomatic) and threads it through session create/resume configs and wire payloads.
  • Ensures the option is omitted from the wire payload when unset (via optional fields / non-null serialization).
  • Adds/extends unit tests to verify forwarding + serialization behavior.
Show a summary per file
File Description
rust/src/wire.rs Adds optional capi field to Rust create/resume wire payload structs.
rust/src/types.rs Introduces CapiSessionOptions, adds capi to SessionConfig/ResumeSessionConfig, and adds serialization tests.
python/test_client.py Adds unit test ensuring capi options are forwarded on create/resume.
python/copilot/client.py Adds CapiSessionOptions TypedDict, wire conversion helper, and capi kwarg wiring for create/resume.
python/copilot/init.py Re-exports CapiSessionOptions from the package surface.
nodejs/test/client.test.ts Adds test verifying capi forwarding on session.create and session.resume.
nodejs/src/types.ts Adds CapiSessionOptions and capi?: to shared session config base types.
nodejs/src/index.ts Re-exports CapiSessionOptions in public entrypoint.
nodejs/src/client.ts Forwards config.capi into session.create / session.resume request params.
java/src/test/java/com/github/copilot/JsonIncludeNonNullTest.java Adds JSON non-null include annotation coverage for CapiSessionOptions.
java/src/test/java/com/github/copilot/CapiSessionOptionsTest.java New test suite covering Java option defaults, fluent setters, and request inclusion/omission.
java/src/main/java/com/github/copilot/SessionRequestBuilder.java Wires config.getCapi() into create/resume request builders.
java/src/main/java/com/github/copilot/rpc/SessionConfig.java Adds capi field + getter/setter + clone propagation.
java/src/main/java/com/github/copilot/rpc/ResumeSessionConfig.java Adds capi field + getter/setter + clone propagation.
java/src/main/java/com/github/copilot/rpc/CreateSessionRequest.java Adds capi JSON property + accessor methods on the wire request type.
java/src/main/java/com/github/copilot/rpc/ResumeSessionRequest.java Adds capi JSON property + accessor methods on the wire request type.
java/src/main/java/com/github/copilot/rpc/CapiSessionOptions.java New Java RPC type with Jackson annotations and fluent setter for disableWebSocketResponses.
go/types.go Adds CapiSessionOptions, threads it through session configs and create/resume request structs.
go/client.go Forwards config.Capi into create/resume RPC request builders.
go/client_test.go Adds tests ensuring capi.disableWebSocketResponses is serialized/forwarded and omitted when unset.
dotnet/test/Unit/SerializationTests.cs Adds serialization coverage for CapiSessionOptions and create/resume request inclusion/omission.
dotnet/test/Unit/CloneTests.cs Extends clone coverage to ensure Capi is copied consistently.
dotnet/src/Types.cs Introduces CapiSessionOptions, adds it to SessionConfigBase, and registers it for source-gen serialization.
dotnet/src/Client.cs Threads config.Capi through internal create/resume request records and serializer context.

Copilot's findings

  • Files reviewed: 24/24 changed files
  • Comments generated: 0

@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds capi.disableWebSocketResponses to all six SDK implementations. Cross-language consistency looks excellent.

Consistency checklist

Concern Result
Feature added to all 6 SDKs ✅ Node.js, Python, Go, .NET, Java, Rust
Both create and resume wired ✅ All SDKs
Wire field name ("disableWebSocketResponses") ✅ Uniform across all SDKs
capi field omitted when unset ✅ All SDKs (omitempty / NON_NULL / null guards)
Language-idiomatic naming ✅ See table below
Type exported/public in each SDK ✅ All SDKs
capi positioned after provider in configs ✅ Consistent ordering across all SDKs

Naming conventions (idiomatic per language)

SDK Config field Type field Wire
Node.js capi?: CapiSessionOptions disableWebSocketResponses?: boolean disableWebSocketResponses
Python capi: CapiSessionOptions | None disable_web_socket_responses: bool (TypedDict) converted → disableWebSocketResponses
Go Capi *CapiSessionOptions DisableWebSocketResponses *bool "capi,omitempty"
.NET Capi CapiSessionOptions? DisableWebSocketResponses bool? [JsonPropertyName]
Java setCapi(CapiSessionOptions) setDisableWebSocketResponses(Boolean) @JsonProperty("disableWebSocketResponses")
Rust capi: Option<CapiSessionOptions> disable_web_socket_responses: Option<bool> #[serde(rename_all = "camelCase")]

All naming follows each language's established conventions and mirrors the existing provider / ProviderConfig pattern exactly — Python's TypedDict for CapiSessionOptions is consistent with ProviderConfig already being a TypedDict in that SDK.

No cross-SDK consistency issues found.

Generated by SDK Consistency Review Agent for issue #1711 · sonnet46 1.5M ·

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.

2 participants