AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(ai): stop offering Google models that new Google projects cannot use (#16022)
Hazem Adel452cc37e42d0
diff --git a/packages/core/piece-types/package.json b/packages/core/piece-types/package.jsonindex 16b520733a8..a53cd465c95 100644--- a/packages/core/piece-types/package.json+++ b/packages/core/piece-types/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/core-piece-types",- "version": "0.12.0",+ "version": "0.12.1","type": "commonjs","main": "./dist/src/index.js","scripts": {diff --git a/packages/core/piece-types/src/lib/ai-providers.test.ts b/packages/core/piece-types/src/lib/ai-providers.test.tsindex f8bfb92ba49..4373cad6fd8 100644--- a/packages/core/piece-types/src/lib/ai-providers.test.ts+++ b/packages/core/piece-types/src/lib/ai-providers.test.ts@@ -244,3 +244,39 @@ describe('aiProviderUtils.isChatModelId', () => {expect(isChat(' GPT-4O ')).toBe(true)})})++describe('Google models that Google has deprecated', () => {+ const deprecated = ['gemini-2.5-pro', 'gemini-2.5-flash']++ it('are not offered to someone using their own Google key, since new Google projects cannot call them', () => {+ for (const provider of [AIProviderName.GOOGLE, AIProviderName.VERTEX]) {+ const offered = (aiProviderUtils.getCuratedChatModels({ provider }) ?? []).map((model) => model.id)+ expect(offered.some((id) => deprecated.includes(id))).toBe(false)+ expect(offered.length).toBeGreaterThan(0)+ }+ })++ it('still run for a step or key that chose them, but only after every current model', () => {+ const runnable = aiProviderUtils.runnableChatModelIds({ provider: AIProviderName.GOOGLE })+ const offered = (aiProviderUtils.getCuratedChatModels({ provider: AIProviderName.GOOGLE }) ?? []).map((model) => model.id)++ expect(runnable.slice(0, offered.length)).toEqual(offered)+ expect(runnable.slice(offered.length)).toEqual(deprecated)+ })++ it('still run on Activepieces credits, so steps saved with them keep working', () => {+ for (const model of deprecated) {+ expect(ALLOWED_CHAT_MODELS_BY_PROVIDER[AIProviderName.ACTIVEPIECES]).toContain(`google/${model}`)+ }+ })++ it('are still recognised as our own model ids, so analytics and billing keep the name', () => {+ for (const model of deprecated) {+ expect(aiProviderUtils.isCuratedChatModelId({ modelId: model })).toBe(true)+ }+ })++ it('are never the default for image generation with a Google key', () => {+ expect(AI_PROVIDER_CAPABILITIES[AIProviderName.GOOGLE].defaultImageModel).toBe('gemini-3.1-flash-image')+ })+})diff --git a/packages/core/piece-types/src/lib/ai-providers.ts b/packages/core/piece-types/src/lib/ai-providers.tsindex 9a3c097b1f6..dc2b998c3cd 100644--- a/packages/core/piece-types/src/lib/ai-providers.ts+++ b/packages/core/piece-types/src/lib/ai-providers.ts@@ -236,9 +236,15 @@ const CF_GATEWAY_SUBMODEL_TO_PROVIDER: Record<string, AIProviderName> = {const OPENAI_CHAT_MODELS = ['gpt-5.5', 'gpt-5.4-mini', 'gpt-5.4-nano', 'gpt-4.1', 'gpt-4.1-mini'] as constconst ANTHROPIC_CHAT_MODELS = ['claude-sonnet-4-6', 'claude-opus-4-7', 'claude-haiku-4-5'] as constconst ANTHROPIC_OPENROUTER_CHAT_MODELS = ['claude-sonnet-4.6', 'claude-opus-4.7', 'claude-opus-4.8', 'claude-haiku-4.5'] as const-const GOOGLE_CHAT_MODELS = ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-3.7-flash', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview'] as const+const GOOGLE_CHAT_MODELS = ['gemini-3.7-flash', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview'] as const+const DEPRECATED_GOOGLE_CHAT_MODELS = ['gemini-2.5-pro', 'gemini-2.5-flash'] as constconst X_AI_OPENROUTER_CHAT_MODELS = ['grok-4.20'] as const+const DEPRECATED_CHAT_MODELS_BY_PROVIDER: Partial<Record<AIProviderName, readonly string[]>> = {+ [AIProviderName.GOOGLE]: DEPRECATED_GOOGLE_CHAT_MODELS,+ [AIProviderName.VERTEX]: DEPRECATED_GOOGLE_CHAT_MODELS,+}+const REASONING_OPTIONAL_CHAT_MODELS: readonly string[] = ANTHROPIC_OPENROUTER_CHAT_MODELS.map((model) => `${AIProviderName.ANTHROPIC}/${model}`)export const ALLOWED_CHAT_MODELS_BY_PROVIDER: Partial<Record<AIProviderName, readonly string[]>> = {@@ -249,7 +255,7 @@ export const ALLOWED_CHAT_MODELS_BY_PROVIDER: Partial<Record<AIProviderName, rea[AIProviderName.ACTIVEPIECES]: [...ANTHROPIC_OPENROUTER_CHAT_MODELS.map((m) => `${AIProviderName.ANTHROPIC}/${m}`),...OPENAI_CHAT_MODELS.map((m) => `${AIProviderName.OPENAI}/${m}`),- ...GOOGLE_CHAT_MODELS.map((m) => `${AIProviderName.GOOGLE}/${m}`),+ ...[...GOOGLE_CHAT_MODELS, ...DEPRECATED_GOOGLE_CHAT_MODELS].map((m) => `${AIProviderName.GOOGLE}/${m}`),...X_AI_OPENROUTER_CHAT_MODELS.map((m) => `x-ai/${m}`),],}@@ -278,6 +284,11 @@ function getCuratedChatModels({ provider }: { provider: AIProviderName }): { id:return curatedIds.map((id) => ({ id, label: CHAT_MODEL_LABELS[id] ?? id }))}+function runnableChatModelIds({ provider }: { provider: AIProviderName }): string[] {+ const offered = (getCuratedChatModels({ provider }) ?? []).map((model) => model.id)+ return unique([...offered, ...(DEPRECATED_CHAT_MODELS_BY_PROVIDER[provider] ?? [])])+}+function canDisableReasoning({ modelId }: { modelId: string }): boolean {return REASONING_OPTIONAL_CHAT_MODELS.includes(modelId)}@@ -297,6 +308,7 @@ function curatedChatModelIds(): string[] {return unique([...ACTIVEPIECES_CHAT_TIERS.flatMap((tier) => [tier.id, tier.modelId]),...Object.values(ALLOWED_CHAT_MODELS_BY_PROVIDER).flatMap((curatedIds) => curatedIds ?? []),+ ...Object.values(DEPRECATED_CHAT_MODELS_BY_PROVIDER).flatMap((deprecatedIds) => deprecatedIds ?? []),])}@@ -453,7 +465,7 @@ const DEFAULT_IMAGE_MODELS: Partial<Record<AIProviderName, string>> = {[AIProviderName.ACTIVEPIECES]: ACTIVEPIECES_IMAGE_TIERS[0].modelId,[AIProviderName.OPENROUTER]: 'google/gemini-3.1-flash-lite-image',[AIProviderName.OPENAI]: 'gpt-image-1.5',- [AIProviderName.GOOGLE]: 'gemini-2.5-flash-image',+ [AIProviderName.GOOGLE]: 'gemini-3.1-flash-image',}export const AI_PROVIDER_CAPABILITIES: Record<AIProviderName, AIProviderCapabilities> = {@@ -479,6 +491,7 @@ export const AI_PROVIDER_CAPABILITIES: Record<AIProviderName, AIProviderCapabiliexport const aiProviderUtils = {getMaxContextTokens,getCuratedChatModels,+ runnableChatModelIds,isCuratedChatModelId,managedChatModelIds,isManagedChatModelId,diff --git a/packages/server/api/src/app/ee/agent/agent-model-resolution.ts b/packages/server/api/src/app/ee/agent/agent-model-resolution.tsindex 28bd415f476..c6166d1b874 100644--- a/packages/server/api/src/app/ee/agent/agent-model-resolution.ts+++ b/packages/server/api/src/app/ee/agent/agent-model-resolution.ts@@ -96,7 +96,7 @@ function resolveModelIdForProvider({ provider, selectedModel, surface, config, mif (provider === AIProviderName.ACTIVEPIECES || provider === AIProviderName.OPENROUTER) {return tier.modelId}- const candidates = (aiProviderUtils.getCuratedChatModels({ provider }) ?? []).map((model) => model.id)+ const candidates = aiProviderUtils.runnableChatModelIds({ provider })const preferred = selectedModel && candidates.includes(selectedModel) ? selectedModel : nativeModelIdFor({ tier })return pickAllowedModel({ provider, selectedModel: preferred, candidates, modelScope, modelIds })}diff --git a/packages/server/api/test/unit/app/ai/providers/google-provider.test.ts b/packages/server/api/test/unit/app/ai/providers/google-provider.test.tsindex 8a68621c533..512aa297bb4 100644--- a/packages/server/api/test/unit/app/ai/providers/google-provider.test.ts+++ b/packages/server/api/test/unit/app/ai/providers/google-provider.test.ts@@ -38,8 +38,8 @@ describe('googleProvider.listModels', () => {mockSendRequest.mockResolvedValue({body: {models: [- { name: 'models/gemini-2.5-pro', displayName: 'Gemini 2.5 Pro' },- { name: 'models/gemini-2.5-flash', displayName: 'Gemini 2.5 Flash' },+ { name: 'models/gemini-3.7-flash', displayName: 'Gemini 3.7 Flash' },+ { name: 'models/gemini-3.1-pro-preview', displayName: 'Gemini 3.1 Pro Preview' },],},})@@ -50,7 +50,7 @@ describe('googleProvider.listModels', () => {const intersection = models.filter((model) => allowedIds.includes(model.id))expect(intersection.map((model) => model.id)).toEqual(- expect.arrayContaining(['gemini-2.5-pro', 'gemini-2.5-flash']),+ expect.arrayContaining(['gemini-3.7-flash', 'gemini-3.1-pro-preview']),)})diff --git a/packages/server/api/test/unit/app/ee/agent/agent-model-resolution.test.ts b/packages/server/api/test/unit/app/ee/agent/agent-model-resolution.test.tsindex cd1af713e69..3fe43f92242 100644--- a/packages/server/api/test/unit/app/ee/agent/agent-model-resolution.test.ts+++ b/packages/server/api/test/unit/app/ee/agent/agent-model-resolution.test.ts@@ -107,7 +107,7 @@ describe('resolveModelIdForProvider', () => {it('falls back to the first curated model when the tier has no provider equivalent', () => {expect(resolve({ provider: AIProviderName.OPENAI, selectedModel: 'smart' })).toBe('gpt-5.5')- expect(resolve({ provider: AIProviderName.GOOGLE, selectedModel: 'smart' })).toBe('gemini-2.5-pro')+ expect(resolve({ provider: AIProviderName.GOOGLE, selectedModel: 'smart' })).toBe('gemini-3.7-flash')})it('gives each tier the native model it declares, rather than one derived from its id', () => {@@ -123,7 +123,7 @@ describe('resolveModelIdForProvider', () => {it('has no native model for a tier the release never shipped, so a curated provider takes its first model', () => {expect(agentModelResolution.nativeModelIdFor({ tier: publishedTierReaders.chat.resolveTier({ tierId: 'turbo' }) })).toBeNull()- expect(resolve({ provider: AIProviderName.GOOGLE, selectedModel: 'turbo', surface: 'chat' })).toBe('gemini-2.5-pro')+ expect(resolve({ provider: AIProviderName.GOOGLE, selectedModel: 'turbo', surface: 'chat' })).toBe('gemini-3.7-flash')})it('never sends another provider stale selection through', () => {