Skip to content

refactor: reuse Java WebSocket connection helpers - #1194

Merged
markstuart-oai merged 1 commit into
mainfrom
castiron/promotions/pr-287
Oct 16, 2026
Merged

markstuart-oai merged 1 commit into
mainfrom
castiron/promotions/pr-287

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Why

Existing and new WebSocket APIs should share the SDK's connection code while preserving each API's public behavior.

High-level description

Extract Live's connection mechanics into an SDK-owned helper. Keep the existing wrappers, options, validation, errors, authentication, and session rules. Generate endpoint and event bindings that use the same request factory and helper.

The current compiler also supplies its already-merged fix for adding items to a copied request's omitted list. That changes 42 request models without changing public signatures. The WebSocket runtime, bindings, and tests match the previously tested candidate.

Validation

  • All current CI checks pass, including the full test suite, API compatibility, Java 8/25 runtime checks, and older Jackson compatibility.
  • The unchanged WebSocket implementation passed all 199 existing WebSocket tests; all 39 Sideband tests also passed with normal and older Jackson.
  • Fresh generation from the merged compiler passed installed-package acceptance: packaged JARs passed 73 external Java 8 real-socket checks covering credentials, request hooks, events, redirects, cancellation, limits, and cleanup.
  • An unrelated API required only spec/config changes. Repeat generation reproduced all 3,800 files and left SDK-owned files unchanged.
  • Custom-code checks pass without changing limits.

Castiron-Internal-PR: openai/openai-java-internal#287
Castiron-Source-SHA: ac314daf9f2e48d609d245501665fb466d63d3e1
Castiron-Public-Base-SHA: 812a4fb
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Castiron custom code

Evaluated main: 812a4fb74885f69b130c82d024f44541f73b8f5e.

Trusted main policy: 812a4fb74885f69b130c82d024f44541f73b8f5e.

Mixed files: 102 → 96

1 newly customized · 7 customizations removed · 0 existing customizations changed · 33 generated baselines changed

Compared 812a4fb74885 → 3f8a44f40f35. Generated baselines verified.

File Result Current custom patch
openai-java-core/src/main/kotlin/com/openai/models/beta/agents/environments/EnvironmentCreateParams.kt Generated baseline changed +4 / −7
openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt Generated baseline changed +42 / −57
openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt Generated baseline changed +2 / −2
openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt Generated baseline changed +2 / −2
openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt Generated baseline changed +76 / −0
openai-java-core/src/test/kotlin/com/openai/models/live/ClientEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/ServerEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/SessionClosedEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/SessionStartEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/SessionStartedEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/SessionUpdatedEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/models/live/forks/ForkServerEventTest.kt Generated baseline changed None
openai-java-core/src/test/kotlin/com/openai/services/async/CompletionServiceAsyncTest.kt Generated baseline changed +3 / −6
openai-java-core/src/test/kotlin/com/openai/services/async/ImageServiceAsyncTest.kt Generated baseline changed +5 / −12
openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt Generated baseline changed +5 / −16
openai-java-core/src/test/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncTest.kt Generated baseline changed +3 / −6
openai-java-core/src/test/kotlin/com/openai/services/async/beta/ResponseServiceAsyncTest.kt Generated baseline changed +2 / −15
openai-java-core/src/test/kotlin/com/openai/services/async/beta/ThreadServiceAsyncTest.kt Generated baseline changed +3 / −8
openai-java-core/src/test/kotlin/com/openai/services/async/beta/agents/SessionServiceAsyncTest.kt Generated baseline changed +12 / −7
openai-java-core/src/test/kotlin/com/openai/services/async/beta/agents/sessions/EventServiceAsyncTest.kt Generated baseline changed +22 / −7
openai-java-core/src/test/kotlin/com/openai/services/async/beta/threads/RunServiceAsyncTest.kt Generated baseline changed +5 / −16
openai-java-core/src/test/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncTest.kt Generated baseline changed +3 / −6
openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt Generated baseline changed +3 / −6
openai-java-core/src/test/kotlin/com/openai/services/blocking/ImageServiceTest.kt Generated baseline changed +7 / −10
openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt Generated baseline changed +5 / −12
openai-java-core/src/test/kotlin/com/openai/services/blocking/audio/TranscriptionServiceTest.kt Generated baseline changed +4 / −5
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/ResponseServiceTest.kt Generated baseline changed +2 / −14
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/ThreadServiceTest.kt Generated baseline changed +3 / −8
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/agents/SessionServiceTest.kt Generated baseline changed +11 / −7
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/agents/sessions/EventServiceTest.kt Generated baseline changed +21 / −7
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/threads/RunServiceTest.kt Generated baseline changed +5 / −16
openai-java-core/src/test/kotlin/com/openai/services/blocking/chat/ChatCompletionServiceTest.kt Generated baseline changed +4 / −5
scripts/castiron/custom_code_budget.py Generated baseline changed +1 / −1
70 existing customizations unchanged
  • openai-java-core/src/main/kotlin/com/openai/models/audio/AudioResponseFormat.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/agents/vaults/credentials/CredentialAuth.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/agents/vaults/credentials/CredentialAuthCreateParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/agents/vaults/credentials/CredentialAuthRotateParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponse.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseError.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInjectEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInjectFailedEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseStreamEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseToolSearchOutputItemParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesServerEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/live/ResponseItemCreateEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseStatus.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseError.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseStreamEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextConfig.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseToolSearchOutputItemParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesServerEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/videos/Video.kt
  • openai-java-core/src/main/kotlin/com/openai/models/videos/VideoCreateError.kt
  • openai-java-core/src/main/kotlin/com/openai/models/webhooks/UnwrapWebhookEvent.kt
  • openai-java-core/src/main/kotlin/com/openai/models/webhooks/WebhookEndpointWithSecret.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/SkillServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/VideoServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt

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

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

git fetch --no-tags origin 812a4fb74885f69b130c82d024f44541f73b8f5e 3f8a44f40f355bfe6d6c738348e295d747096301
python3 scripts/castiron/custom_code_report.py report \
  --base 812a4fb74885f69b130c82d024f44541f73b8f5e \
  --head 3f8a44f40f355bfe6d6c738348e295d747096301 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-3f8a44f40f35
cat /tmp/castiron-custom-code-3f8a44f40f35/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

@markstuart-oai
markstuart-oai marked this pull request as ready for review October 16, 2026 08:29
@markstuart-oai
markstuart-oai requested a review from a team as a code owner October 16, 2026 08:29
@openai-sdks

openai-sdks Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 236/236 SDK tests passed in 15.203s for Java SDK PR #1194.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 189ms
tests/chat-completions-create.test.ts ✅ Passed 626ms
tests/chat-completions-stream.test.ts ✅ Passed 850ms
tests/files-content-binary.test.ts ✅ Passed 286ms
tests/files-create-multipart.test.ts ✅ Passed 443ms
tests/files-list-pagination.test.ts ✅ Passed 236ms
tests/initialize-config.test.ts ✅ Passed 255ms
tests/instance-isolation.test.ts ✅ Passed 244ms
tests/models-list.test.ts ✅ Passed 306ms
tests/responses-background-lifecycle.test.ts ✅ Passed 725ms
tests/responses-body-method-errors.test.ts ✅ Passed 599ms
tests/responses-cancel-timeout.test.ts ✅ Passed 228ms
tests/responses-cancel.test.ts ✅ Passed 264ms
tests/responses-compact-retries.test.ts ✅ Passed 430ms
tests/responses-compact.test.ts ✅ Passed 284ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 247ms
tests/responses-create-advanced.test.ts ✅ Passed 1.771s
tests/responses-create-disconnect.test.ts ✅ Passed 1.072s
tests/responses-create-errors.test.ts ✅ Passed 308ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 311ms
tests/responses-create-retries.test.ts ✅ Passed 316ms
tests/responses-create-stream-failures.test.ts ✅ Passed 293ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 219ms
tests/responses-create-stream-wire.test.ts ✅ Passed 4.988s
tests/responses-create-stream.test.ts ✅ Passed 269ms
tests/responses-create-terminal-states.test.ts ✅ Passed 310ms
tests/responses-create-timeout.test.ts ✅ Passed 273ms
tests/responses-create.test.ts ✅ Passed 337ms
tests/responses-delete.test.ts ✅ Passed 275ms
tests/responses-input-items-errors.test.ts ✅ Passed 282ms
tests/responses-input-items-list.test.ts ✅ Passed 372ms
tests/responses-input-items-options.test.ts ✅ Passed 470ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 303ms
tests/responses-input-tokens-count.test.ts ✅ Passed 329ms
tests/responses-malformed-inputs.test.ts ✅ Passed 3.728s
tests/responses-not-found-errors.test.ts ✅ Passed 355ms
tests/responses-parse.test.ts ✅ Passed 727ms
tests/responses-retrieve-retries.test.ts ✅ Passed 348ms
tests/responses-retrieve.test.ts ✅ Passed 353ms
tests/responses-stored-method-errors.test.ts ✅ Passed 1.016s
tests/retry-behavior.test.ts ✅ Passed 3.487s
tests/sdk-error-shape.test.ts ✅ Passed 480ms

View OkTest run #38874046441

SDK merge (63e2a64d7be7) · head (3f8a44f40f35) · base (812a4fb74885) · OkTest (0bab422a5181)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-10-16T08:34:38.322786Z 3f8a44f Draft marked ready
🔒 Security Review ✅ Completed 2026-10-16T08:34:49.262845Z 3f8a44f Draft marked ready
ℹ️ 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.

@jbeckwith-oai jbeckwith-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 3f8a44f40f355bfe6d6c738348e295d747096301 against 812a4fb74885f69b130c82d024f44541f73b8f5e. No actionable findings.

The extraction preserves the existing Live wrappers' request policy, event types, error text, queue/drain behavior, cancellation and uncertain-write handling. Fork/Sideband path encoding and command restrictions stay in their API-specific wrappers; Realtime, Translation and Responses retain their existing connection machinery while taking endpoint/auth metadata from the generated bindings.

I also checked the new Sideband unions and compilation-shard dependencies, the Translation visitor defaults, and the generated request changes. Across all 42 changed request models, the only non-whitespace change is the 60 missing-list guards, preserving explicit-null/invalid-value behavior. The legacy custom-code inventory fallback is tied to exact checker bytes and does not relax the budget policy or workflow ownership rules.

Validation: static review only; git diff --check passed. I independently verified the public generated snapshot hash (bda6b5fe…f75878). Hosted tests, older-Jackson compatibility, API compatibility, Java 8/25 runtime checks, and Castiron statuses are green for this head. I did not locally rerun tests, generation, or the author-reported installed-JAR/socket experiments.

@markstuart-oai
markstuart-oai added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 848ef53 Oct 16, 2026
23 checks passed
@openai-sdks openai-sdks Bot mentioned this pull request Oct 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.

2 participants