Skip to content

feat(realtime): add private translation WebSocket transport - #3871

Draft
jbeckwith-oai wants to merge 3 commits into
mainfrom
codex/realtime-translation-transport
Draft

jbeckwith-oai wants to merge 3 commits into
mainfrom
codex/realtime-translation-transport

Conversation

@jbeckwith-oai

@jbeckwith-oai jbeckwith-oai commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Changes being requested

Adds private synchronous and asynchronous WebSocket transport support for a future generated Realtime Translation resource. Connections refresh callable API keys through the existing client hooks, reuse the protected async connector and sync redirect rejection, and report failed or unsent frames without reconnecting or replaying them.

Startup queues are fully flushed, including messages added during a flush. Failure cleanup preserves cancellation, shields async cleanup from AnyIO cancellation, and allows up to 10 seconds for graceful close before aborting a transport that cannot close. API error events are delivered through a single raw receive path. Incoming messages have no new fixed size limit; callers can still specify a limit.

This is SDK infrastructure only: there is no new public client resource, generated adapter, event model, or exported public API. Both new files are handwritten; generated ownership and custom-code budget metadata are unchanged.

Validation

  • Focused transport, redirect, WebSocket option, and send-queue suites: 183 passed with websockets 15.0.1.
  • Minimum supported websockets 13.0: 116 passed, 8 expected redirect-capability skips.
  • Full-project Ruff, mypy, and Pyright passed; the two added files pass formatting checks.
  • Security review and required independent paired reviews completed, ending with two consecutive clean rounds on the unchanged files. All 25 transport regressions pass, including bounded cancellation under the installed WebSocket connection's flow-control path over an in-memory transport.
  • Local checks used the committed frozen dependency environment and direct tool entrypoints because the managed registry override and installed Node patch version prevented the standard wrappers. CI will exercise the repository wrappers.

Additional context & links

Generated resource integration and adapter-level tests are intentionally deferred. No reconnect system, WebRTC, or changes to existing Realtime resources are included.

  • I understand that this repository is auto-generated and my pull request may not be merged

@jbeckwith-oai
jbeckwith-oai requested a review from a team September 16, 2026 04:13
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

46 mixed files remain; 0 existing customizations changed.

Compared 98e1d24f4902189f5431ee40. Generated baselines verified.

46 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/agents/sessions/sessions.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/responses/responses.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/live/forks.py
  • src/openai/resources/live/live.py
  • src/openai/resources/live/sideband.py
  • src/openai/resources/realtime/api.md
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/responses/responses.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/beta/agent_session_message.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/realtime/conversation_item_input_audio_transcription_delta_event.py
  • src/openai/types/realtime/realtime_error_event.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/responses_client_event.py
  • src/openai/types/responses/responses_client_event_param.py

6 more in the full report.

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 35056205891 --repo openai/openai-python \
  --name castiron-custom-code-35056205891-1 --dir /tmp/castiron-custom-code-35056205891-1
git apply --stat /tmp/castiron-custom-code-35056205891-1/custom-code.patch
cat /tmp/castiron-custom-code-35056205891-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 98e1d24f4902ab58830adf0e2b6a729a5d5429b1 189f5431ee40d58cab79f5d98fe03d0a22fbad2a
python3 scripts/castiron/custom_code_report.py report \
  --base 98e1d24f4902ab58830adf0e2b6a729a5d5429b1 \
  --head 189f5431ee40d58cab79f5d98fe03d0a22fbad2a --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-189f5431ee40
cat /tmp/castiron-custom-code-189f5431ee40/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

Comment thread src/openai/lib/_realtime_translation.py Fixed

@markstuart-oai markstuart-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 9255036de3ba48c18892fb34ba89bdde9174cfaa against 98e1d24f4902ab58830adf0e2b6a729a5d5429b1. Leaving feedback without approval for a cancellation hang in failure cleanup. A real loopback peer that stops reading leaves both a directly cancelled send and an AnyIO-cancelled startup flush pending beyond the default close timeout. The shielded close cannot reach its timeout while it is blocked draining the same socket.

Authentication and ordinary transport behavior otherwise check out: the independent auth review passed six boundary probes; 51 focused transport/queue tests pass; real sync/async wire probes confirm FIFO startup frames, one raw error delivery, an uncompressed frame over 1 MiB, normal remote close, and unsent reporting after close. Source stays private and the generated adapter remains out of scope.

Exact-head CI run 35055191611 passes Python 3.10/3.14, HTTPX2, lint and build; Python 3.10's Pydantic lanes report 13,182 and 13,168 passed. Security and custom-code checks also pass. Local probes used the existing Python 3.10 environment with websockets 15.0.1 and AnyIO 4.12.1, not a fresh locked installation. No live API calls or generated-adapter integration tests were run.

Comment thread src/openai/lib/_realtime_translation.py
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.

2 participants