Add capi.disableWebSocketResponses session option#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
Cross-SDK Consistency Review ✅This PR adds Consistency checklist
Naming conventions (idiomatic per language)
All naming follows each language's established conventions and mirrors the existing No cross-SDK consistency issues found.
|
Why
WebSocket transport is now the default for the CAPI (Copilot API) Responses API whenever a model advertises the
ws:/responsesendpoint. 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. Whentrue, the session uses the HTTP Responses transport instead of WebSockets. It is equivalent to setting theCOPILOT_CLI_DISABLE_WEBSOCKET_RESPONSESenvironment variable.The option is scoped under a
capinamespace (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.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
provideroption):CapiSessionOptionsinterface +SessionConfigBase.capi, wired in create + resume, re-exported, with a test.CapiSessionOptionsTypedDict + camelCase wire helper,capikwarg on create/resume, exported.CapiSessionOptionsstruct +Capion configs and wire requests, set in create + resume builders.CapiSessionOptions(fluent setters + Jackson) + field on both configs/requests, wired inSessionRequestBuilderfor create + resume.CapiSessionOptionsclass +CapionSessionConfigBase, copy-constructor, positional in both request records, registered in the serializer context.CapiSessionOptions(#[non_exhaustive]+ builders) +capion configs and wire types, converted ininto_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)
@github/copilotdependency bump / codegen re-run yet. The current schema does not contain a generatedCapiSessionOptions; 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.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