Skip to content

refactor(core): replace websocket flags with a single transport preference - #48423

Open
rekram1-node wants to merge 1 commit into
v2from
model-transport
Open

refactor(core): replace websocket flags with a single transport preference#48423
rekram1-node wants to merge 1 commit into
v2from
model-transport

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

Models had two WebSocket knobs that meant different things: capabilities.responsesWebsockets (a route fact precomputed by provider plugins, never user-settable) and websocket: boolean (user policy, model overrides provider, default true). Every other plugin-known field on Model.Info uses one pattern — plugin sets a default, user overrides, wrong overrides fail at request time — so this collapses WebSocket to the same shape.

  • Drop Model.capabilities.responsesWebsockets. The route already knows whether it has a channel (open-responses-channel.ts falls back to HTTP when prepared.channel is absent; Azure's enabled(url) gate in @opencode/ai covers the URL/api-version checks the core plugin duplicated).
  • Replace websocket?: boolean on Model.Info, Provider.Info, and their config entries with transport?: "http" | "websocket" (new Provider.Transport literal). Inherits model → provider like compaction.
  • Remove the capability-setting loops from the OpenAI, xAI, and Azure plugins.

Request-time semantics

transport Behavior
omitted Offer the session executor; the route uses its channel when it has one, HTTP otherwise
"http" Never offer the executor
"websocket" Offer the executor; if the route has no channel, log a warning and fall back to HTTP

The warning is delivered via a new optional WebSocketChannelExecutor.unavailable: Effect<void> hook. HttpTransport.httpJson, the Open Responses channel transport's HTTP path, and the AI SDK adapter route in core/src/aisdk.ts all run it when handed an executor they cannot use, so every route type reports consistently. Core attaches it only when the user explicitly chose "websocket".

Notes

Testing

  • bun typecheck clean in schema, ai, core, server, protocol, client.
  • ai: 1290 pass. schema: pass. core: 5374 pass; the 8 remaining failures are bash/shell-environment tests that fail identically on the base commit.
  • Extended the Meta HTTP-only and Azure unsupported-endpoint tests to assert unavailable fires; updated the config inheritance and model-request policy tests to the three-way transport behavior.

…rence

Drop Model.capabilities.responsesWebsockets, which provider plugins
precomputed from route facts, and replace the websocket booleans on
Model.Info, Provider.Info and their config entries with
transport?: "http" | "websocket".

The route now decides whether it has a WebSocket channel. Omitted uses
the channel when offered and HTTP otherwise; "http" never offers the
session executor; an explicit "websocket" on a route without a channel
logs a warning via the new WebSocketChannelExecutor.unavailable hook and
falls back to HTTP.
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.

1 participant