Skip to content

fix: resume Responses streams from server-side cursors - #548

Merged
jbeckwith-oai merged 5 commits into
mainfrom
codex/fix-responses-server-resumption
Aug 29, 2026
Merged

fix: resume Responses streams from server-side cursors#548
jbeckwith-oai merged 5 commits into
mainfrom
codex/fix-responses-server-resumption

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Summary

  • Forward starting_after when client.responses.stream(response_id:, starting_after:) retrieves an existing response, so the server resumes from the requested event sequence.
  • Handle genuine incremental resumed streams that begin with text or tool deltas, finalized structured text, unknown events, or response.completed, while preserving normal stream validation and typed final responses.
  • Add public-entrypoint regression coverage for cursor forwarding, partial snapshots, completion-only resumes, structured text/tool outputs, unknown-event filtering, and unchanged non-resumed behavior.

Verification

  • TMPDIR=/private/tmp bundle exec rake test
  • BUNDLE_FROZEN=true BUNDLE_GEMFILE=gemfiles/bedrock.gemfile bundle exec rake test:bedrock
  • bundle exec rake lint:rubocop
  • bundle exec rake typecheck:sorbet
  • bundle exec rake validate:rbs
  • python3 -m unittest discover -s scripts/castiron -p 'test_custom_code*.py'
  • Trusted-main Castiron custom-code budget check: 3,047 / 4,000 lines.
  • Two consecutive clean adversarial-review rounds with two independent reviewers per round, including endpoint/deserialization security review.

@openai/sdks-team

@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 27, 2026 22:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 27, 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-29T00:18:09.155177Z d0aad51 New commits
🔒 Security Review Completed 2026-08-29T00:19:06.806387Z d0aad51 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 27, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.13s for Ruby SDK PR #548.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 303ms
tests/chat-completions-create.test.ts ✅ Passed 324ms
tests/chat-completions-stream.test.ts ✅ Passed 196ms
tests/files-content-binary.test.ts ✅ Passed 251ms
tests/files-create-multipart.test.ts ✅ Passed 251ms
tests/files-list-pagination.test.ts ✅ Passed 222ms
tests/initialize-config.test.ts ✅ Passed 204ms
tests/instance-isolation.test.ts ✅ Passed 293ms
tests/models-list.test.ts ✅ Passed 201ms
tests/responses-background-lifecycle.test.ts ✅ Passed 276ms
tests/responses-body-method-errors.test.ts ✅ Passed 448ms
tests/responses-cancel-timeout.test.ts ✅ Passed 194ms
tests/responses-cancel.test.ts ✅ Passed 317ms
tests/responses-compact-retries.test.ts ✅ Passed 365ms
tests/responses-compact.test.ts ✅ Passed 350ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 173ms
tests/responses-create-advanced.test.ts ✅ Passed 225ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.065s
tests/responses-create-errors.test.ts ✅ Passed 257ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 208ms
tests/responses-create-retries.test.ts ✅ Passed 331ms
tests/responses-create-stream-failures.test.ts ✅ Passed 200ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 260ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.38s
tests/responses-create-stream.test.ts ✅ Passed 122ms
tests/responses-create-terminal-states.test.ts ✅ Passed 359ms
tests/responses-create-timeout.test.ts ✅ Passed 200ms
tests/responses-create.test.ts ✅ Passed 397ms
tests/responses-delete.test.ts ✅ Passed 416ms
tests/responses-input-items-errors.test.ts ✅ Passed 256ms
tests/responses-input-items-list.test.ts ✅ Passed 264ms
tests/responses-input-items-options.test.ts ✅ Passed 272ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 261ms
tests/responses-input-tokens-count.test.ts ✅ Passed 324ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.115s
tests/responses-not-found-errors.test.ts ✅ Passed 316ms
tests/responses-parse.test.ts ✅ Passed 291ms
tests/responses-retrieve-retries.test.ts ✅ Passed 366ms
tests/responses-retrieve.test.ts ✅ Passed 289ms
tests/responses-stored-method-errors.test.ts ✅ Passed 933ms
tests/retry-behavior.test.ts ✅ Passed 3.313s
tests/sdk-error-shape.test.ts ✅ Passed 393ms

View OkTest run #33223024190

SDK merge (85fa63f837aa) · head (d0aad51d7bf3) · base (da421b507c24) · OkTest (2b1bdfd25e98)

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

47 mixed files remain; 1 existing customization changed.

Compared da421b507c24d0aad51d7bf3. Generated baselines verified.

File Result Current custom patch
lib/openai/resources/responses.rb Existing customization changed +164 / −3
46 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/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
  • sig/openai/client.rbs

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

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

git fetch --no-tags origin da421b507c24c35f62ff8679dd5c468ce8a0dab9 d0aad51d7bf351667e5df16e2d079d077c1e0f8d
python3 scripts/castiron/custom_code_report.py report \
  --base da421b507c24c35f62ff8679dd5c468ce8a0dab9 \
  --head d0aad51d7bf351667e5df16e2d079d077c1e0f8d --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-d0aad51d7bf3
cat /tmp/castiron-custom-code-d0aad51d7bf3/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: 21a88e4205

ℹ️ 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/streaming/response_stream.rb Outdated

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-reviewed the exact current head. starting_after is forwarded to the retrieval stream, resumed streams no longer require a synthetic response.created, raw deltas avoid quadratic prefix materialization, and authoritative done/completed events still drive parsed/final results. No blocking findings. (GitHub does not permit this account to formally approve its own PR.)

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

Reviewed the full diff at 8b8f54b1f1b2240faca2a20bbc16c975255a8fee, including cursor forwarding, partial-stream handling, structured completion, unknown events, and stream cleanup. The previous quadratic-copy concern is addressed, but one helper-event compatibility regression remains inline.

Comment thread lib/openai/helpers/streaming/response_stream.rb Outdated
@jbeckwith-oai
jbeckwith-oai requested a review from a team August 28, 2026 23:19

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

Reviewed the full current diff at 439c5f654bf439deeead263173a6b5034c722da9. The prior helper-event compatibility issue is fixed for both text and function-argument deltas: partial resumes retain the public helper subclasses and original payload fields, with snapshot: nil representing the unavailable prefix without rebuilding it. Cursor forwarding now also uses normalized parameters while preserving request options. Completion/structured-output handling, unknown-event filtering, normal-stream validation, and stream cleanup remain consistent. No substantive issues found.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 29, 2026
Merged via the queue into main with commit 3b88261 Aug 29, 2026
19 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/fix-responses-server-resumption branch August 29, 2026 00:21
@openai-sdks openai-sdks Bot mentioned this pull request Aug 28, 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