Skip to content

examples: validate parsed chat completion events - #517

Merged
jbeckwith-oai merged 1 commit into
mainfrom
codex/validate-structured-chat-calendar-events
Aug 24, 2026
Merged

examples: validate parsed chat completion events#517
jbeckwith-oai merged 1 commit into
mainfrom
codex/validate-structured-chat-calendar-events

Conversation

@jbeckwith-oai

@jbeckwith-oai jbeckwith-oai commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Print only actual CalendarEvent instances from the handwritten structured-output Chat Completions example, preserving existing successful output and refusal handling.
  • Exit with The response did not contain a parsed CalendarEvent when choices are empty, all refused, or contain only nil/wrong-type parsed values.
  • Add eight isolated regression and characterization tests using the existing example-loading conventions, Minitest client mocks, and real SDK choice/message models.
  • Document examples: as the required Conventional Commit prefix for example-focused commits and pull request titles.

Evidence and scope

The new regression suite failed 7 of 8 tests against the unchanged example: empty choices and refused/invalid values exited successfully, while mixed invalid values were printed. This change is limited to one handwritten, generator-independent example, its dedicated new test, and a concise AGENTS.md contributor-guidance clarification. It does not modify generated SDK code, response parsing, model behavior, transport, authentication, serialization, public APIs, dependencies, or CI.

Validation

  • mise exec ruby@3.3.12 -- ./scripts/test — 1,199 tests, 10,642 assertions, 0 failures, 1 existing skip.
  • mise exec ruby@3.4.10 -- ./scripts/test — 1,199 tests, 10,642 assertions, 0 failures, 1 existing skip.
  • mise exec ruby@4.0.6 -- ./scripts/test — 1,199 tests, 10,642 assertions, 0 failures, 1 existing skip.
  • Focused example regression suite on Ruby 3.3, 3.4, and 4.0 — 8 tests, 49 assertions each.
  • TEST='test/openai/structured_outputs*_test.rb' mise exec ruby@4.0.6 -- bundle exec rake test — 11 tests, 66 assertions.
  • mise exec ruby@4.0.6 -- bundle exec rake lint — RuboCop, rubyfmt, directive validation, Sorbet, and 1,239 RBS files pass.
  • python3 -m unittest discover -s scripts/castiron -p 'test_custom_code*.py' — 51 tests pass, 1 existing skip.
  • python3 -B -I scripts/castiron/custom_code_budget.py check --repo . --base edfb30b2973d68b4a19ce3f86f1de7313f730702 --head c6d841f36e78e318841df10735dce2e187ed310e --public --out /private/tmp/openai-ruby-calendar-event-custom-budget-v2 — 2,659 / 4,000 custom lines; budget and isolation pass.
  • bundle exec rake test:examples:inventory, git diff --check, pinned-base scope review, extensive general review, and thermo-nuclear maintainability review all pass.

Local runs used the existing cached bundle for each Ruby version and TMPDIR=/private/tmp to avoid the pre-existing macOS /var versus /private/var path-alias issue in formatter tests.

@jbeckwith-oai jbeckwith-oai added the codex-maintenance Low-risk maintenance changes created by Codex label Aug 23, 2026
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

48 mixed files remain; 0 existing customizations changed.

Compared edfb30b2973dc6d841f36e78. Generated baselines verified.

48 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/responses.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

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

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

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

@jbeckwith-oai jbeckwith-oai changed the title fix(examples): validate parsed chat completion events examples: validate parsed chat completion events Aug 23, 2026
@jbeckwith-oai
jbeckwith-oai force-pushed the codex/validate-structured-chat-calendar-events branch from 84fecdc to c6d841f Compare August 23, 2026 19:46
@jbeckwith-oai
jbeckwith-oai marked this pull request as ready for review August 23, 2026 19:51
@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 23, 2026 19:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 23, 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-23T19:52:39.211922Z c6d841f Draft marked ready
🔒 Security Review Completed 2026-08-23T19:52:39.888639Z c6d841f 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.

@openai-sdks

openai-sdks Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 10.648s for Ruby SDK PR #517.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 185ms
tests/chat-completions-create.test.ts ✅ Passed 366ms
tests/chat-completions-stream.test.ts ✅ Passed 161ms
tests/files-content-binary.test.ts ✅ Passed 247ms
tests/files-create-multipart.test.ts ✅ Passed 271ms
tests/files-list-pagination.test.ts ✅ Passed 192ms
tests/initialize-config.test.ts ✅ Passed 253ms
tests/instance-isolation.test.ts ✅ Passed 240ms
tests/models-list.test.ts ✅ Passed 192ms
tests/responses-background-lifecycle.test.ts ✅ Passed 203ms
tests/responses-body-method-errors.test.ts ✅ Passed 428ms
tests/responses-cancel-timeout.test.ts ✅ Passed 214ms
tests/responses-cancel.test.ts ✅ Passed 234ms
tests/responses-compact-retries.test.ts ✅ Passed 279ms
tests/responses-compact.test.ts ✅ Passed 295ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 134ms
tests/responses-create-advanced.test.ts ✅ Passed 201ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.116s
tests/responses-create-errors.test.ts ✅ Passed 299ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 144ms
tests/responses-create-retries.test.ts ✅ Passed 396ms
tests/responses-create-stream-failures.test.ts ✅ Passed 180ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 224ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.608s
tests/responses-create-stream.test.ts ✅ Passed 129ms
tests/responses-create-terminal-states.test.ts ✅ Passed 315ms
tests/responses-create-timeout.test.ts ✅ Passed 269ms
tests/responses-create.test.ts ✅ Passed 293ms
tests/responses-delete.test.ts ✅ Passed 338ms
tests/responses-input-items-errors.test.ts ✅ Passed 222ms
tests/responses-input-items-list.test.ts ✅ Passed 213ms
tests/responses-input-items-options.test.ts ✅ Passed 195ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 287ms
tests/responses-input-tokens-count.test.ts ✅ Passed 288ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.302s
tests/responses-not-found-errors.test.ts ✅ Passed 349ms
tests/responses-parse.test.ts ✅ Passed 198ms
tests/responses-retrieve-retries.test.ts ✅ Passed 331ms
tests/responses-retrieve.test.ts ✅ Passed 309ms
tests/responses-stored-method-errors.test.ts ✅ Passed 820ms
tests/retry-behavior.test.ts ✅ Passed 2.974s
tests/sdk-error-shape.test.ts ✅ Passed 412ms

View OkTest run #32662578618

SDK merge (1994e6b33780) · head (c6d841f36e78) · base (edfb30b2973d) · OkTest (2b1bdfd25e98)

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

[sdk codex review] Approved at c6d841f36e78e318841df10735dce2e187ed310e after two independent, full code reviews and reconciliation of existing feedback. No actionable findings.

The example preserves refusal handling and valid-event ordering while rejecting runs with no parsed CalendarEvent. All eight regression/characterization cases were examined, including empty, refused, wrong-type, and mixed choices. The contributor-guidance change was also reviewed; no public SDK parsing or API behavior changes.

Existing hosted CI for the reviewed head merged with edfb30b2973d68b4a19ce3f86f1de7313f730702 passed on Ruby 3.3, 3.4, and 4.0: 1,199 tests and 10,643 assertions per version, with no failures, errors, or skips. Lint, type checks, packaging, Bedrock, and current required checks also passed. Source review plus existing hosted CI only; no local test execution or live-API validation.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 23, 2026
@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 24, 2026
Merged via the queue into main with commit 9775e7b Aug 24, 2026
21 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/validate-structured-chat-calendar-events branch August 24, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-maintenance Low-risk maintenance changes created by Codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants