Skip to content

fix(realtime): clean up interrupted WebRTC call allocations - #534

Merged
jbeckwith-oai merged 2 commits into
mainfrom
codex/realtime-call-allocation-lifecycle
Aug 27, 2026
Merged

fix(realtime): clean up interrupted WebRTC call allocations#534
jbeckwith-oai merged 2 commits into
mainfrom
codex/realtime-call-allocation-lifecycle

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Summary

  • Keep the Castiron-generated realtime.calls.create endpoint and its OpenAI::HTTPClient::Response contract unchanged while giving the existing handwritten Realtime client extension ownership of a newly allocated WebRTC call until response buffering and completion succeed.
  • If reading the SDP answer, request completion, or Async cancellation interrupts that ownership transfer, validate the Location against the original request origin/path and call the generated realtime.calls.hangup endpoint before preserving the original failure.
  • Preserve tenant/project routing headers, query parameters, request timeouts, normal hangup retries, connection-pool release, current and legacy optional Async behavior, malformed-request validation, equivalent IPv6 origins, sensitive-data redaction, binary downloads, SIP operations, and successfully delivered calls.
  • Treat absent, malformed, cross-origin, or otherwise untrusted Location values as unrecoverable; allocation without any received response headers remains a separate platform-level recovery limitation.

Verification

  • Five adversarial review rounds with exactly two independent fresh-context reviewers per round; rounds four and five were consecutively clean.
  • Ruby 4.0 general suite: 1,425 tests / 12,902 assertions, zero failures or errors, one existing skip.
  • Realtime ownership suite: 22 tests / 173 assertions on Ruby 3.3, 3.4, and 4.0, including actual legacy Async 2.34 and current Async 2.44.
  • Existing security suites: 28 logging-security tests / 849 assertions, 24 transport-origin tests / 412 assertions, and 38 redirect-security tests / 380 assertions.
  • The other 10 network-invariant tests / 197 assertions pass separately. The pre-existing test_sideband_proxy_keeps_call_ids_and_both_credentials_out_of_traces hangs in this local environment even when isolated, so it was excluded locally and remains covered by hosted CI.
  • Full bundle exec rake lint: 2,783 RuboCop files clean, Sorbet clean, and 1,246 RBS files validated.
  • Castiron custom-code budget: 2,933 / 4,000 lines, unchanged generated ownership and no budget-policy changes.
  • Examples inventory and installed-gem/X.509 packaging checks pass.

Requesting @openai/sdks-team review because this change affects Realtime request lifecycle and transport-adjacent ownership.

@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 26, 2026 19:54
@jbeckwith-oai
jbeckwith-oai requested a review from a team August 26, 2026 19:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-26T21:03:32.482452Z 91489fb New commits
🔒 Security Review Completed 2026-08-26T21:04:27.400298Z 91489fb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 10.658s for Ruby SDK PR #534.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 261ms
tests/chat-completions-create.test.ts ✅ Passed 345ms
tests/chat-completions-stream.test.ts ✅ Passed 186ms
tests/files-content-binary.test.ts ✅ Passed 280ms
tests/files-create-multipart.test.ts ✅ Passed 299ms
tests/files-list-pagination.test.ts ✅ Passed 182ms
tests/initialize-config.test.ts ✅ Passed 290ms
tests/instance-isolation.test.ts ✅ Passed 273ms
tests/models-list.test.ts ✅ Passed 335ms
tests/responses-background-lifecycle.test.ts ✅ Passed 276ms
tests/responses-body-method-errors.test.ts ✅ Passed 356ms
tests/responses-cancel-timeout.test.ts ✅ Passed 187ms
tests/responses-cancel.test.ts ✅ Passed 280ms
tests/responses-compact-retries.test.ts ✅ Passed 349ms
tests/responses-compact.test.ts ✅ Passed 334ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 128ms
tests/responses-create-advanced.test.ts ✅ Passed 240ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.205s
tests/responses-create-errors.test.ts ✅ Passed 238ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 181ms
tests/responses-create-retries.test.ts ✅ Passed 357ms
tests/responses-create-stream-failures.test.ts ✅ Passed 201ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 268ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.259s
tests/responses-create-stream.test.ts ✅ Passed 117ms
tests/responses-create-terminal-states.test.ts ✅ Passed 344ms
tests/responses-create-timeout.test.ts ✅ Passed 201ms
tests/responses-create.test.ts ✅ Passed 393ms
tests/responses-delete.test.ts ✅ Passed 364ms
tests/responses-input-items-errors.test.ts ✅ Passed 279ms
tests/responses-input-items-list.test.ts ✅ Passed 209ms
tests/responses-input-items-options.test.ts ✅ Passed 257ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 237ms
tests/responses-input-tokens-count.test.ts ✅ Passed 265ms
tests/responses-malformed-inputs.test.ts ✅ Passed 1.923s
tests/responses-not-found-errors.test.ts ✅ Passed 269ms
tests/responses-parse.test.ts ✅ Passed 290ms
tests/responses-retrieve-retries.test.ts ✅ Passed 339ms
tests/responses-retrieve.test.ts ✅ Passed 267ms
tests/responses-stored-method-errors.test.ts ✅ Passed 843ms
tests/retry-behavior.test.ts ✅ Passed 3.128s
tests/sdk-error-shape.test.ts ✅ Passed 331ms

View OkTest run #33013383426

SDK merge (b90e053be5aa) · head (91489fb21de7) · base (fd220ef63d5f) · OkTest (2b1bdfd25e98)

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

47 mixed files remain; 0 existing customizations changed.

Compared fd220ef63d5f91489fb21de7. Generated baselines verified.

47 existing customizations unchanged
  • lib/openai.rb
  • lib/openai/client.rb
  • lib/openai/models/chat/chat_completion_message.rb
  • lib/openai/models/chat/chat_completion_message_function_tool_call.rb
  • lib/openai/models/chat/completion_create_params.rb
  • lib/openai/models/response_format_json_schema.rb
  • lib/openai/models/responses/function_tool.rb
  • lib/openai/models/responses/response.rb
  • lib/openai/models/responses/response_create_params.rb
  • lib/openai/models/responses/response_format_text_config.rb
  • lib/openai/models/responses/response_format_text_json_schema_config.rb
  • lib/openai/models/responses/response_function_tool_call.rb
  • lib/openai/models/responses/response_function_web_search.rb
  • lib/openai/models/responses/response_output_text.rb
  • lib/openai/models/responses/tool.rb
  • lib/openai/resources/beta/threads.rb
  • lib/openai/resources/chat/completions.rb
  • lib/openai/resources/files.rb
  • lib/openai/resources/responses.rb
  • lib/openai/resources/vector_stores/file_batches.rb
  • lib/openai/resources/vector_stores/files.rb
  • lib/openai/resources/webhooks.rb
  • rbi/openai/client.rbi
  • rbi/openai/models/chat/chat_completion_message.rbi
  • rbi/openai/models/chat/chat_completion_message_function_tool_call.rbi
  • rbi/openai/models/chat/completion_create_params.rbi
  • rbi/openai/models/response_format_json_schema.rbi
  • rbi/openai/models/responses/response.rbi
  • rbi/openai/models/responses/response_create_params.rbi
  • rbi/openai/models/responses/response_function_tool_call.rbi
  • rbi/openai/models/responses/response_function_web_search.rbi
  • rbi/openai/models/responses/response_output_text.rbi
  • rbi/openai/resources/chat/completions.rbi
  • rbi/openai/resources/files.rbi
  • rbi/openai/resources/responses.rbi
  • rbi/openai/resources/vector_stores/file_batches.rbi
  • rbi/openai/resources/vector_stores/files.rbi
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py

7 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 33013423030 --repo openai/openai-ruby \
  --name castiron-custom-code-33013423030-1 --dir /tmp/castiron-custom-code-33013423030-1
git apply --stat /tmp/castiron-custom-code-33013423030-1/custom-code.patch
cat /tmp/castiron-custom-code-33013423030-1/custom-code.patch

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

git fetch --no-tags origin fd220ef63d5f5d21c1975ec686a529df5d3d3ef3 91489fb21de754901d7203aca323080a5026809a
python3 scripts/castiron/custom_code_report.py report \
  --base fd220ef63d5f5d21c1975ec686a529df5d3d3ef3 \
  --head 91489fb21de754901d7203aca323080a5026809a --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-91489fb21de7
cat /tmp/castiron-custom-code-91489fb21de7/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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38326d74cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/openai/helpers/realtime/client_extension.rb Outdated
Comment thread lib/openai/helpers/realtime/client_extension.rb Outdated

@HAYDEN-OAI HAYDEN-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.

Found one additional substantive cancellation/cleanup issue. The existing unresolved findings about malformed hostless Location values and allocation ownership before response logging also remain valid.

Comment thread lib/openai/helpers/realtime/client_extension.rb

@HAYDEN-OAI HAYDEN-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.

Re-reviewed the complete WebRTC allocation lifecycle and verified all previous material findings are resolved. Allocation ownership is captured immediately when trusted response headers arrive, before cancellable logging; malformed, hostless, and cross-origin Location values cannot trigger authenticated cleanup; and cancellation-shielded hangup now has a single bounded wall-clock deadline (maximum five seconds), no retries, and preserved original errors. Also verified tenant/project routing, connection release, hostile redirects, IPv6 origin equivalence, legacy Async compatibility, and sensitive-data redaction. Looks good to merge.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 27, 2026
Merged via the queue into main with commit 2057039 Aug 27, 2026
19 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/realtime-call-allocation-lifecycle branch August 27, 2026 15:50
@openai-sdks openai-sdks Bot mentioned this pull request Aug 27, 2026
cjc0013 pushed a commit to cjc0013/openai-ruby that referenced this pull request Aug 28, 2026
Automated Release PR
---


##
[0.83.0](openai/openai-ruby@v0.82.0...v0.83.0)
(2026-08-27)


### Features

* **api:** add compute_units to Responses and Chat Completions usage
([openai#543](openai#543))
([b128f89](openai@b128f89))
* expose opt-in raw response bodies on response metadata
([openai#544](openai#544))
([1529e96](openai@1529e96))


### Bug Fixes

* **realtime:** clean up interrupted WebRTC call allocations
([openai#534](openai#534))
([2057039](openai@2057039))


### Chores

* **deps:** bump the codeql group with 2 updates
([openai#541](openai#541))
([b15451c](openai@b15451c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
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