From 1084bfd48527d3ede5d533705d33d74f65c7297c Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 21 Aug 2025 09:18:58 -0600 Subject: [PATCH] add gpt5 to fallback chain on sonnet 4 --- packages/ai/src/steps/analyst-step.ts | 1 + packages/ai/src/steps/think-and-prep-step.ts | 1 + packages/ai/src/utils/models/sonnet-4.ts | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/ai/src/steps/analyst-step.ts b/packages/ai/src/steps/analyst-step.ts index 3dcf3a91f..54a241abc 100644 --- a/packages/ai/src/steps/analyst-step.ts +++ b/packages/ai/src/steps/analyst-step.ts @@ -60,6 +60,7 @@ const outputSchema = z.object({ const DEFAULT_CACHE_OPTIONS = { anthropic: { cacheControl: { type: 'ephemeral', ttl: '1h' } }, + openai: { parallelToolCalls: false, reasoningEffort: 'minimal' }, }; /** diff --git a/packages/ai/src/steps/think-and-prep-step.ts b/packages/ai/src/steps/think-and-prep-step.ts index b4a384517..f916181ec 100644 --- a/packages/ai/src/steps/think-and-prep-step.ts +++ b/packages/ai/src/steps/think-and-prep-step.ts @@ -82,6 +82,7 @@ const outputSchema = ThinkAndPrepOutputSchema; const DEFAULT_CACHE_OPTIONS = { anthropic: { cacheControl: { type: 'ephemeral', ttl: '1h' } }, + openai: { parallelToolCalls: false, reasoningEffort: 'minimal' }, }; // Helper function to create the result object diff --git a/packages/ai/src/utils/models/sonnet-4.ts b/packages/ai/src/utils/models/sonnet-4.ts index 03bb8ecd3..46ade010b 100644 --- a/packages/ai/src/utils/models/sonnet-4.ts +++ b/packages/ai/src/utils/models/sonnet-4.ts @@ -1,6 +1,7 @@ import type { LanguageModelV1 } from '@ai-sdk/provider'; import { createFallback } from './ai-fallback'; import { anthropicModel } from './providers/anthropic'; +import { openaiModel } from './providers/openai'; import { vertexModel } from './providers/vertex'; // Lazy initialization to allow mocking in tests @@ -24,13 +25,13 @@ function initializeSonnet4() { } } - // Only include Vertex if credentials are available - if (process.env.VERTEX_CLIENT_EMAIL && process.env.VERTEX_PRIVATE_KEY) { + if (process.env.OPENAI_API_KEY) { try { - models.push(vertexModel('claude-sonnet-4@20250514')); - console.info('Sonnet4: Vertex AI model added to fallback chain'); + models.push(openaiModel('gpt-5')); + + console.info('Sonnet4: OpenAI model added to fallback chain'); } catch (error) { - console.warn('Sonnet4: Failed to initialize Vertex AI model:', error); + console.warn('Sonnet4: Failed to initialize OpenAI model:', error); } }