fix: openAi model names and structure parsing #188
main fromrefs/pull/188/head·merged by AlemTuzlak View on GitHub🎯 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.
- 1
View your CI Pipeline Execution ↗ for commit f9239fb12afc81b117c10ed2631c7a26e3bcce81
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:41UTC@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@188commit:
f9239fb- @@ -75,3 +75,4 @@7575 prop.items.required || [],7676 ),7777 }78+ } else if (prop.anyOf || prop.oneOf) {
Just to notice,
oneOfis not part of the open ai supported typesah you're right, thank you! Wanted to cover both while I was at it 😓
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 a8667216fd081be1629f47a531ff3a39052b1156 and 433e57ac3c4858a1c9692bb928bd4730ed65156b.
📒 Files selected for processing (5)
.changeset/full-stars-drop.mdpackages/typescript/ai-openai/src/model-meta.tspackages/typescript/ai-openai/src/utils/schema-converter.tspackages/typescript/ai-openai/tests/schema-converter.test.tspackages/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/adapterssubpath rather than monolithic adapters Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference Implement isomorphic tool system usingtoolDefinition()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 responsesFiles:
packages/typescript/ai/src/types.tspackages/typescript/ai-openai/src/model-meta.tspackages/typescript/ai-openai/src/utils/schema-converter.tspackages/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.tspackages/typescript/ai-openai/src/model-meta.tspackages/typescript/ai-openai/src/utils/schema-converter.tspackages/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.tsnaming conventionFiles:
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 sizeApplied 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 inferenceApplied to files:
packages/typescript/ai/src/types.tspackages/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 safetyApplied to files:
packages/typescript/ai/src/types.tspackages/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
unknowntoanyresolves type assignment issues when using custom JSON Schema definitions withtoolDefinition(), 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
anyOfandoneOfproperties, ensuring each union variant receives proper OpenAI structured output compatibility (includingadditionalProperties: false). This addresses issue #186.
115-120: LGTM: Schema-level anyOf handling implemented correctly.Each variant in
anyOfunions is recursively transformed with its ownrequiredarray, ensuring OpenAI compatibility for union schemas.
122-127: LGTM: Schema-level oneOf handling mirrors anyOf approach.The
oneOfhandling correctly applies the same recursive transformation pattern asanyOf, 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: falseenforcement- 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, andchatgpt-4o-latestalign 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.@@ -0,0 +1,7 @@1+---2+'@tanstack/ai-openai': patch3+'@tanstack/ai': patch4+'@tanstack/ai-solid': patch5+---6+7+Fix up model names for OpenAI and release the new response API's⚠️ Potential issue | 🟡 Minor
Fix grammatical error in changeset note.
The phrase "API's" should be "APIs" (plural, not possessive).
🔎 Proposed fix
-Fix up model names for OpenAI and release the new response API's +Fix up model names for OpenAI and release the new response APIs📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change7-Fix up model names for OpenAI and release the new response API's7+Fix up model names for OpenAI and release the new response APIs🤖 Prompt for AI Agents
In .changeset/full-stars-drop.md around line 7, there's a grammatical error using the possessive "API's" when it should be the plural "APIs"; edit that line to replace "API's" with "APIs" so the changeset note reads "release the new response APIs" (no other changes needed).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
makeOpenAIStructuredOutputCompatiblehandles 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 433e57ac3c4858a1c9692bb928bd4730ed65156b and 99203e11ab5ae15b6ddfba11636eb5e15b41ce67.
📒 Files selected for processing (14)
.changeset/mighty-gifts-enter.mdREADME.mdpackages/typescript/ai-client/README.mdpackages/typescript/ai-devtools/README.mdpackages/typescript/ai-gemini/README.mdpackages/typescript/ai-ollama/README.mdpackages/typescript/ai-openai/README.mdpackages/typescript/ai-openai/src/utils/schema-converter.tspackages/typescript/ai-openai/tests/schema-converter.test.tspackages/typescript/ai-react-ui/README.mdpackages/typescript/ai-react/README.mdpackages/typescript/ai/README.mdpackages/typescript/react-ai-devtools/README.mdpackages/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/adapterssubpath rather than monolithic adapters Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference Implement isomorphic tool system usingtoolDefinition()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 responsesFiles:
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.tsnaming conventionFiles:
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 inferenceApplied 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.tsnaming) 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.
@@ -0,0 +81,21 @@81+ type: 'object',82+ properties: { a: { type: 'string' } },83+ required: ['a'],84+ },85+ {86+ type: 'object',87+ properties: { b: { type: 'number' } },88+ required: ['b'],89+ },90+ ],91+ },92+ },93+ required: ['u'],94+ }95+96+ const result = makeOpenAIStructuredOutputCompatible(schema, ['u'])97+98+ // Each variant in anyOf should have additionalProperties: false99+ expect(result.properties.u.anyOf[0].additionalProperties).toBe(false)100+ expect(result.properties.u.anyOf[1].additionalProperties).toBe(false)101+ })⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # First, find the schema-converter implementation file fd -e ts -e js schema-converter packages/typescript/ai-openai/srcRepository: TanStack/ai
Length of output: 114
🏁 Script executed:
# Check the implementation for oneOf handling rg -n -C5 'oneOf' packages/typescript/ai-openai/Repository: TanStack/ai
Length of output: 1084
🏁 Script executed:
# Read the test file to understand the complete test structure wc -l packages/typescript/ai-openai/tests/schema-converter.test.tsRepository: TanStack/ai
Length of output: 119
🏁 Script executed:
# Read the relevant sections of the test file head -150 packages/typescript/ai-openai/tests/schema-converter.test.ts | tail -100Repository: TanStack/ai
Length of output: 2723
🏁 Script executed:
# Check the schema-converter implementation fd -type f -name "schema-converter*" packages/typescript/ai-openai/src/ -exec cat {} \;Repository: TanStack/ai
Length of output: 225
🏁 Script executed:
# Read the full schema-converter.ts implementation cat packages/typescript/ai-openai/src/utils/schema-converter.tsRepository: TanStack/ai
Length of output: 4215
🏁 Script executed:
# Check git history or comments about oneOf removal rg -n 'oneOf' packages/typescript/ai-openai/Repository: TanStack/ai
Length of output: 179
🏁 Script executed:
# Read the complete test file to understand all tests cat packages/typescript/ai-openai/tests/schema-converter.test.tsRepository: TanStack/ai
Length of output: 4438
Add comprehensive structure assertions to the anyOf test.
The test currently only verifies
additionalPropertieson the union variants but doesn't assert the complete transformed structure. The suggested enhancement checks should be included to verify that the root object maintains itsadditionalProperties: false,requiredarray, and that each variant'srequiredfields are properly preserved through the recursive transformation.it('should handle anyOf (union types) by transforming each variant', () => { const schema = { type: 'object', properties: { u: { anyOf: [ { type: 'object', properties: { a: { type: 'string' } }, required: ['a'], }, { type: 'object', properties: { b: { type: 'number' } }, required: ['b'], }, ], }, }, required: ['u'], } const result = makeOpenAIStructuredOutputCompatible(schema, ['u']) // Each variant in anyOf should have additionalProperties: false expect(result.properties.u.anyOf[0].additionalProperties).toBe(false) expect(result.properties.u.anyOf[1].additionalProperties).toBe(false) + + // Verify complete structure + expect(result.additionalProperties).toBe(false) + expect(result.required).toEqual(['u']) + expect(result.properties.u.anyOf).toHaveLength(2) + expect(result.properties.u.anyOf[0].required).toEqual(['a']) + expect(result.properties.u.anyOf[1].required).toEqual(['b']) })📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change74+ it('should handle anyOf (union types) by transforming each variant', () => {75+ const schema = {76+ type: 'object',77+ properties: {78+ u: {79+ anyOf: [80+ {81+ type: 'object',82+ properties: { a: { type: 'string' } },83+ required: ['a'],84+ },85+ {86+ type: 'object',87+ properties: { b: { type: 'number' } },88+ required: ['b'],89+ },90+ ],91+ },92+ },93+ required: ['u'],94+ }95+96+ const result = makeOpenAIStructuredOutputCompatible(schema, ['u'])97+98+ // Each variant in anyOf should have additionalProperties: false99+ expect(result.properties.u.anyOf[0].additionalProperties).toBe(false)100+ expect(result.properties.u.anyOf[1].additionalProperties).toBe(false)101+102+ // Verify complete structure103+ expect(result.additionalProperties).toBe(false)104+ expect(result.required).toEqual(['u'])105+ expect(result.properties.u.anyOf).toHaveLength(2)106+ expect(result.properties.u.anyOf[0].required).toEqual(['a'])107+ expect(result.properties.u.anyOf[1].required).toEqual(['b'])108+ })🤖 Prompt for AI Agents
In packages/typescript/ai-openai/tests/schema-converter.test.ts around lines 74 to 101, the anyOf test only asserts additionalProperties on the variants; update the test to also assert that the root object has additionalProperties: false, that the root required array includes 'u', and that each anyOf variant preserves its required fields (i.e., variant 0 has required ['a'] and variant 1 has required ['b']) by adding appropriate expect(...) assertions for these conditions.✅ Addressed in commit 8ac9059
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: falseon 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:
- Root-level unions: anyOf/oneOf at the schema root rather than within properties
- Type arrays: Fields with
type: ['string', 'number']or types that already include'null' - 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 ef311605e06280e4b34442cf2c673422a89a4557 and 9ea46740346c28934862f379bf21d17381ff6b49.
📒 Files selected for processing (2)
packages/typescript/ai-openai/src/utils/schema-converter.tspackages/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/adapterssubpath rather than monolithic adapters Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference Implement isomorphic tool system usingtoolDefinition()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 responsesFiles:
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.tsnaming conventionFiles:
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 inferenceApplied 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.
@@ -0,0 +1,6 @@1+import { describe, expect, it } from 'vitest'2+import {3+ makeOpenAIStructuredOutputCompatible,4+ transformNullsToUndefined,5+} from '../src/utils/schema-converter'6+⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Check if other tests in the project are co-located with source files or in separate test directories echo "=== Test files in src/ directories ===" fd -e test.ts -e test.tsx packages/typescript/ai-openai/src/ | head -20 echo -e "\n=== Test files in tests/ directories ===" fd -e test.ts -e test.tsx packages/typescript/ai-openai/tests/ | head -20 echo -e "\n=== Check other packages too ===" echo "Co-located tests in all packages:" fd -e test.ts -e test.tsx packages/*/src/ | wc -l echo "Tests in separate test directories in all packages:" fd -e test.ts -e test.tsx packages/*/tests/ | wc -l echo -e "\n=== Check structure of main source directory ===" ls -la packages/typescript/ai-openai/src/ ls -la packages/typescript/ai-openai/Repository: TanStack/ai
Length of output: 2656
🏁 Script executed:
#!/bin/bash # List all test files in the project echo "=== All .test.ts files in ai-openai package ===" find packages/typescript/ai-openai -name "*.test.ts" -type f echo -e "\n=== Check if tests directory is used elsewhere ===" ls -la packages/typescript/ai-openai/tests/ echo -e "\n=== Check all test files in typescript packages ===" find packages/typescript -name "*.test.ts" -type fRepository: TanStack/ai
Length of output: 3107
Move test file to co-located location per coding guidelines.
The coding guidelines specify: "Write unit tests using Vitest alongside source files with
.test.tsnaming convention." This test should be located atsrc/utils/schema-converter.test.tsrather thantests/schema-converter.test.ts.Note: While most tests in the project currently use a separate
tests/directory, the stated guideline requires co-location with source files.🤖 Prompt for AI Agents
In packages/typescript/ai-openai/tests/schema-converter.test.ts lines 1-6, the unit test file is placed in the top-level tests/ directory but project guidelines require Vitest unit tests to be co-located next to their source files with a .test.ts suffix; move this file to packages/typescript/ai-openai/src/utils/schema-converter.test.ts (keeping the same test contents and imports) and update any test runner or package paths if they rely on the old tests/ location so the test executes from the new co-located path.would it be possible to tack on exporting the chat model names in the main index file?
all of the other models are exported except for the chat models
@stephansama mind opening up an issue? Im off this week and I'll forget this by the time I'm back 😅
@stephansama mind opening up an issue? Im off this week and I'll forget this by the time I'm back 😅
@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
@stephansama added the export
harry-whorlow(GitHub profile, opens in a new tab) approved these changes
AlemTuzlak merged this181e0ac
AlemTuzlak closed this
harry-whorlow(GitHub profile, opens in a new tab) changed the title
Sign in to join this conversation.
📝 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#
packages/typescript/ai-openai/src/model-meta.ts,packages/typescript/ai-openai/src/index.ts.namefields to match OpenAI identifiers (added-latestsuffixes andchatgpt-4.0→chatgpt-4o-latest) and re-exportedOPENAI_CHAT_MODELS.packages/typescript/ai-openai/src/utils/schema-converter.tsmakeOpenAIStructuredOutputCompatibleto handleanyOfrecursively at property and root levels (apply per-variantrequired/additionalProperties: false); throws on unsupportedoneOf.packages/typescript/ai-openai/tests/schema-converter.test.tstransformNullsToUndefinedandmakeOpenAIStructuredOutputCompatible, covering null→undefined, nested objects/arrays, and union (anyOf/oneOf) cases.packages/typescript/ai/src/types.tsJSONSchemaindex signature from[key: string]: unknownto[key: string]: anyto improve assignability with custom schema shapes.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.changeset/full-stars-drop.md,.changeset/mighty-gifts-enter.md@tanstackpackages 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#
packages/typescript/ai-openai/src/model-meta.ts— related model name identifier and export changes.Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 9ea46740346c28934862f379bf21d17381ff6b49 and cda48469cb6a25e454ebaa63fbf0ef094603ed8e.
📒 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)
Files:
packages/typescript/ai-openai/src/index.tspackages/typescript/*/src/index.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/ai-openai/src/index.ts**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/ai-openai/src/index.ts🧠 Learnings (4)
📚 Learning: 2025-12-27T20:22:51.232Z
Applied to files:
packages/typescript/ai-openai/src/index.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-openai/src/index.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-openai/src/index.ts📚 Learning: 2025-12-27T21:39:29.563Z
Applied to files:
packages/typescript/ai-openai/src/index.ts🔇 Additional comments (1)
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