Skip to content

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

Open
illegalcall wants to merge 1 commit into0xPlaygrounds:mainfrom
illegalcall:add-openai-ws-mode
Open

feat(rig-core): add stateful WebSocket session for OpenAI Responses API#1500
illegalcall wants to merge 1 commit into0xPlaygrounds:mainfrom
illegalcall:add-openai-ws-mode

Conversation

@illegalcall
Copy link
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

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

1 participant