Skip to content

fix: accept string Responses structured-output tags - #617

Merged
jbeckwith-oai merged 1 commit into
mainfrom
codex/autoimprove-20260904-4-responses-string-tags
Sep 4, 2026
Merged

fix: accept string Responses structured-output tags#617
jbeckwith-oai merged 1 commit into
mainfrom
codex/autoimprove-20260904-4-responses-string-tags

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Problem

Responses structured-output preparation recognized symbol tags but missed the equivalent string tags for nested text JSON schema formats and flat function tools. A request such as type: "json_schema" or type: "function" with an OpenAI structured-output model serialized the Ruby class name instead of the model JSON schema, so returned text or tool calls had no typed parsed value.

User impact

Applications that build request hashes from JSON-like configuration can use the documented existing Responses shapes with string tag values and receive the same schema serialization and typed parsing as symbol-tag callers.

Fix

Widen the two existing Responses parser pattern matches to accept the string spellings alongside their supported symbols:

  • nested text.format.type: :json_schema or "json_schema"
  • flat tool type: :function or "function"

No global coercion or request normalization was added. Existing name/default-name, strictness, sibling options, raw schema, mutation, and retrieval-hint behavior remain on their current paths.

Regression coverage

Added a network-disabled public client.responses.create WebMock test file that inspects wire JSON and typed results for:

  • string versus symbol nested text tags
  • string versus symbol flat function-tool tags
  • both string-tag paths together
  • the existing default tool-name behavior

The safe synthetic red probe showed symbol forms sending object schemas and returning typed values, while string forms sent class-name strings and returned nil parsed fields. After the fix, both forms send equivalent schemas and return typed values. No live API calls were made.

Scope and non-goals

Only lib/openai/helpers/structured_output/response_parser.rb and the new focused test file changed. This does not add public APIs, model features, Sorbet behavior, general transport coercion, strictness changes, streaming-state changes, generated-file edits, dependencies, schema caching, recursion work, or broader normalization.

Validation

  • mise exec ruby@4.0.6 -- bundle exec ruby -Itest test/openai/helpers/responses_string_type_hints_test.rb — 4 runs, 22 assertions, 0 failures
  • mise exec ruby@4.0.6 -- bundle exec ruby -Itest test/openai/helpers/structured_output_api_names_test.rb — 40 runs, 133 assertions, 0 failures
  • mise exec ruby@4.0.6 -- bundle exec ruby -Itest test/openai/resources/responses/streaming_test.rb — 33 runs, 122 assertions, 0 failures
  • mise exec ruby@4.0.6 -- bundle exec rake lint — 2,870 RuboCop files clean; RBS validation and Sorbet examples clean
  • serialized TEST_API_BASE_URL=... mise exec ruby@4.0.6 -- bundle exec rake test — 1,627 runs, 14,451 assertions, 0 failures, 0 errors, 1 skip
  • trusted public custom-code budget on committed candidate — 3,363 / 4,000 lines, 637 headroom

Review and security

Two consecutive adversarial-review rounds completed on unchanged code, each with two new independent read-only reviewers; all four reviews were clean. A bounded security review found no new credential, transport, logging, dependency, or deserialization boundary: the change only recognizes existing request tags and uses the existing schema conversion and model-registration paths.

Limitations

The tests use safe synthetic WebMock responses and do not claim a live-server rejection or make live API requests.

@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner September 4, 2026 16:43
@jbeckwith-oai jbeckwith-oai added codex-maintenance Low-risk maintenance changes created by Codex autoimprove Automated repository-health improvements labels Sep 4, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-09-04T16:44:20.923496Z 2bebb26 PR opened
🔒 Security Review Completed 2026-09-04T16:46:00.147902Z 2bebb26 PR opened
ℹ️ 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 Sep 4, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 7.482s for Ruby SDK PR #617.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 116ms
tests/chat-completions-create.test.ts ✅ Passed 173ms
tests/chat-completions-stream.test.ts ✅ Passed 84ms
tests/files-content-binary.test.ts ✅ Passed 110ms
tests/files-create-multipart.test.ts ✅ Passed 114ms
tests/files-list-pagination.test.ts ✅ Passed 108ms
tests/initialize-config.test.ts ✅ Passed 128ms
tests/instance-isolation.test.ts ✅ Passed 137ms
tests/models-list.test.ts ✅ Passed 124ms
tests/responses-background-lifecycle.test.ts ✅ Passed 114ms
tests/responses-body-method-errors.test.ts ✅ Passed 255ms
tests/responses-cancel-timeout.test.ts ✅ Passed 216ms
tests/responses-cancel.test.ts ✅ Passed 172ms
tests/responses-compact-retries.test.ts ✅ Passed 167ms
tests/responses-compact.test.ts ✅ Passed 143ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 77ms
tests/responses-create-advanced.test.ts ✅ Passed 133ms
tests/responses-create-disconnect.test.ts ✅ Passed 962ms
tests/responses-create-errors.test.ts ✅ Passed 230ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 116ms
tests/responses-create-retries.test.ts ✅ Passed 147ms
tests/responses-create-stream-failures.test.ts ✅ Passed 101ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 200ms
tests/responses-create-stream-wire.test.ts ✅ Passed 1.813s
tests/responses-create-stream.test.ts ✅ Passed 88ms
tests/responses-create-terminal-states.test.ts ✅ Passed 186ms
tests/responses-create-timeout.test.ts ✅ Passed 207ms
tests/responses-create.test.ts ✅ Passed 92ms
tests/responses-delete.test.ts ✅ Passed 82ms
tests/responses-input-items-errors.test.ts ✅ Passed 119ms
tests/responses-input-items-list.test.ts ✅ Passed 128ms
tests/responses-input-items-options.test.ts ✅ Passed 84ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 218ms
tests/responses-input-tokens-count.test.ts ✅ Passed 143ms
tests/responses-malformed-inputs.test.ts ✅ Passed 1.502s
tests/responses-not-found-errors.test.ts ✅ Passed 179ms
tests/responses-parse.test.ts ✅ Passed 150ms
tests/responses-retrieve-retries.test.ts ✅ Passed 197ms
tests/responses-retrieve.test.ts ✅ Passed 144ms
tests/responses-stored-method-errors.test.ts ✅ Passed 559ms
tests/retry-behavior.test.ts ✅ Passed 3.09s
tests/sdk-error-shape.test.ts ✅ Passed 373ms

View OkTest run #33896699202

SDK merge (392e51944fda) · head (2bebb266b742) · base (59e0643dbb37) · OkTest (2b1bdfd25e98)

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

47 mixed files remain; 0 existing customizations changed.

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

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

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

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

Handling the string spellings at the two parser pattern boundaries is the right scope: it restores JSON-like request parity without globally coercing caller input. The wire-equality assertions plus typed parsed-result checks cover both serialization and model registration.

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

The parser now accepts both serialized and symbol forms at the two structured-output boundaries, and the focused request/response tests cover preservation and typed hydration across text and tools.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 4322e07 Sep 4, 2026
20 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/autoimprove-20260904-4-responses-string-tags branch September 4, 2026 17:13
@openai-sdks openai-sdks Bot mentioned this pull request Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoimprove Automated repository-health improvements codex-maintenance Low-risk maintenance changes created by Codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants