Skip to content
Source
Sign inSign up
TanStack/ai

fix(openai-base): send Responses verbosity as text.verbosity #2305

Openpcbeingused33(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2305/headopened View on GitHub

pcbeingused33(GitHub profile, opens in a new tab)commented

Fixes #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 verbosity from the options type. Callers would pass only text.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.

  1. On current main, send modelOptions: { verbosity: "low" } with and without outputSchema.
  2. The body has a root verbosity, and with outputSchema it has no text.verbosity.
  3. On this branch, the same calls send text.verbosity: "low" and, when a schema is set, text.format beside 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. 🦋 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
      NameType
      @tanstack/openai-basePatch

      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

    2. tanstack-source added labelsbug

    3. tanstack-sourceBotcommented Only here. This is not on GitHub.

      This looks useful. It maps root verbosity onto text.verbosity and keeps text.format. Related open issue: #2292. The PR links #2291.

      TanStack Source bot, value agent

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The Responses text adapter maps root-level modelOptions.verbosity to text.verbosity. It preserves existing text options when adding schema-based text.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.md
      The adapter maps root-level verbosity to text.verbosity unless nested verbosity is set. Structured-output requests merge text.format with 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 to 4e147

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe description covers the change, root cause, fix, alternatives considered, testing results, and risk. It links issue #2291 and states the changeset was added. Two checklist items remain unchecked: t…
      Linked Issues checkPassed[#2291] The only directly linked issue is open and has coding requirements. (1) Cases A and C require a root modelOptions.verbosity to be sent as text.verbosity. The PR summary states that `mapOpt…
      Out of Scope Changes checkPassedThe changed files are packages/openai-base/src/adapters/responses-text.ts, its test file packages/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 #2291 and 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 root modelOptions.verbosity to be sent as text.verbosity. The PR summary states that mapOptionsToRequest now moves root verbosity onto text.verbosity, and that an existing text.verbosity takes precedence. (2) Cases C and D require text.format to be merged onto the caller's text instead of replacing it. The PR summary states that format is merged in mapOptionsToRequest, structuredOutput, and structuredOutputStream, the three locations named in the issue. (3) Other root fields such as temperature stay unchanged. Tests added in packages/openai-base/tests/responses-text.test.ts cover these cases for chatStream, structuredOutput, and structuredOutputStream, and the author reports 6 passing targeted tests and 139 passing tests across the two test files. Limitation: the source diff of responses-text.ts could 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 file packages/openai-base/tests/responses-text.test.ts, and a patch changeset for @tanstack/openai-base. The source change moves root verbosity to text.verbosity and merges text.format in 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 because OpenAIBaseOptions.verbosity already documents text.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.

      Share

      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.md
      • packages/openai-base/src/adapters/responses-text.ts
      • packages/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.

    5. 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)
      Automated triage — a human review follows.
    6. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

Sign in to join this conversation.