Skip to content

Conversation

@AlemTuzlak
Copy link
Contributor

@AlemTuzlak AlemTuzlak commented Dec 26, 2025

🎯 Changes

Fixes #173
Fixes #178
Fixes #186
Fixes #187
Fixes #170

βœ… Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

πŸš€ Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • OpenAI structured-output conversion now supports anyOf unions (oneOf yields a clear error).
    • Exposed updated list of OpenAI chat models.
  • Bug Fixes

    • Normalized public OpenAI model names to their latest identifiers.
  • Tests

    • Added unit tests for schema conversion, null handling, unions, and arrays/objects.
  • Documentation

    • Removed "Bonus: TanStack Start Integration" sections from multiple READMEs.
  • Chores

    • Added changesets and relaxed JSONSchema index typing for compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@AlemTuzlak AlemTuzlak linked an issue Dec 26, 2025 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

πŸ“ Walkthrough

Walkthrough

This PR renames OpenAI chat model public names, exports OPENAI_CHAT_MODELS, extends OpenAI structured-output schema conversion to handle unions (anyOf) with explicit errors for unsupported oneOf, adds unit tests for the converter, relaxes the JSONSchema index signature for assignability, removes "TanStack Start Integration" sections from multiple READMEs, and adds changeset files for patch bumps.

Changes

Cohort / File(s) Summary
Model name corrections & export
packages/typescript/ai-openai/src/model-meta.ts, packages/typescript/ai-openai/src/index.ts
Updated chat model .name fields to match OpenAI identifiers (added -latest suffixes and chatgpt-4.0 β†’ chatgpt-4o-latest) and re-exported OPENAI_CHAT_MODELS.
Schema conversion: union support
packages/typescript/ai-openai/src/utils/schema-converter.ts
Extended makeOpenAIStructuredOutputCompatible to handle anyOf recursively at property and root levels (apply per-variant required / additionalProperties: false); throws on unsupported oneOf.
Schema converter tests
packages/typescript/ai-openai/tests/schema-converter.test.ts
Added tests for transformNullsToUndefined and makeOpenAIStructuredOutputCompatible, covering null→undefined, nested objects/arrays, and union (anyOf/oneOf) cases.
Type signature update
packages/typescript/ai/src/types.ts
Changed JSONSchema index signature from [key: string]: unknown to [key: string]: any to improve assignability with custom schema shapes.
README removals (TanStack Start Integration)
README.md, packages/typescript/ai-client/README.md, packages/typescript/ai-devtools/README.md, packages/typescript/ai-gemini/README.md, packages/typescript/ai-ollama/README.md, packages/typescript/ai-openai/README.md, packages/typescript/ai-react-ui/README.md, packages/typescript/ai-react/README.md, packages/typescript/ai/README.md, packages/typescript/react-ai-devtools/README.md, packages/typescript/solid-ai-devtools/README.md
Removed the entire "Bonus: TanStack Start Integration" section (headers, explanatory text, and code examples) from multiple package READMEs β€” documentation-only deletions.
Changeset / release metadata
.changeset/full-stars-drop.md, .changeset/mighty-gifts-enter.md
Added/updated changeset files marking patch bumps for multiple @tanstack packages with short notes (includes @tanstack/ai-openai, @tanstack/ai, @tanstack/ai-solid, devtools and UI packages).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jherr

Poem

🐰 I hopped through names and schema trees,

I nudged unions gently with my paws,
Tests now hum like carrot breeze,
Readmes trimmed, neat as springtime laws,
A tiny hop β€” then nap because.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description references five linked issues (#173, #178, #186, #187, #170) that address various bugs, but lacks implementation details explaining what code changes fix each issue. The checklist items are unchecked, which appears incomplete for a submission. Add a detailed 'Changes' section explaining how each linked issue is addressed in the code (e.g., model name updates, schema converter changes, export additions, README removals).
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title concisely describes the main change: fixing GPT-5 chat model names (e.g., changing 'gpt-5.2-chat' to 'gpt-5.2-chat-latest') which is the primary focus across the changeset.
Linked Issues check βœ… Passed Code changes address all five linked issues: model names updated (#173), JSONSchema index signature changed to 'any' (#178), schema-converter expanded for unions (#186), README sections removed (#170), and changes appear comprehensive for addressing all issues.
Out of Scope Changes check βœ… Passed Changes include model name fixes, schema converter updates, type definition changes, export additions, test additions, and README cleanupβ€”all directly supporting the five linked issues with no detectable out-of-scope modifications.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • πŸ“ Generate docstrings

πŸ“œ Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 9ea4674 and cda4846.

πŸ“’ Files selected for processing (1)
  • packages/typescript/ai-openai/src/index.ts
🧰 Additional context used
πŸ““ Path-based instructions (3)
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from /adapters subpath rather than monolithic adapters
Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with toolDefinition() and Zod schema inference
Implement isomorphic tool system using toolDefinition() with .server() and .client() implementations for dual-environment execution
Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses

Files:

  • packages/typescript/ai-openai/src/index.ts
packages/typescript/*/src/index.ts

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Export tree-shakeable adapters with clear subpath exports in package.json (e.g., @tanstack/ai/adapters, @tanstack/ai-openai/adapters) to minimize bundle size

Files:

  • packages/typescript/ai-openai/src/index.ts
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Use camelCase for function and variable names throughout the codebase

Files:

  • packages/typescript/ai-openai/src/index.ts
🧠 Learnings (4)
πŸ“š Learning: 2025-12-27T20:22:51.232Z
Learnt from: harry-whorlow
Repo: TanStack/ai PR: 117
File: packages/typescript/ai-ollama/src/meta/model-meta-gpt-oss.ts:92-97
Timestamp: 2025-12-27T20:22:51.232Z
Learning: In the ai-ollama package's model-meta files (packages/typescript/ai-ollama/src/meta/model-meta-*.ts), capability-related comments follow a standard template format across all files for consistency, even if the comment text doesn't precisely match individual model capabilities. This is an intentional design choice to maintain uniformity across the codebase.

Applied to files:

  • packages/typescript/ai-openai/src/index.ts
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/model-meta.ts : Maintain model metadata files that define provider options and capabilities per model for per-model type safety

Applied to files:

  • packages/typescript/ai-openai/src/index.ts
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle size

Applied to files:

  • packages/typescript/ai-openai/src/index.ts
πŸ“š Learning: 2025-12-27T21:39:29.563Z
Learnt from: harry-whorlow
Repo: TanStack/ai PR: 117
File: packages/typescript/ai-ollama/src/meta/model-meta-llama-guard3.ts:70-75
Timestamp: 2025-12-27T21:39:29.563Z
Learning: The standard template comments in ai-ollama model-meta files (like "Models with text, image, audio, video (no document)") should not be modified to match individual model capabilities, as they are intentionally kept uniform across all model-meta-*.ts files for consistency, regardless of what each specific model actually supports.

Applied to files:

  • packages/typescript/ai-openai/src/index.ts
πŸ”‡ Additional comments (1)
packages/typescript/ai-openai/src/index.ts (1)

87-87: LGTM! Export addresses user request.

The addition of OPENAI_CHAT_MODELS export is consistent with existing model constant exports and directly addresses stephansama's request to make chat models publicly accessible. The change maintains the established pattern and supports tree-shaking.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@AlemTuzlak AlemTuzlak mentioned this pull request Dec 26, 2025
2 tasks
@nx-cloud
Copy link

nx-cloud bot commented Dec 26, 2025

View your CI Pipeline Execution β†— for commit f9239fb

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... βœ… Succeeded 2m 40s View β†—
nx run-many --targets=build --exclude=examples/** βœ… Succeeded 1m 5s View β†—

☁️ Nx Cloud last updated this comment at 2026-01-05 16:13:41 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 26, 2025

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@188

@tanstack/ai-anthropic

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@188

@tanstack/ai-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@188

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@188

@tanstack/ai-gemini

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@188

@tanstack/ai-ollama

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@188

@tanstack/ai-openai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@188

@tanstack/ai-preact

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@188

@tanstack/ai-react

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@188

@tanstack/ai-react-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@188

@tanstack/ai-solid

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@188

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@188

@tanstack/ai-svelte

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@188

@tanstack/ai-vue

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@188

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@188

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@188

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@188

commit: f9239fb

prop.items.required || [],
),
}
} else if (prop.anyOf || prop.oneOf) {
Copy link

Choose a reason for hiding this comment

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

Just to notice, oneOf is not part of the open ai supported types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah you're right, thank you! Wanted to cover both while I was at it πŸ˜“

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a866721 and 433e57a.

πŸ“’ Files selected for processing (5)
  • .changeset/full-stars-drop.md
  • packages/typescript/ai-openai/src/model-meta.ts
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
  • packages/typescript/ai-openai/tests/schema-converter.test.ts
  • packages/typescript/ai/src/types.ts
🧰 Additional context used
πŸ““ Path-based instructions (4)
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from /adapters subpath rather than monolithic adapters
Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with toolDefinition() and Zod schema inference
Implement isomorphic tool system using toolDefinition() with .server() and .client() implementations for dual-environment execution
Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses

Files:

  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai-openai/src/model-meta.ts
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
  • packages/typescript/ai-openai/tests/schema-converter.test.ts
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Use camelCase for function and variable names throughout the codebase

Files:

  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai-openai/src/model-meta.ts
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
  • packages/typescript/ai-openai/tests/schema-converter.test.ts
packages/typescript/*/src/model-meta.ts

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Maintain model metadata files that define provider options and capabilities per model for per-model type safety

Files:

  • packages/typescript/ai-openai/src/model-meta.ts
**/*.test.ts

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Write unit tests using Vitest alongside source files with .test.ts naming convention

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🧠 Learnings (3)
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle size

Applied to files:

  • packages/typescript/ai/src/types.ts
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with `toolDefinition()` and Zod schema inference

Applied to files:

  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/model-meta.ts : Maintain model metadata files that define provider options and capabilities per model for per-model type safety

Applied to files:

  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai-openai/src/model-meta.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
πŸ”‡ Additional comments (7)
packages/typescript/ai/src/types.ts (1)

63-63: LGTM: Index signature change improves type compatibility.

Changing from unknown to any resolves type assignment issues when using custom JSON Schema definitions with toolDefinition(), as noted in issue #178. While this reduces type safety, it's appropriate for JSON Schema's dynamic nature and aligns with the extensibility goal noted in the comment.

packages/typescript/ai-openai/src/utils/schema-converter.ts (3)

64-83: LGTM: Property-level union handling correctly added.

The new logic recursively transforms anyOf and oneOf properties, ensuring each union variant receives proper OpenAI structured output compatibility (including additionalProperties: false). This addresses issue #186.


115-120: LGTM: Schema-level anyOf handling implemented correctly.

Each variant in anyOf unions is recursively transformed with its own required array, ensuring OpenAI compatibility for union schemas.


122-127: LGTM: Schema-level oneOf handling mirrors anyOf approach.

The oneOf handling correctly applies the same recursive transformation pattern as anyOf, ensuring discriminated union schemas are compatible with OpenAI's requirements.

packages/typescript/ai-openai/tests/schema-converter.test.ts (2)

7-29: LGTM: Comprehensive tests for transformNullsToUndefined.

The test suite covers null-to-undefined conversion, nested object pruning, array handling, and value preservation. All test cases are well-structured and validate the expected behavior.


31-183: LGTM: Thorough test coverage for OpenAI schema transformation.

The test suite validates all key behaviors:

  • additionalProperties: false enforcement
  • Required property augmentation
  • Nullable optional fields
  • Union type handling (anyOf/oneOf) with recursive transformation
  • Nested structures within unions
  • Array item schemas

All tests are well-structured and align with the implementation changes for structured output union support.

packages/typescript/ai-openai/src/model-meta.ts (1)

136-136: Verify updated model names match OpenAI's API.

The model name updates to gpt-5.2-chat-latest, gpt-5.1-chat-latest, and chatgpt-4o-latest align with valid OpenAI API identifiers as of December 2025. However, verify that any hardcoded references to the old model names in examples, tests, or documentation are also updated.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/typescript/ai-openai/tests/schema-converter.test.ts (2)

7-29: Consider adding edge case tests for deeply nested structures.

The current test coverage is solid for the core functionality. However, consider adding tests for:

  • Deeply nested structures (3+ levels of nesting)
  • Empty objects and arrays
  • Mixed arrays containing objects, arrays, and primitives

These additions would strengthen confidence in the recursive transformation logic.

πŸ’‘ Example additional test cases
+  it('should handle deeply nested structures', () => {
+    const input = {
+      level1: {
+        level2: {
+          level3: { value: null, keep: 'this' }
+        }
+      }
+    }
+    const result = transformNullsToUndefined(input)
+    expect(result).toEqual({ level1: { level2: { level3: { keep: 'this' } } } })
+  })
+
+  it('should handle empty objects and arrays', () => {
+    expect(transformNullsToUndefined({})).toEqual({})
+    expect(transformNullsToUndefined([])).toEqual([])
+  })

31-154: Add test coverage for root-level anyOf and additional type scenarios.

The implementation (per relevant code snippets) handles root-level anyOf schemas where the schema itself contains an anyOf array, not just anyOf in properties. This important case is not tested.

Additionally, the optional-fields-nullable test (lines 59-72) only covers string types. Other primitive types and edge cases should be verified.

πŸ”Ž Suggested additional test cases
it('should handle root-level anyOf schemas', () => {
  const schema = {
    anyOf: [
      {
        type: 'object',
        properties: { a: { type: 'string' } },
        required: ['a'],
      },
      {
        type: 'object',
        properties: { b: { type: 'number' } },
        required: ['b'],
      },
    ],
  }

  const result = makeOpenAIStructuredOutputCompatible(schema)
  
  // Each root-level anyOf variant should have additionalProperties: false
  expect(result.anyOf[0].additionalProperties).toBe(false)
  expect(result.anyOf[1].additionalProperties).toBe(false)
  expect(result.anyOf).toHaveLength(2)
})

it('should handle nullable optional fields of different types', () => {
  const schema = {
    type: 'object',
    properties: {
      optString: { type: 'string' },
      optNumber: { type: 'number' },
      optBoolean: { type: 'boolean' },
      optArray: { type: 'array', items: { type: 'string' } },
    },
    required: [],
  }

  const result = makeOpenAIStructuredOutputCompatible(schema, [])
  
  expect(result.properties.optString.type).toEqual(['string', 'null'])
  expect(result.properties.optNumber.type).toEqual(['number', 'null'])
  expect(result.properties.optBoolean.type).toEqual(['boolean', 'null'])
  expect(result.properties.optArray.type).toEqual(['array', 'null'])
})

Based on relevant code snippets showing that makeOpenAIStructuredOutputCompatible handles root-level anyOf schemas.

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 433e57a and 99203e1.

πŸ“’ Files selected for processing (14)
  • .changeset/mighty-gifts-enter.md
  • README.md
  • packages/typescript/ai-client/README.md
  • packages/typescript/ai-devtools/README.md
  • packages/typescript/ai-gemini/README.md
  • packages/typescript/ai-ollama/README.md
  • packages/typescript/ai-openai/README.md
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
  • packages/typescript/ai-openai/tests/schema-converter.test.ts
  • packages/typescript/ai-react-ui/README.md
  • packages/typescript/ai-react/README.md
  • packages/typescript/ai/README.md
  • packages/typescript/react-ai-devtools/README.md
  • packages/typescript/solid-ai-devtools/README.md
πŸ’€ Files with no reviewable changes (11)
  • packages/typescript/ai-client/README.md
  • README.md
  • packages/typescript/solid-ai-devtools/README.md
  • packages/typescript/ai-openai/README.md
  • packages/typescript/ai-react/README.md
  • packages/typescript/ai-gemini/README.md
  • packages/typescript/ai-react-ui/README.md
  • packages/typescript/react-ai-devtools/README.md
  • packages/typescript/ai-ollama/README.md
  • packages/typescript/ai-devtools/README.md
  • packages/typescript/ai/README.md
βœ… Files skipped from review due to trivial changes (1)
  • .changeset/mighty-gifts-enter.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
🧰 Additional context used
πŸ““ Path-based instructions (3)
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from /adapters subpath rather than monolithic adapters
Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with toolDefinition() and Zod schema inference
Implement isomorphic tool system using toolDefinition() with .server() and .client() implementations for dual-environment execution
Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
**/*.test.ts

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Write unit tests using Vitest alongside source files with .test.ts naming convention

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Use camelCase for function and variable names throughout the codebase

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🧠 Learnings (1)
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with `toolDefinition()` and Zod schema inference

Applied to files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🧬 Code graph analysis (1)
packages/typescript/ai-openai/tests/schema-converter.test.ts (1)
packages/typescript/ai-openai/src/utils/schema-converter.ts (2)
  • transformNullsToUndefined (12-35)
  • makeOpenAIStructuredOutputCompatible (48-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
πŸ”‡ Additional comments (2)
packages/typescript/ai-openai/tests/schema-converter.test.ts (2)

1-5: LGTM! Clean imports and proper test setup.

The imports follow the coding guidelines (Vitest for unit tests with .test.ts naming) and correctly reference the source functions.


103-133: Good coverage of nested object transformation.

This test effectively verifies the recursive transformation of nested objects within anyOf variants. The assertions check both the variant level and the nested object level, which is excellent.

AlemTuzlak and others added 5 commits December 26, 2025 11:13
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@AlemTuzlak AlemTuzlak requested a review from a team December 26, 2025 10:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/typescript/ai-openai/tests/schema-converter.test.ts (2)

74-140: LGTM! anyOf handling is thoroughly tested.

The anyOf tests comprehensively verify:

  • Recursive transformation of union variants
  • additionalProperties: false on each variant
  • Preservation of required fields through transformation
  • Deep nesting within union types

Consider adding an assertion for the nested object's required array in the second test for complete verification:

Optional enhancement
   const result = makeOpenAIStructuredOutputCompatible(schema, ['data'])

   // The nested object inside anyOf variant should also have additionalProperties: false
   expect(result.properties.data.anyOf[0].additionalProperties).toBe(false)
   expect(
     result.properties.data.anyOf[0].properties.nested.additionalProperties,
   ).toBe(false)
+  expect(
+    result.properties.data.anyOf[0].properties.nested.required,
+  ).toEqual(['x'])

31-187: Consider adding tests for additional edge cases.

The current test suite covers the main functionality well. For more comprehensive coverage, consider adding tests for:

  1. Root-level unions: anyOf/oneOf at the schema root rather than within properties
  2. Type arrays: Fields with type: ['string', 'number'] or types that already include 'null'
  3. Optional fields within anyOf variants: Verify nullable transformation applies recursively
Example tests for edge cases
it('should handle anyOf at root level', () => {
  const schema = {
    anyOf: [
      {
        type: 'object',
        properties: { a: { type: 'string' } },
        required: ['a'],
      },
      {
        type: 'object',
        properties: { b: { type: 'number' } },
        required: ['b'],
      },
    ],
  }

  const result = makeOpenAIStructuredOutputCompatible(schema, [])
  expect(result.anyOf[0].additionalProperties).toBe(false)
  expect(result.anyOf[1].additionalProperties).toBe(false)
})

it('should handle fields with existing type arrays', () => {
  const schema = {
    type: 'object',
    properties: {
      multiType: { type: ['string', 'number'] },
      alreadyNullable: { type: ['string', 'null'] },
    },
    required: [],
  }

  const result = makeOpenAIStructuredOutputCompatible(schema, [])
  expect(result.properties.multiType.type).toEqual(['string', 'number', 'null'])
  expect(result.properties.alreadyNullable.type).toEqual(['string', 'null'])
})
πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between ef31160 and 9ea4674.

πŸ“’ Files selected for processing (2)
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/typescript/ai-openai/src/utils/schema-converter.ts
🧰 Additional context used
πŸ““ Path-based instructions (3)
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from /adapters subpath rather than monolithic adapters
Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with toolDefinition() and Zod schema inference
Implement isomorphic tool system using toolDefinition() with .server() and .client() implementations for dual-environment execution
Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
**/*.test.ts

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Write unit tests using Vitest alongside source files with .test.ts naming convention

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (CLAUDE.md)

Use camelCase for function and variable names throughout the codebase

Files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🧠 Learnings (1)
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with `toolDefinition()` and Zod schema inference

Applied to files:

  • packages/typescript/ai-openai/tests/schema-converter.test.ts
🧬 Code graph analysis (1)
packages/typescript/ai-openai/tests/schema-converter.test.ts (1)
packages/typescript/ai-openai/src/utils/schema-converter.ts (2)
  • transformNullsToUndefined (12-35)
  • makeOpenAIStructuredOutputCompatible (48-134)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test
πŸ”‡ Additional comments (3)
packages/typescript/ai-openai/tests/schema-converter.test.ts (3)

7-29: LGTM! Comprehensive coverage of null transformation.

The test suite thoroughly covers the key behaviors of transformNullsToUndefined:

  • Primitive null conversion to undefined
  • Field pruning for null values in objects (absent rather than undefined)
  • Array element handling (null becomes undefined in place)
  • Preservation of non-null values

31-72: LGTM! Core transformation behaviors are well tested.

These tests effectively verify the fundamental OpenAI schema compatibility transformations:

  • Enforcement of additionalProperties: false
  • All properties made required (previously optional fields added to required array)
  • Optional fields made nullable via union types

142-187: LGTM! Array and oneOf restriction tests are correct.

These tests properly verify:

  • Recursive transformation of array item schemas
  • Explicit error on oneOf usage (unsupported by OpenAI)

The error message assertion is sufficient to identify the correct error case.

@stephansama
Copy link

would it be possible to tack on exporting the chat model names in the main index file?
image
all of the other models are exported except for the chat models

@AlemTuzlak
Copy link
Contributor Author

@stephansama mind opening up an issue? Im off this week and I'll forget this by the time I'm back πŸ˜…

1 similar comment
@AlemTuzlak
Copy link
Contributor Author

@stephansama mind opening up an issue? Im off this week and I'll forget this by the time I'm back πŸ˜…

@stephansama
Copy link

@stephansama mind opening up an issue? Im off this week and I'll forget this by the time I'm back πŸ˜…

Of course! I can also make the changes if that is permissible or just create the issue either or both

@AlemTuzlak
Copy link
Contributor Author

@stephansama added the export

@AlemTuzlak AlemTuzlak merged commit 181e0ac into main Jan 5, 2026
6 checks passed
@AlemTuzlak AlemTuzlak deleted the 173-gpt-5-chat-model-names-are-incorrect branch January 5, 2026 16:30
@harry-whorlow harry-whorlow changed the title 173 gpt 5 chat model names are incorrect fix: openAi model names and structure parsing Jan 5, 2026
@github-actions github-actions bot mentioned this pull request Jan 5, 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

5 participants