Add capi.enableWebSocketResponses and provider.transport session options#1711
Conversation
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>
There was a problem hiding this comment.
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
This comment has been minimized.
This comment has been minimized.
Add the BYOK provider `transport` field ("http" | "websockets", default
"http") to the hand-written ProviderConfig across all six SDK languages,
so BYOK OpenAI-compatible providers can opt into delivering Responses API
requests over a persistent WebSocket connection instead of HTTP.
SDK-side follow-up to github/copilot-agent-runtime#9557, which adds the
runtime `transport` option. The SDK's consumer-facing ProviderConfig is
hand-written (not generated from the schema), so the field is added as a
pass-through mirroring the existing `wireApi` field, flowing through the
already-wired `provider` option on session create and resume.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…isable-websocket-responses Resolve conflicts by keeping both the new capi.disableWebSocketResponses / provider.transport options from this branch and the experimental multi-provider BYOK (providers/models) additions from main across all six SDK languages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Update the CapiSessionOptions type-level doc summary in each language to lead with the spelled-out 'Copilot API (CAPI)' form on first use, matching the existing docs convention (and the Node SDK, which already did this). Python's class docstring previously never expanded the acronym. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Rename the hand-written capi session option from disableWebSocketResponses (default false) to enableWebSocketResponses (default true) across all six language SDKs, matching the inverted shape in runtime PR github/copilot-agent-runtime#10551. Setting it to false forces the HTTP Responses transport, equivalent to the unchanged COPILOT_CLI_DISABLE_WEBSOCKET_RESPONSES environment variable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency Review ✅Both new features ( Feature 1:
|
| SDK | Type | Field | On create | On resume | Wire key |
|---|---|---|---|---|---|
| Node.js | CapiSessionOptions interface |
enableWebSocketResponses?: boolean |
✅ capi? on SessionConfigBase |
✅ (inherited) | enableWebSocketResponses |
| Python | CapiSessionOptions TypedDict |
enable_web_socket_responses: bool |
✅ capi kwarg |
✅ capi kwarg |
enableWebSocketResponses |
| Go | CapiSessionOptions struct |
EnableWebSocketResponses *bool |
✅ Capi *CapiSessionOptions |
✅ Capi field |
enableWebSocketResponses |
| .NET | CapiSessionOptions class |
EnableWebSocketResponses bool? |
✅ Capi on SessionConfigBase |
✅ (inherited) | enableWebSocketResponses |
| Java | CapiSessionOptions class |
getEnableWebSocketResponses() / setEnableWebSocketResponses() |
✅ setCapi() on SessionConfig |
✅ setCapi() on ResumeSessionConfig |
enableWebSocketResponses |
| Rust | CapiSessionOptions struct |
enable_web_socket_responses: Option<bool> |
✅ with_capi() on SessionConfig |
✅ with_capi() on ResumeSessionConfig |
enableWebSocketResponses |
Feature 2: provider.transport
| SDK | Field | Type |
|---|---|---|
| Node.js | transport? |
"http" | "websockets" |
| Python | transport |
Literal["http", "websockets"] (optional in TypedDict) |
| Go | Transport |
string (omitempty) |
| .NET | Transport |
string? |
| Java | transport |
String (getter/setter) |
| Rust | transport |
Option<String> + with_transport() builder |
All SDKs serialize correctly to the same camelCase wire format (capi.enableWebSocketResponses, transport), use appropriate language idioms for optional/nullable types, include the CapiSessionOptions type in public exports where applicable (Node.js index.ts, Python __init__.py), and include unit tests covering both features.
Generated by SDK Consistency Review Agent for issue #1711 · sonnet46 1.3M · ◷
…ons (#1711) * Add capi.disableWebSocketResponses session option 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> * Add provider.transport BYOK option Add the BYOK provider `transport` field ("http" | "websockets", default "http") to the hand-written ProviderConfig across all six SDK languages, so BYOK OpenAI-compatible providers can opt into delivering Responses API requests over a persistent WebSocket connection instead of HTTP. SDK-side follow-up to github/copilot-agent-runtime#9557, which adds the runtime `transport` option. The SDK's consumer-facing ProviderConfig is hand-written (not generated from the schema), so the field is added as a pass-through mirroring the existing `wireApi` field, flowing through the already-wired `provider` option on session create and resume. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Lead with spelled-out 'Copilot API (CAPI)' on first mention Update the CapiSessionOptions type-level doc summary in each language to lead with the spelled-out 'Copilot API (CAPI)' form on first use, matching the existing docs convention (and the Node SDK, which already did this). Python's class docstring previously never expanded the acronym. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Invert capi flag to enableWebSocketResponses (default true) Rename the hand-written capi session option from disableWebSocketResponses (default false) to enableWebSocketResponses (default true) across all six language SDKs, matching the inverted shape in runtime PR github/copilot-agent-runtime#10551. Setting it to false forces the HTTP Responses transport, equivalent to the unchanged COPILOT_CLI_DISABLE_WEBSOCKET_RESPONSES environment variable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Why
Two related WebSocket transport controls for the SDK's hand-written session options, both follow-ups to runtime PRs that were already merged/under review and explicitly called out as needing a corresponding SDK change:
capi.enableWebSocketResponses— WebSocket transport is now the default for the CAPI (Copilot API) Responses API whenever a model advertises thews:/responsesendpoint. That breaks for users behind proxies or in networks where WebSockets fail, so they need a way to opt out and fall back to the HTTP Responses transport. SDK-side follow-up to github/copilot-agent-runtime#10551 (requested in review by @SteveSandersonMS).provider.transport— BYOK OpenAI-compatible providers need the opposite knob: an opt-in to deliver Responses API requests over a persistent WebSocket connection instead of HTTP (better for long-running, tool-call-heavy sessions that benefit from incrementalprevious_response_idcontinuations). SDK-side follow-up to github/copilot-agent-runtime#9557.These are two distinct, complementary toggles:
capi.enableWebSocketResponses: falseopts out of WS for GitHub's Copilot API;provider.transport: "websockets"opts in to WS for your own BYOK endpoint. They are independent and coexist.What
1.
capi.enableWebSocketResponsesNew nested session option
capi: { enableWebSocketResponses?: boolean }on session create and resume. WebSocket transport is enabled by default when the model advertisesws:/responses; set this tofalseto force the HTTP Responses transport instead. Setting it tofalseis equivalent to setting theCOPILOT_CLI_DISABLE_WEBSOCKET_RESPONSESenvironment variable (the env var name is unchanged). Scoped under acapinamespace (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.resumeparams gaincapi: { enableWebSocketResponses: false }, omitted entirely when unset.2.
provider.transportNew field
transport?: "http" | "websockets"(default"http") on the BYOKProviderConfig. When"websockets", Responses API requests for that OpenAI-compatible provider are delivered over a persistent WebSocket connection. Flows through the already-wiredprovideroption on session create and resume.Wire shape:
provider.transportserializes as a plain camelCase string, omitted when unset.Approach
Both options are hand-written pass-throughs. Session create/resume options — and the
ProviderConfigtype — are hand-written in every language (not codegen-driven), so these ship independently of the runtime releases:capiis a new nested type mirroring the existingprovider(BYOK) nested option exactly, wired into both the create and resume RPC params in every language.transportis a single new field onProviderConfigmirroring the existingwireApifield; it needs no new wiring because the wholeproviderobject is already serialized end-to-end.Per-language summary:
CapiSessionOptionsinterface +SessionConfigBase.capiwired in create/resume + re-export;transportonProviderConfig. Tests added.CapiSessionOptionsTypedDict + camelCase wire helper +capikwarg + export;transportonProviderConfigTypedDict + wire mapping. Tests added.CapiSessionOptionsstruct +Capion configs/wire requests/builders;TransportonProviderConfig. Tests added.CapiSessionOptions(fluent + Jackson) wired inSessionRequestBuilderfor create/resume;transportfield + getter/fluent-setter onProviderConfig. Tests added.CapiSessionOptionsclass +CapionSessionConfigBase(copy-ctor, both request records, serializer context);TransportonProviderConfig. Tests added.CapiSessionOptions(#[non_exhaustive]+ builders) +capion configs/wire;transportfield +with_transportbuilder onProviderConfig. Tests added.Compatibility
Both fields are harmless no-ops on a CLI runtime that predates the corresponding runtime PR, so the SDK changes are safe to land ahead of (or independently of) the runtime releases.
Deferred follow-up (by design)
@github/copilotdependency bump / codegen re-run. The current schema does not contain a generatedCapiSessionOptions, and the generatedProviderConfigis not the consumer-facing type (the SDK exports a hand-written one). Once the runtime PRs publish, an optional bump + codegen re-run can produce generated types; the hand-written pass-throughs are sufficient in the meantime.session.options.update(live update) wiring. This PR covers session create and resume only.Testing
Built and ran the per-language unit suites for every change — Node.js, Python, Go, Java, Rust, and .NET all pass locally (formatting/lint/clippy/spotless clean where applicable). e2e suites that require the replay-proxy harness were out of scope for local verification.
Refs github/copilot-agent-runtime#10551, github/copilot-agent-runtime#9557