fix(openai-base): send Responses verbosity as text.verbosity #2305
main fromrefs/pull/2305/head·opened View on GitHubFixes #2291
🎯 Changes#
modelOptions.verbosity on an OpenAI Responses chat is documented as text.verbosity, but the request sent a root verbosity field, which the Responses API does not define. With outputSchema, the adapter also replaced text with { format }, so a caller text.verbosity was dropped. Only a plain request that already used text.verbosity worked.
A root verbosity now moves onto text.verbosity. An existing text.verbosity wins. text.format is merged onto the caller text in the combined chat request, in structuredOutput, and in structuredOutputStream. Other root fields, such as temperature, stay where they are.
No docs change. OpenAIBaseOptions.verbosity already documents text.verbosity.
Root cause#
Issue. Callers of createOpenaiChat who set modelOptions.verbosity send it as an unsupported root field instead of text.verbosity. With outputSchema, a caller text.verbosity is dropped too.
Cause. mapOptionsToRequest spreads modelOptions onto the Responses body, so verbosity stays at the root. The same method, structuredOutput, and structuredOutputStream then set text to { format } and replace any caller text.
Fix. Move a root verbosity onto text.verbosity, and merge format onto the existing text object.
Possible alternatives#
- Drop
verbosityfrom the options type. Callers would pass onlytext.verbosity. That is a breaking change, and the typed field already documents the wire shape. - Leave the root field and only merge
text. Cases B and D from the issue would work. Cases A and C would still send a root field the API does not define.
Testing#
vitest run tests/responses-text.test.ts -t text.verbosity in @tanstack/openai-base: 5 failed before the adapter change, 0 failed after it (6 passed).
vitest run tests/responses-text.test.ts tests/responses-structured-output-stream.test.ts: 139 passed after the change.
tsc --noEmit in @tanstack/openai-base passed. pnpm run test:pr was not run.
- On current main, send
modelOptions: { verbosity: "low" }with and withoutoutputSchema. - The body has a root
verbosity, and withoutputSchemait has notext.verbosity. - On this branch, the same calls send
text.verbosity: "low"and, when a schema is set,text.formatbeside it.
The new cases live in packages/openai-base/tests/responses-text.test.ts.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Risk / rollback#
Low risk. Revert this commit to restore the previous request shape. Callers who set a root verbosity will see that value under text instead.
This change was prepared with an AI coding assistant.
Summary by CodeRabbit#
- Bug Fixes
- Responses API requests now send verbosity settings in the expected text options, including when schema-based structured output is used.
- Explicit text-level verbosity settings are preserved and take precedence over top-level settings.
- 1
tanstack-source added labelsbug
No actionable comments were generated in the recent review.
Walkthrough
-
The Responses text adapter maps root-level
modelOptions.verbositytotext.verbosity. It preserves existing text options when adding schema-basedtext.format. Tests cover streaming and non-streaming requests.Changes: Responses text option handling
Layer / File(s) Summary Verbosity mapping and schema format merging
packages/openai-base/src/adapters/responses-text.ts,packages/openai-base/tests/responses-text.test.ts,.changeset/responses-text-verbosity.mdThe adapter maps root-level verbosity to text.verbosityunless nested verbosity is set. Structured-output requests mergetext.formatwith existing text options. Tests cover the mapping and preservation behavior. The changeset records a patch release.Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
tombeckenham,alemtuzlak
Merge Risk:
Minimal · up to4e147-
This change sends verbosity in the nested text field that the Responses API expects, and keeps caller text options when a schema format is added. Targeted tests cover the changed paths, and no actionable merge-blocking risk is evident.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: the Responses verbosity value is now sent as text.verbosity. It fits the changeset, the adapter change in responses-text.ts, and the PR objectives. It also uses the co… Description check The description covers the change, root cause, fix, alternatives considered, testing results, and risk. It links issue #2291and states the changeset was added. Two checklist items remain unchecked: t…Linked Issues check [ #2291] The only directly linked issue is open and has coding requirements. (1) Cases A and C require a rootmodelOptions.verbosityto be sent astext.verbosity. The PR summary states that `mapOpt…Out of Scope Changes check The changed files are packages/openai-base/src/adapters/responses-text.ts, its test filepackages/openai-base/tests/responses-text.test.ts, and a patch changeset for@tanstack/openai-base. The s…Full details: Title check
-
Explanation
The title names the main change: the Responses verbosity value is now sent as text.verbosity. It fits the changeset, the adapter change in responses-text.ts, and the PR objectives. It also uses the conventional fix(openai-base) prefix and stays under one sentence.
Full details: Description check
-
Explanation
The description covers the change, root cause, fix, alternatives considered, testing results, and risk. It links issue
#2291and states the changeset was added. Two checklist items remain unchecked: the test:pr run was not performed, and the AI-assistance understanding item is unchecked. The description says a test run was not performed, so the unchecked item is accurate. The Docs item is also unchecked, which matches the stated no-docs-change reasoning. Overall the template is substantially complete.
Full details: Linked Issues check
-
Explanation
[
#2291] The only directly linked issue is open and has coding requirements. (1) Cases A and C require a rootmodelOptions.verbosityto be sent astext.verbosity. The PR summary states thatmapOptionsToRequestnow moves rootverbosityontotext.verbosity, and that an existingtext.verbositytakes precedence. (2) Cases C and D requiretext.formatto be merged onto the caller'stextinstead of replacing it. The PR summary states thatformatis merged inmapOptionsToRequest,structuredOutput, andstructuredOutputStream, the three locations named in the issue. (3) Other root fields such astemperaturestay unchanged. Tests added inpackages/openai-base/tests/responses-text.test.tscover these cases forchatStream,structuredOutput, andstructuredOutputStream, and the author reports 6 passing targeted tests and 139 passing tests across the two test files. Limitation: the source diff ofresponses-text.tscould not be read in this review, so the code behavior rests on the PR summary and the author's test report. The head file was readable but the relevant lines were beyond the returned range.
Full details: Out of Scope Changes check
-
Explanation
The changed files are
packages/openai-base/src/adapters/responses-text.ts, its test filepackages/openai-base/tests/responses-text.test.ts, and a patch changeset for@tanstack/openai-base. The source change moves rootverbositytotext.verbosityand mergestext.formatin the three request paths named by#2291. The tests exercise those same paths. The changeset documents the same behavior for the published package. The PR description states that no docs change is needed becauseOpenAIBaseOptions.verbosityalready documentstext.verbosity. No unrelated behavior change appears in the PR summary. The summary states that other root fields are unchanged. Limitation: the source diff could not be read, so this verdict relies on the change summary.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/ai
- Branch: main
- File: .coderabbit.yaml
- Commit: 840ea56
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a460479f-4c8a-428b-a4a7-6cac8012ac33
Commits-
Reviewing files that changed from the base of the PR and between 840ea56621f4c32de4359849a0beaa343db60fe3 and 4e147af1e2edcc440fd51947da5fd4240d3972c9.
Files selected for processing: 3-
.changeset/responses-text-verbosity.mdpackages/openai-base/src/adapters/responses-text.tspackages/openai-base/tests/responses-text.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
-
github-actions[bot](GitHub profile, opens in a new tab) assignedAlemTuzlak
Thanks for the PR, @pcbeingused33! 🙌 @AlemTuzlak will take a look.
Automated pre-review checks
- ✅ CI passing
- ✅ No merge conflicts
- ✅ Changeset present
- ⚠️ No E2E test changes detected — behavior changes need coverage under
testing/e2e/(see CONTRIBUTING)
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 4e147af1e2edcc440fd51947da5fd4240d3972c9
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR