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

    • Handle anyOf unions in OpenAI structured output conversion; oneOf now triggers a clear error.
  • Bug Fixes

    • Updated public model names for OpenAI integrations.
  • Tests

    • Added unit tests for schema conversion, null handling, unions, and array/object behaviors.
  • Documentation

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

    • Added version bump 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, extends OpenAI structured-output schema conversion to handle unions (anyOf/oneOf) with tests, 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
packages/typescript/ai-openai/src/model-meta.ts
Updated .name fields for chat models to match OpenAI identifiers (added -latest suffixes and changed chatgpt-4.0 β†’ chatgpt-4o-latest).
Schema conversion: union support
packages/typescript/ai-openai/src/utils/schema-converter.ts
Extended makeOpenAIStructuredOutputCompatible to recursively handle anyOf at property and root levels (apply per-variant required and 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 transformations, nested objects/arrays, and union (anyOf/oneOf) handling.
Type signature update
packages/typescript/ai/src/types.ts
Changed JSONSchema index signature from [key: string]: unknown to [key: string]: any to improve assignability of 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 (header, 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
  • harry-whorlow

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

βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The PR title directly addresses the main issue #173 about incorrect GPT-5 chat model names, which is the primary change made to the codebase.
Description check βœ… Passed The PR description follows the template structure with linked issues listed, but the description lacks specific details about what changes were made to fix these issues.
Linked Issues check βœ… Passed The PR addresses all 5 linked issues: #173 (model name fixes), #178 (JSONSchema type fix), #186 (union schema support), #187 (missing export), and #170 (removed non-existent function from docs).
Out of Scope Changes check βœ… Passed All changes are directly related to the linked issues: model name updates for #173, schema converter enhancements for #186, type signature update for #178, README removals for #170 and #187, and associated changesets.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 173-gpt-5-chat-model-names-are-incorrect

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 9ea4674

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

☁️ Nx Cloud last updated this comment at 2025-12-26 10:26:17 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-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: 9ea4674

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants