Add capi.disableWebSocketResponses and provider.transport session options#1711
Add capi.disableWebSocketResponses and provider.transport session options#1711dereklegenzoff wants to merge 2 commits into
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>
Cross-SDK Consistency Review ✅This PR adds two new session options ( CoverageAll six SDKs are updated in this PR:
Wire Format ConsistencyAll SDKs agree on the JSON wire shape:
API Naming ConventionsConventions are correctly applied per language:
Type Safety
Export Visibility
Both Session OperationsBoth No consistency issues found. The changes are symmetric, well-documented, and follow each language's established conventions.
|
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.disableWebSocketResponses— 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.disableWebSocketResponsesopts out of WS for GitHub's Copilot API;provider.transportopts in to WS for your own BYOK endpoint. They are independent and coexist.What
1.
capi.disableWebSocketResponsesNew nested session option
capi: { disableWebSocketResponses?: boolean }on session create and resume. Whentrue, the session uses the HTTP Responses transport instead of WebSockets. Equivalent to setting theCOPILOT_CLI_DISABLE_WEBSOCKET_RESPONSESenvironment variable. 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: { disableWebSocketResponses: true }, 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