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(agents): agents on Claude Opus 5.5 and other newer Claude models no longer fail (#16451)
Hazem Adel1dcce96362c5
diff --git a/packages/server/utils/src/agent-provider-options.ts b/packages/server/utils/src/agent-provider-options.tsindex 04b9bbba94b..3264e2e274c 100644--- a/packages/server/utils/src/agent-provider-options.ts+++ b/packages/server/utils/src/agent-provider-options.ts@@ -1,5 +1,6 @@import { AIProviderName } from '@activepieces/core-utils'import { aiProviderUtils } from '@activepieces/shared'+import { AnthropicLanguageModelOptions } from '@ai-sdk/anthropic'import { SharedV3ProviderOptions } from '@ai-sdk/provider'import { SystemModelMessage } from 'ai'@@ -7,7 +8,7 @@ function buildProviderOptions({ provider, tier, modelId, disableThinking = falseswitch (provider) {case AIProviderName.ANTHROPIC:case AIProviderName.BEDROCK:- return { anthropic: { thinking: disableThinking ? { type: 'disabled' } : { type: 'enabled', budgetTokens: tier.thinkingBudget } } }+ return { anthropic: anthropicThinking({ thinkingBudget: tier.thinkingBudget, modelId, disableThinking }) }case AIProviderName.ACTIVEPIECES:case AIProviderName.OPENROUTER:return { openrouter: { cache_control: { type: 'ephemeral' }, reasoning: openRouterReasoning({ thinkingBudget: tier.thinkingBudget, modelId, disableThinking }) } }@@ -16,6 +17,13 @@ function buildProviderOptions({ provider, tier, modelId, disableThinking = false}}+function anthropicThinking({ thinkingBudget, modelId, disableThinking }: { thinkingBudget: number, modelId: string, disableThinking: boolean }): Pick<AnthropicLanguageModelOptions, 'thinking' | 'effort'> {+ if (ADAPTIVE_ONLY_ANTHROPIC_MODELS.some((family) => modelId.includes(family))) {+ return disableThinking ? { thinking: { type: 'adaptive' }, effort: 'low' } : { thinking: { type: 'adaptive' } }+ }+ return disableThinking ? { thinking: { type: 'disabled' } } : { thinking: { type: 'enabled', budgetTokens: thinkingBudget } }+}+function openRouterReasoning({ thinkingBudget, modelId, disableThinking }: { thinkingBudget: number, modelId: string, disableThinking: boolean }): OpenRouterReasoningDirective {if (!disableThinking) {return { max_tokens: thinkingBudget }@@ -38,6 +46,8 @@ export const agentProviderOptions = {buildSystemPromptWithCaching,}+const ADAPTIVE_ONLY_ANTHROPIC_MODELS = ['claude-opus-4-7', 'claude-opus-4-8', 'claude-opus-5', 'claude-sonnet-5', 'claude-haiku-5', 'claude-fable-5', 'claude-mythos-5']+type OpenRouterReasoningDirective =| { enabled: false }| { effort: 'minimal' }diff --git a/packages/server/utils/test/agent-ai-utils.test.ts b/packages/server/utils/test/agent-ai-utils.test.tsindex 78a51216747..5fa7a5dde86 100644--- a/packages/server/utils/test/agent-ai-utils.test.ts+++ b/packages/server/utils/test/agent-ai-utils.test.ts@@ -486,6 +486,25 @@ describe('buildProviderOptions', () => {expect(options.anthropic?.thinking).toEqual({ type: 'disabled' })})+ for (const provider of [AIProviderName.ANTHROPIC, AIProviderName.BEDROCK]) {+ for (const modelId of ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-haiku-5-5', 'claude-mythos-5-1', 'anthropic.claude-opus-5-5', 'claude-fable-5-1']) {+ it(`keeps ${modelId} on ${provider} thinking at low effort instead of sending disabled`, () => {+ const options = agentAiUtils.buildProviderOptions({ provider, tier: TIER, modelId, disableThinking: true })+ expect(options.anthropic).toEqual({ thinking: { type: 'adaptive' }, effort: 'low' })+ })++ it(`never sends a thinking budget to ${modelId} on ${provider}`, () => {+ const options = agentAiUtils.buildProviderOptions({ provider, tier: TIER, modelId, disableThinking: false })+ expect(options.anthropic).toEqual({ thinking: { type: 'adaptive' } })+ })+ }+ }++ it('still spends the tier budget on an Anthropic model that takes one', () => {+ const options = agentAiUtils.buildProviderOptions({ provider: AIProviderName.ANTHROPIC, tier: TIER, modelId: 'claude-sonnet-4-6', disableThinking: false })+ expect(options.anthropic?.thinking).toEqual({ type: 'enabled', budgetTokens: TIER.thinkingBudget })+ })+it('leaves the ephemeral prompt cache in place beside the reasoning directive', () => {const options = agentAiUtils.buildProviderOptions({ provider: AIProviderName.ACTIVEPIECES, tier: TIER, modelId: REASONING_OPTIONAL, disableThinking: true })expect(options.openrouter?.cache_control).toEqual({ type: 'ephemeral' })