Skip to content

feat(rig-core): add stateful WebSocket session for OpenAI Responses API#1500

Merged
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
illegalcall:add-openai-ws-mode
Mar 16, 2026
Merged

feat(rig-core): add stateful WebSocket session for OpenAI Responses API#1500
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
illegalcall:add-openai-ws-mode

Conversation

@illegalcall
Copy link
Copy Markdown
Contributor

@illegalcall illegalcall commented Mar 11, 2026

Summary

Adds ResponsesWebSocketSession for OpenAI's Responses API WebSocket mode — a stateful session supporting warmup, streaming, multi-turn chaining, and clean shutdown.

Key design decisions

  • response.completed as source of truth over response.done — it carries a fully typed CompletionResponse and exists in both SSE and WebSocket codepaths. response.done is treated as a trailing echo, silently absorbed between turns via pending_done_response_id.
  • Restricted to Client<reqwest::Client>, non-WASM only — WebSocket transport uses tokio-tungstenite directly, bypassing HttpClientExt. Exposing it on generic H would be misleading since the custom backend gets ignored.
  • Reuses StreamingCompletionChunk from the SSE layer rather than duplicating event types.

Other changes

  • Fixed ContentPartChunkPart / SummaryPartChunkPart serde rename_all = "snake_case" to match OpenAI's wire format, with deserialization tests
  • tokio-tungstenite added as target-scoped native-only dependency

Test plan

  • cargo fmt, cargo clippy --all-features --all-targets, cargo test -p rig-core
  • Manual test with OPENAI_API_KEY via examples/openai_websocket_mode.rs

Fixes #1425

Copy link
Copy Markdown
Contributor

@joshua-mo-143 joshua-mo-143 left a comment

Choose a reason for hiding this comment

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

lgtm

@joshua-mo-143 joshua-mo-143 added this pull request to the merge queue Mar 16, 2026
Merged via the queue into 0xPlaygrounds:main with commit 09c5a3f Mar 16, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 16, 2026
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.

feat: Add support for new OpenAI WebSocket Mode

2 participants