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): gpt-5.6 now works in agents and chat, and OpenAI and Azure no longer store conversations (#16381)
Louai Boumedieneac0b47c29770
diff --git a/brain/knowledge/ai-intelligence/ai-providers.md b/brain/knowledge/ai-intelligence/ai-providers.mdindex df77fe53289..e92a499ef57 100644--- a/brain/knowledge/ai-intelligence/ai-providers.md+++ b/brain/knowledge/ai-intelligence/ai-providers.md@@ -122,7 +122,7 @@ after a file without chat keys it seeds the chat list from the live flow list.- **`getEffectiveProviderAndModel` exists for one provider, and skipping it makes Cloudflare Gateway fall off the end of any per-provider switch.** It looks like generic provider resolution; it is not. It returns its input untouched for everything except `CLOUDFLARE_GATEWAY`, where it splits the model id and maps the submodel prefix (`anthropic`, `openai`, `google-ai-studio`, `google-vertex-ai`) back to the real provider. So a gateway model of `anthropic/claude-…` only reaches an Anthropic-keyed branch if you called it first. Any table or lookup keyed on `AIProviderName` — the web-search tool table, capability checks — has no `CLOUDFLARE_GATEWAY` entry and returns nothing for one that skipped the call: no tool, no error, no log. The AI piece calls it at the top of `buildWebSearchConfig`; server-side code that dispatches per provider needs the same call or the same resolution built in.-- **The Agent and the Direct AI steps disagree about whether OpenAI does web search, and both are right.** `WEB_SEARCH_MODE_BY_PROVIDER` has no `OPENAI` entry, so `supportsWebSearch(OPENAI)` is `false` — the Agent asks that question before offering the tool and therefore has never had OpenAI web search (deliberately: it needs the Responses API, which breaks legacy BYOK models). Ask AI never asks it; it builds the tool straight from its own props and has had OpenAI web search all along. So `supportsWebSearch` is the *agent's* policy, not a statement of fact about the provider — reusing it as a general gate silently removes a capability Ask AI users have today. Whoever unifies the two paths has to keep the OpenAI branch reachable without routing it through that gate. The two paths also disagree about the unsupported tail: the piece's `webSearch` prop is a plain checkbox with no provider gating, and `createWebSearchTool` ends in `default: throw new Error('Provider X is not supported for web search')` — so ticking it on Azure, Mistral, xAI, or a Cloudflare Gateway model whose submodel prefix is not one of the four in `CF_GATEWAY_SUBMODEL_TO_PROVIDER` **fails the step**. The server's `buildWebSearchTools` returns `{}` for the same input, because the agent gates before calling it. The builder cannot simply be made to throw: `supportsWebSearch` is true for the `plugin` providers (`openrouter`, `activepieces`), the agent calls the builder for them, and there is no native entry for either because the plugin rides on the model settings instead — so `{}` is the correct answer there. The piece has the same shape, returning early for OpenRouter before the switch that throws. Hence two entry points: `buildWebSearchTools` stays total for callers that gate first, `buildWebSearchToolsOrThrow` reproduces the piece's error for callers that do not.+- **The Agent and the Direct AI steps disagree about whether OpenAI does web search, and both are right.** `WEB_SEARCH_MODE_BY_PROVIDER` has no `OPENAI` entry, so `supportsWebSearch(OPENAI)` is `false` — the Agent asks that question before offering the tool and therefore has never had OpenAI web search (it needed the Responses API, which agents did not use until GIT-1848; every OpenAI call is on Responses now, so adding `OPENAI: 'native'` is the open follow-up). Ask AI never asks it; it builds the tool straight from its own props and has had OpenAI web search all along. So `supportsWebSearch` is the *agent's* policy, not a statement of fact about the provider — reusing it as a general gate silently removes a capability Ask AI users have today. Whoever unifies the two paths has to keep the OpenAI branch reachable without routing it through that gate. The two paths also disagree about the unsupported tail: the piece's `webSearch` prop is a plain checkbox with no provider gating, and `createWebSearchTool` ends in `default: throw new Error('Provider X is not supported for web search')` — so ticking it on Azure, Mistral, xAI, or a Cloudflare Gateway model whose submodel prefix is not one of the four in `CF_GATEWAY_SUBMODEL_TO_PROVIDER` **fails the step**. The server's `buildWebSearchTools` returns `{}` for the same input, because the agent gates before calling it. The builder cannot simply be made to throw: `supportsWebSearch` is true for the `plugin` providers (`openrouter`, `activepieces`), the agent calls the builder for them, and there is no native entry for either because the plugin rides on the model settings instead — so `{}` is the correct answer there. The piece has the same shape, returning early for OpenRouter before the switch that throws. Hence two entry points: `buildWebSearchTools` stays total for callers that gate first, `buildWebSearchToolsOrThrow` reproduces the piece's error for callers that do not.- **The AI-provider create/update endpoints reject unknown `auth` keys rather than stripping them** (`strictAuth` in `packages/core/shared/src/lib/management/ai-providers/index.ts`). This is deliberately the request boundary only: `aiProviderCredentials()` still parses *stored* rows through the loose schemas, because a strict parse of a legacy row falls through to the `auth: {}` fallback and silently empties a working key. If you tighten the shared schemas themselves, you move a loud 400 into a quiet credential loss.- **`aiProviderModule` is registered unconditionally, `agentModule` is not.** In `app.ts`, `aiProviderModule` sits outside the edition switch, while `agentModule` appears only in the `CLOUD` and `ENTERPRISE` arms — so an AI route hung off the provider module is on Community for free, and the same route hung off the agent module 404s there. That asymmetry is the cheapest way to satisfy [000036](../decisions/000036-the-worker-side-ai-path-is-community-edition-core.md): pick the module and there is no edition branch left to get wrong.@@ -239,3 +239,4 @@ Paths verified 2026-07-26.- **`OPENROUTER_PROVISION_KEY` is a management key and cannot make inference calls; only the per-platform keys it mints can.** OpenRouter states it outright: management keys are for creating, listing, updating and deleting other keys and are rejected by every completion or decisions endpoint. So "we already have an OpenRouter key" is true for provisioning and false for anything that needs to call a model at the instance level (the AI Router's Jev call, for example): that needs an ordinary inference key from the same account, created in the dashboard or via the same `POST /keys` the instance already uses, with a credit `limit`. The AI Router does exactly that since 2026-09-23: it runs on the platform's managed key where credits are on, else the admin's own OpenRouter row, as a worker `EXECUTE_AI` job billed like any AI step.- **`z.enum(SomeTsEnum).exclude([SomeTsEnum.MEMBER])` compiles and excludes nothing at the type level; pass the key string, `.exclude(['MEMBER'])`.** zod's `exclude` is typed over `keyof T` and returns `ZodEnum<Omit<T, U[number]>>`. A TS enum member is its own literal type, not the string `'MEMBER'`, so `Omit` finds no key to drop and the inferred value type keeps every member, while the runtime check does exclude it. The symptom is one step removed from the cause: a switch over the parsed field is suddenly non-exhaustive (`switch-exhaustiveness-check` in lint, `TS2366` in the build) even though the branch you removed can never arrive. `/v1/ai/execute` hit this when `ROUTE` was carved out of `AiStepAction` for #15707. Neither vitest nor a package-local eslint run without type information reports it; only the build does.- **The managed Activepieces row can never restrict its models, so a finding that the managed picker offers a model the key forbids is not reachable.** The row is inserted with `modelScope: 'all', modelIds: []`, `create()` refuses `provider === ACTIVEPIECES` (`aiProvider.activepiecesIsManaged`), and `update()` handles only `enabledForChat` for it and returns before any scope field is read (`ai-provider-service.ts`). Every published tier therefore runs on it, and any `modelScope` filtering on the managed path is inert. Reviewers (Greptile on #15871) raise this as a P1; answer with these three facts rather than adding a filter.+- **OpenAI and Azure language models run on the Responses API with `store: false`; everything else OpenAI-shaped stays on Chat Completions.** `createLanguageModel` builds OpenAI and Azure with `.responses()`. A Cloudflare Gateway `openai/*` text model goes to the gateway's `/openai` endpoint with `.responses()` on **both** routes: chat and agents use `routing: 'compat'`, which otherwise sends everything to `/compat/chat/completions`, so the OpenAI check has to sit before the compat early return. `withoutServerStorage` wraps them so `store: false` is the default. Chat Completions refuses tools + reasoning from gpt-5.4 on, and the gpt-5.6 family needs Responses for agents and chat (GIT-1848). `store: false` matters because the default `true` makes the SDK replay saved history as `item_reference` ids, which break after OpenAI's 30-day retention, on a key switch, or when compaction drops parts. Azure's Responses model reads `providerOptions.azure` and only falls back to `openai` when that key is absent, so set options under the provider's own key. The vendors (xAI, DeepSeek, ...), Mistral, every non-OpenAI model on the Cloudflare compat route, and Custom keep Chat Completions, because many of them only speak it. Custom offers Responses through `apiStyle: 'responses'`. To test `store: false`, give the saved assistant turn a **text** part with an `itemId`. With `store: true` the SDK swaps only text, reasoning and provider-run tool parts for `item_reference`, and plain function tool calls are always sent in full, so a tool-call-only fixture passes either way.diff --git a/brain/knowledge/engineering/web-feature-anatomy.md b/brain/knowledge/engineering/web-feature-anatomy.mdindex b492261e22a..cefef781ff3 100644--- a/brain/knowledge/engineering/web-feature-anatomy.md+++ b/brain/knowledge/engineering/web-feature-anatomy.md@@ -164,7 +164,7 @@ way back was to stash the handful of intended edits, `git checkout` the package,- **Platform admin has two page shells that disagree, and one settings-row primitive that got cloned five times.** `DashboardPageHeader` (over `components/custom/page-header.tsx`) is `sticky top-0 z-30`, `text-base font-semibold`, full width, and respects `embedState.hidePageHeader`; `CenteredPage` is `max-w-[40rem] mx-auto py-6`, `text-xl font-medium`, and follows itself with a `Separator`. Twelve admin pages take the first, six the second, and four (billing, usage, embed, AI Center) hand-roll their own `h1` instead. Nothing marks which a new page should use, so the choice has been made per-page by whoever copied the nearest neighbour. Same story one level down: `components/custom/item.tsx` (`Item` / `ItemGroup` / `ItemTitle` / `ItemDescription` / `ItemActions`) is the intended label-left, control-right settings row and has nine call sites, eight of them in platform admin, with SSO the clearest reference. But five local re-implementations sit beside it and reuse none of it: `BillingSection` in `billing/index.tsx`, `HealthCard` plus `HealthRowItem` in `infra/health/components/system-health-tab.tsx` (a near-clone of `Item` + `ItemGroup` + `ItemSeparator`), `SectionHeader` under `setup/ai/components/`, an open-coded `Item variant="outline"` in `setup/general/danger-zone-section.tsx`, and `AutoIncludePill` in `piece-set-details-page.tsx`. Reach for `Item` before writing a row, and check whether the clone next to you is one of those five. The real outlier is `appearance-section.tsx`, which is a vertically stacked `FormItem` form rather than a row list, so it is the one file a standardisation pass has to decide about rather than mechanically convert.- **`packages/web/public/locales/en/translation.json` contains duplicate keys, so no JSON tool may rewrite it — edit it as text.** `agentMoveLosesConnections`, `No projects yet`, `All projects` and `Model` each appear twice today. Any parse-and-dump round-trip (Python's `json`, `jq`, a formatter) silently keeps only the last of each pair and drops the rest, and will additionally unescape every `\uXXXX` sequence in the file — one such round-trip to add a single key produced a 36-line diff with a key deletion buried in it. Add or rename a key with a targeted string replacement and check `git diff --stat` says 1 insertion.- **Resolving a `translation.json` merge conflict is where that rule is hardest to keep and most worth keeping.** Both sides append to a flat map, so any long-lived web branch conflicts here, and the obvious resolution is to parse both sides and dump the union. That loses the duplicates and escapes exactly as above. It also has a three-way trap of its own: keeping every key that is in *ours* resurrects the keys main **deleted**, because our side never removed them either. Merge as main's bytes plus only the keys our side actually added (`in ours, not in the merge base`), appended as text before the closing brace, then confirm `git diff origin/main` is purely additive. Anything else and a reviewer sees deletions in a file they expected to grow.-- **The "New translation files" sync can delete `en` keys that are still in use.** #16370 pruned 361 keys and took `"Couldn't load {key} models"` with them, though the Tiers page calls it as `t("Couldn't load {key} models")`: keys written in double quotes (the usual form when the key holds an apostrophe) slip past whatever decides a key is unused. After merging such a sync, check that every `t('…')` / `t("…")` literal in your changed files is still a key, and add missing ones back as text.+- **The "New translation files" sync can delete `en` keys that are still in use.** #16370 pruned 361 keys and took `"Couldn't load {key} models"` with them, though the Tiers page calls it as `t("Couldn't load {key} models")`: keys written in double quotes (the usual form when the key holds an apostrophe) slip past whatever decides a key is unused. After merging such a sync, check that every `t('…')` / `t("…")` literal in your changed files is still a key, and add missing ones back as text. Keys that reach `t()` only through a variable (a kind-to-key map, a zod message in `core/shared`) are pruned the same way, because the extractor only keeps keys it sees in a literal `t('…')` or `translationKey('…')` call (it also scans `core/utils/src/lib/form-errors.ts`): put zod messages in `formErrors` wrapped in `translationKey`, and give a dynamic key a literal `t('…')` call.- **`AllowOnlyLoggedInUserOnlyGuard` calls its hooks after two early returns, and the linter only lets it.** `react-hooks/rules-of-hooks` does not flag member-expression calls, so `platformHooks.useCurrentPlatform()` / `flagsHooks.useFlags()` sail past it — but add a bare `useSomething()` there and the rule fires, correctly: `isLoggedIn()` can change between renders, so those calls really are conditional. Anything new that needs to run once a session is authenticated belongs in a null-rendering component placed inside the returned `<SocketProvider>` subtree, which mounts only after the guard passes. That is why automatic trial activation is `<AutomaticTrialActivation />` and not a hook.- **The layering is lint-enforced, not just a convention.** `packages/web/.eslintrc.json` has an `import/no-restricted-paths` zone making the codebase unidirectional: `src/app` may import `src/features`, and both may import `src/lib`/`hooks`/`components`/`types`/`utils` — never the reverse (the one exception is `app/query-client.ts`). So a hook that a public route needs belongs in `src/lib`, but anything rendering a feature's components has to live in that feature; you cannot keep the pair in one `lib` file. It fails as an `import/no-restricted-paths` **error**, not a warning, so it blocks lint.- **`cn()` silently drops `text-xss` when a text colour is in the same call.** `cn` is plain `twMerge` with no config, so it does not know `xss` is a font size. It treats `text-xss` as a colour and lets a later `text-gray-11` or `text-warning-11` win. The element renders at the inherited size, with no error. Keep `text-xss` in a static `className`, or outside the `cn()` that also picks a colour. The same `twMerge` also misses Tailwind v4's `w-(--var)` syntax, so a component's default `w-72` wins over it. Write `w-[var(--radix-popover-trigger-width)]` instead.diff --git a/bun.lock b/bun.lockindex fceaa07c6fb..6565458b54e 100644--- a/bun.lock+++ b/bun.lock@@ -153,7 +153,7 @@},"packages/core/piece-types": {"name": "@activepieces/core-piece-types",- "version": "0.12.1",+ "version": "0.12.2","dependencies": {"@activepieces/core-utils": "workspace:*","tslib": "2.6.2",diff --git a/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.test.ts b/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.test.tsindex 49a6aed3d0c..9be289db8df 100644--- a/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.test.ts+++ b/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.test.ts@@ -1,13 +1,30 @@import { aiProviderCredentials, AIProviderName } from '@activepieces/core-utils'-import { describe, expect, it } from 'vitest'+import { describe, expect, it, vi } from 'vitest'import { createCloudflareGatewayModel } from './create-cloudflare-gateway-model'+type SentRequest = { url: string, headers: Headers, body: Record<string, unknown> }type ModelIdentity = { provider: string, modelId: string, config?: { headers?: () => Record<string, string>, baseURL?: string | (() => string), url?: (options: { path: string }) => string } }function identify(model: unknown): ModelIdentity {return model as ModelIdentity}+async function sendHi(model: ReturnType<typeof createCloudflareGatewayModel>): Promise<SentRequest> {+ const original = globalThis.fetch+ let seen: SentRequest = { url: '', headers: new Headers(), body: {} }+ globalThis.fetch = (input, init) => {+ seen = { url: String(input), headers: new Headers(init?.headers), body: typeof init?.body === 'string' ? JSON.parse(init.body) : {} }+ return Promise.resolve(new Response('{}'))+ }+ try {+ await model.doGenerate({ prompt: [{ role: 'user', content: [{ type: 'text', text: 'hi' }] }] }).catch(() => undefined)+ }+ finally {+ globalThis.fetch = original+ }+ return seen+}+const credentials = aiProviderCredentials({ provider: AIProviderName.CLOUDFLARE_GATEWAY, auth: { apiKey: 'cf-key' }, config: { accountId: 'acct', gatewayId: 'gw' } })describe('createCloudflareGatewayModel', () => {@@ -17,11 +34,27 @@ describe('createCloudflareGatewayModel', () => {expect(model.modelId).toBe('gpt-4o')})- it('sends the gateway authorization header and no metadata header', () => {- const model = identify(createCloudflareGatewayModel({ credentials, modelId: 'openai/gpt-4o' }))- const headers = model.config?.headers?.() ?? {}- expect(headers['cf-aig-authorization']).toBe('Bearer cf-key')- expect(headers['cf-aig-metadata']).toBeUndefined()+ it('sends the gateway authorization header and no metadata header', async () => {+ const request = await sendHi(createCloudflareGatewayModel({ credentials, modelId: 'openai/gpt-4o' }))+ expect(request.headers.get('cf-aig-authorization')).toBe('Bearer cf-key')+ expect(request.headers.has('cf-aig-metadata')).toBe(false)+ })++ it('sends an openai model to the gateway Responses endpoint without storing the conversation', async () => {+ const model = createCloudflareGatewayModel({ credentials, modelId: 'openai/gpt-5.6-sol' })+ const request = await sendHi(model)++ expect(identify(model).provider).toBe('openai.responses')+ expect(request.url).toBe('https://gateway.ai.cloudflare.com/v1/acct/gw/openai/responses')+ expect(request.body).toMatchObject({ model: 'gpt-5.6-sol', store: false })+ expect(request.headers.has('authorization')).toBe(false)+ })++ it('still reports the key outcome for an openai model', async () => {+ const onOutcome = vi.fn()+ await sendHi(createCloudflareGatewayModel({ credentials, modelId: 'openai/gpt-5.6-sol', onOutcome }))++ expect(onOutcome).toHaveBeenCalled()})it('ignores the submodel prefix and stays on the compat endpoint', () => {@@ -35,7 +68,7 @@ describe('createCloudflareGatewayModel', () => {it('routes an openai submodel to the gateway openai endpoint with the stripped id', () => {const model = identify(createCloudflareGatewayModel({ credentials, modelId: 'openai/gpt-4o', routing: 'submodel' }))expect(model.modelId).toBe('gpt-4o')- expect(model.provider).toContain('openai')+ expect(model.provider).toBe('openai.responses')})it('falls back to the compat endpoint with the full model id for an unmapped prefix', () => {diff --git a/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.ts b/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.tsindex 1e00332ef95..f5b813c7f5d 100644--- a/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.ts+++ b/packages/core/ai-providers/src/lib/create-cloudflare-gateway-model.ts@@ -6,10 +6,11 @@ import { createOpenAI } from '@ai-sdk/openai'import { createOpenAICompatible } from '@ai-sdk/openai-compatible'import { ImageModel, LanguageModel } from 'ai'import { createAiGateway } from 'ai-gateway-provider'+import { withoutServerStorage } from './create-language-model'export function createCloudflareGatewayModel(params: CreateCloudflareGatewayModelParams & { isImage: true }): ImageModelexport function createCloudflareGatewayModel(params: CreateCloudflareGatewayModelParams & { isImage?: false }): LanguageModel-export function createCloudflareGatewayModel({ credentials, modelId, isImage = false, openaiResponsesModel = false, routing = 'compat', metadata, onOutcome }: CreateCloudflareGatewayModelParams): ImageModel | LanguageModel {+export function createCloudflareGatewayModel({ credentials, modelId, isImage = false, routing = 'compat', metadata, onOutcome }: CreateCloudflareGatewayModelParams): ImageModel | LanguageModel {const { apiKey } = credentials.authconst { vertexProject, vertexRegion } = credentials.configconst accountId = credentials.config.accountId ?? ''@@ -20,6 +21,11 @@ export function createCloudflareGatewayModel({ credentials, modelId, isImage = f...(isNil(metadata) ? {} : { 'cf-aig-metadata': JSON.stringify(metadata) }),}+ if (providerPrefix === 'openai' && !isImage) {+ const openaiProvider = openAiGatewayProvider({ accountId, gatewayId, headers, onOutcome })+ return withoutServerStorage({ model: openaiProvider.responses(actualModelId), providerOptionsName: 'openai' })+ }+if (routing === 'compat') {return compatGatewayModel({ accountId, gatewayId, headers, isImage, modelId: actualModelId, onOutcome })}@@ -40,18 +46,8 @@ export function createCloudflareGatewayModel({ credentials, modelId, isImage = fheaders,})(actualModelId)}- case 'openai': {- const openaiProvider = createOpenAI({- apiKey: NO_KEY_PLACEHOLDER,- baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/openai`,- headers,- fetch: stripAuthorizationHeader,- })- if (isImage) {- return openaiProvider.imageModel(actualModelId)- }- return openaiResponsesModel ? openaiProvider.responses(actualModelId) : openaiProvider.chat(actualModelId)- }+ case 'openai':+ return openAiGatewayProvider({ accountId, gatewayId, headers }).imageModel(actualModelId)default:return compatGatewayModel({ accountId, gatewayId, headers, isImage, modelId })}@@ -74,10 +70,26 @@ function compatGatewayModel({ accountId, gatewayId, headers, isImage, modelId, oreturn isImage ? provider.imageModel(modelId) : provider.chatModel(modelId)}-const stripAuthorizationHeader: typeof globalThis.fetch = (input, init) => {- const headers = new Headers(init?.headers)- headers.delete('Authorization')- return fetch(input, { ...init, headers })+function openAiGatewayProvider({ accountId, gatewayId, headers, onOutcome }: {+ accountId: string+ gatewayId: string+ headers: Record<string, string>+ onOutcome?: ProviderOutcomeReporter+}): ReturnType<typeof createOpenAI> {+ return createOpenAI({+ apiKey: NO_KEY_PLACEHOLDER,+ baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/openai`,+ headers,+ fetch: withoutAuthorizationHeader(observedProviderFetch(onOutcome)),+ })+}++function withoutAuthorizationHeader(delegate: typeof globalThis.fetch | undefined): typeof globalThis.fetch {+ return (input, init) => {+ const headers = new Headers(init?.headers)+ headers.delete('Authorization')+ return (delegate ?? globalThis.fetch)(input, { ...init, headers })+ }}const NO_KEY_PLACEHOLDER = 'no-key'@@ -95,7 +107,6 @@ export type CreateCloudflareGatewayModelParams = {credentials: Extract<AiProviderCredentials, { provider: AIProviderName.CLOUDFLARE_GATEWAY }>modelId: stringisImage?: boolean- openaiResponsesModel?: booleanrouting?: CloudflareGatewayRoutingmetadata?: CloudflareGatewayMetadataonOutcome?: ProviderOutcomeReporterdiff --git a/packages/core/ai-providers/src/lib/create-language-model.test.ts b/packages/core/ai-providers/src/lib/create-language-model.test.tsindex 644a1dff1b9..8c057af516d 100644--- a/packages/core/ai-providers/src/lib/create-language-model.test.ts+++ b/packages/core/ai-providers/src/lib/create-language-model.test.ts@@ -7,6 +7,7 @@ type ModelIdentity = { provider: string, modelId: string, settings?: { plugins?:type VertexModelIdentity = { config: { baseURL: string | (() => string) } }type CustomModelIdentity = { config: { headers: () => Record<string, string>, fetch?: typeof globalThis.fetch } }+type SentRequest = { url: string, headers: Headers, body: Record<string, unknown> }function identify(model: unknown): ModelIdentity {return model as ModelIdentity@@ -20,11 +21,11 @@ function identifyCustom(model: unknown): CustomModelIdentity {return model as CustomModelIdentity}-async function captureSentHeaders(send: () => Promise<unknown>): Promise<Headers> {+async function captureSentRequest(send: () => Promise<unknown>): Promise<SentRequest> {const original = globalThis.fetch- let seen = new Headers()- globalThis.fetch = (_input, init) => {- seen = new Headers(init?.headers)+ let seen: SentRequest = { url: '', headers: new Headers(), body: {} }+ globalThis.fetch = (input, init) => {+ seen = { url: String(input), headers: new Headers(init?.headers), body: typeof init?.body === 'string' ? JSON.parse(init.body) : {} }return Promise.resolve(new Response('{}'))}try {@@ -36,6 +37,14 @@ async function captureSentHeaders(send: () => Promise<unknown>): Promise<Headersreturn seen}+async function captureSentHeaders(send: () => Promise<unknown>): Promise<Headers> {+ return (await captureSentRequest(send)).headers+}++function generateHi(model: ReturnType<typeof createLanguageModel>): Promise<SentRequest> {+ return captureSentRequest(() => model.doGenerate({ prompt: [{ role: 'user', content: [{ type: 'text', text: 'hi' }] }] }))+}+function captureHeaders({ patchedFetch, headers }: {patchedFetch?: typeof globalThis.fetchheaders: Record<string, string>@@ -104,9 +113,9 @@ describe('createLanguageModel', () => {})it('picks the right SDK client per provider', () => {- expect(identify(buildFor(AIProviderName.OPENAI)).provider).toBe('openai.chat')+ expect(identify(buildFor(AIProviderName.OPENAI)).provider).toBe('openai.responses')expect(identify(buildFor(AIProviderName.ANTHROPIC)).provider).toBe('anthropic.messages')- expect(identify(buildFor(AIProviderName.AZURE)).provider).toBe('azure.chat')+ expect(identify(buildFor(AIProviderName.AZURE)).provider).toBe('azure.responses')expect(identify(buildFor(AIProviderName.BEDROCK)).provider).toBe('amazon-bedrock')expect(identify(buildFor(AIProviderName.CUSTOM)).provider).toBe('openai-compatible.chat')expect(identify(buildFor(AIProviderName.OPENROUTER)).provider).toBe('openrouter')@@ -125,9 +134,32 @@ describe('createLanguageModel', () => {expect(headers.has('x-amz-security-token')).toBe(false)})- it('uses the OpenAI Chat API by default and the Responses API when asked', () => {- expect(identify(buildFor(AIProviderName.OPENAI)).provider).toBe('openai.chat')- expect(identify(buildFor(AIProviderName.OPENAI, { openaiResponsesModel: true })).provider).toBe('openai.responses')+ it.each([AIProviderName.OPENAI, AIProviderName.AZURE])('sends %s to the Responses API without storing the conversation', async (provider) => {+ const request = await generateHi(buildFor(provider))++ expect(new URL(request.url).pathname).toMatch(/\/responses$/)+ expect(request.body.store).toBe(false)+ })++ it.each([+ { provider: AIProviderName.OPENAI, optionsKey: 'openai' },+ { provider: AIProviderName.AZURE, optionsKey: 'azure' },+ ])('replays a saved $provider tool turn in full instead of as a stored item reference', async ({ provider, optionsKey }) => {+ const model = buildFor(provider)+ const request = await captureSentRequest(() => model.doGenerate({+ tools: [{ type: 'function', name: 'getWeather', inputSchema: { type: 'object', properties: {} } }],+ prompt: [+ { role: 'user', content: [{ type: 'text', text: 'weather in Paris?' }] },+ { role: 'assistant', content: [{ type: 'text', text: 'Checking the weather.', providerOptions: { [optionsKey]: { itemId: 'msg_saved' } } }, { type: 'tool-call', toolCallId: 'call_1', toolName: 'getWeather', input: { city: 'Paris' }, providerOptions: { [optionsKey]: { itemId: 'fc_saved' } } }] },+ { role: 'tool', content: [{ type: 'tool-result', toolCallId: 'call_1', toolName: 'getWeather', output: { type: 'json', value: { celsius: 20 } } }] },+ ],+ }))+ const items = Array.isArray(request.body.input) ? request.body.input : []++ expect(items).toContainEqual(expect.objectContaining({ role: 'assistant' }))+ expect(items).toContainEqual(expect.objectContaining({ type: 'function_call', call_id: 'call_1', name: 'getWeather' }))+ expect(items).toContainEqual(expect.objectContaining({ type: 'function_call_output', call_id: 'call_1' }))+ expect(items).not.toContainEqual(expect.objectContaining({ type: 'item_reference' }))})it('routes Vertex straight at the configured GCP project and region', () => {@@ -277,18 +309,17 @@ describe('resolved endpoint, credentials and headers', () => {const headersOf = (cfg: ResolvedConfig): Record<string, string> => (typeof cfg.headers === 'function' ? cfg.headers() : cfg.headers)const urlOf = (cfg: ResolvedConfig): string => cfg.url({ path: '/chat/completions', modelId: 'm' })- it('sends OpenAI to the OpenAI endpoint with a bearer credential', () => {- const cfg = configOf(createLanguageModel({ credentials: aiProviderCredentials({ provider: AIProviderName.OPENAI, auth: { apiKey: 'SECRET' }, config: {} }), modelId: 'm' }))- expect(urlOf(cfg)).toContain('https://api.openai.com')- expect(headersOf(cfg)['authorization']).toBe('Bearer SECRET')+ it('sends OpenAI to the OpenAI endpoint with a bearer credential', async () => {+ const request = await generateHi(createLanguageModel({ credentials: aiProviderCredentials({ provider: AIProviderName.OPENAI, auth: { apiKey: 'SECRET' }, config: {} }), modelId: 'm' }))+ expect(request.url).toContain('https://api.openai.com')+ expect(request.headers.get('authorization')).toBe('Bearer SECRET')})- it('encodes the Azure resource name and api version into the URL', () => {- const cfg = configOf(createLanguageModel({ credentials: aiProviderCredentials({ provider: AIProviderName.AZURE, auth: { apiKey: 'SECRET' }, config: { resourceName: 'myres', apiVersion: '2024-08-01' } }), modelId: 'm' }))- const url = urlOf(cfg)- expect(url).toContain('myres')- expect(url).toContain('api-version=2024-08-01')- expect(headersOf(cfg)['api-key']).toBe('SECRET')+ it('encodes the Azure resource name and api version into the URL', async () => {+ const request = await generateHi(createLanguageModel({ credentials: aiProviderCredentials({ provider: AIProviderName.AZURE, auth: { apiKey: 'SECRET' }, config: { resourceName: 'myres', apiVersion: '2024-08-01' } }), modelId: 'm' }))+ expect(request.url).toContain('myres')+ expect(request.url).toContain('api-version=2024-08-01')+ expect(request.headers.get('api-key')).toBe('SECRET')})it('attaches the caller metadata headers to managed OpenRouter traffic', () => {diff --git a/packages/core/ai-providers/src/lib/create-language-model.ts b/packages/core/ai-providers/src/lib/create-language-model.tsindex 1df745cc47a..0503b6c65c1 100644--- a/packages/core/ai-providers/src/lib/create-language-model.ts+++ b/packages/core/ai-providers/src/lib/create-language-model.ts@@ -10,7 +10,7 @@ import { createGoogleGenerativeAI } from '@ai-sdk/google'import { createOpenAI } from '@ai-sdk/openai'import { createOpenAICompatible } from '@ai-sdk/openai-compatible'import { createOpenRouter, OpenRouterChatSettings } from '@openrouter/ai-sdk-provider'-import { ImageModel, LanguageModel } from 'ai'+import { defaultSettingsMiddleware, ImageModel, LanguageModel, wrapLanguageModel } from 'ai'const VERTEX_MAAS_SUFFIX = '-maas'const VERTEX_ANTHROPIC_PREFIX = 'claude'@@ -22,8 +22,7 @@ export function createLanguageModel({ credentials, modelId, options = {} }: Creaswitch (credentials.provider) {case AIProviderName.OPENAI: {const { apiKey } = credentials.auth- const client = createOpenAI({ apiKey, ...observed })- return options.openaiResponsesModel ? client.responses(modelId) : client.chat(modelId)+ return withoutServerStorage({ model: createOpenAI({ apiKey, ...observed }).responses(modelId), providerOptionsName: 'openai' })}case AIProviderName.ANTHROPIC: {const { apiKey } = credentials.auth@@ -36,7 +35,7 @@ export function createLanguageModel({ credentials, modelId, options = {} }: Creacase AIProviderName.AZURE: {const { apiKey } = credentials.authconst { resourceName, apiVersion } = credentials.config- return createAzure({ resourceName, apiKey, apiVersion, ...observed }).chat(modelId)+ return withoutServerStorage({ model: createAzure({ resourceName, apiKey, apiVersion, ...observed }).responses(modelId), providerOptionsName: 'azure' })}case AIProviderName.BEDROCK: {const { accessKeyId, secretAccessKey, sessionToken } = credentials.auth@@ -180,6 +179,16 @@ function stripDefaultAuthorization({ headers, delegate }: {}}+export function withoutServerStorage({ model, providerOptionsName }: {+ model: Parameters<typeof wrapLanguageModel>[0]['model']+ providerOptionsName: 'openai' | 'azure'+}): LanguageModel {+ return wrapLanguageModel({+ model,+ middleware: defaultSettingsMiddleware({ settings: { providerOptions: { [providerOptionsName]: { store: false } } } }),+ })+}+function createOpenRouterChatModel({ apiKey, modelId, options }: {apiKey: string | undefinedmodelId: string@@ -207,7 +216,6 @@ export function buildOpenAICompatibleHeaders({ apiKeyHeader, apiKey, defaultHeadexport type LanguageModelOptions = {onOutcome?: ProviderOutcomeReporter- openaiResponsesModel?: booleanopenRouterSettings?: OpenRouterChatSettingsmistralViaOpenRouter?: booleanextraHeaders?: Record<string, string>diff --git a/packages/core/piece-types/package.json b/packages/core/piece-types/package.jsonindex a53cd465c95..e1b39f11dc4 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.1",+ "version": "0.12.2","type": "commonjs","main": "./dist/src/index.js","scripts": {diff --git a/packages/core/piece-types/src/lib/ai-providers.ts b/packages/core/piece-types/src/lib/ai-providers.tsindex dc2b998c3cd..5e10daeb668 100644--- a/packages/core/piece-types/src/lib/ai-providers.ts+++ b/packages/core/piece-types/src/lib/ai-providers.ts@@ -233,7 +233,7 @@ const CF_GATEWAY_SUBMODEL_TO_PROVIDER: Record<string, AIProviderName> = {'google-vertex-ai': AIProviderName.GOOGLE,}-const OPENAI_CHAT_MODELS = ['gpt-5.5', 'gpt-5.4-mini', 'gpt-5.4-nano', 'gpt-4.1', 'gpt-4.1-mini'] as const+const OPENAI_CHAT_MODELS = ['gpt-5.5', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna', '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 constconst GOOGLE_CHAT_MODELS = ['gemini-3.7-flash', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview'] as const@@ -262,6 +262,9 @@ export const ALLOWED_CHAT_MODELS_BY_PROVIDER: Partial<Record<AIProviderName, reaconst CHAT_MODEL_LABELS: Record<string, string> = {'gpt-5.5': 'GPT-5.5',+ 'gpt-5.6-sol': 'GPT-5.6 Sol',+ 'gpt-5.6-terra': 'GPT-5.6 Terra',+ 'gpt-5.6-luna': 'GPT-5.6 Luna','gpt-5.4-mini': 'GPT-5.4 mini','gpt-5.4-nano': 'GPT-5.4 nano','gpt-4.1': 'GPT-4.1',diff --git a/packages/server/utils/src/ai-utils.ts b/packages/server/utils/src/ai-utils.tsindex 055b39c7646..e4e3a496240 100644--- a/packages/server/utils/src/ai-utils.ts+++ b/packages/server/utils/src/ai-utils.ts@@ -156,14 +156,13 @@ function assertManagedModelAllowed({ provider, modelId, image, adminChosenModelI}, message)}-function createModel({ credentials, modelId, metadata, flowStep, billing, turnAlreadyCharged, openaiResponsesModel = false, webSearchEnabled = false, webSearchOptions, platformId, providerConfigId, imageGeneration = false, adminChosenImageModelId }: {+function createModel({ credentials, modelId, metadata, flowStep, billing, turnAlreadyCharged, webSearchEnabled = false, webSearchOptions, platformId, providerConfigId, imageGeneration = false, adminChosenImageModelId }: {credentials: AiProviderCredentialsmodelId: stringmetadata?: ChatModelMetadataflowStep?: FlowStepMetadatabilling?: ActivepiecesAiBillingturnAlreadyCharged?: boolean- openaiResponsesModel?: booleanwebSearchEnabled?: booleanwebSearchOptions?: WebSearchOptionsplatformId?: string@@ -172,7 +171,7 @@ function createModel({ credentials, modelId, metadata, flowStep, billing, turnAladminChosenImageModelId?: string}): LanguageModel {assertManagedModelAllowed({ provider: credentials.provider, modelId, image: imageGeneration, ...spreadIfDefined('adminChosenModelId', adminChosenImageModelId) })- const model = buildModel({ credentials, modelId, metadata, flowStep, openaiResponsesModel, webSearchEnabled, webSearchOptions, onOutcome: keyHealthReporterFor({ platformId, providerConfigId }) })+ const model = buildModel({ credentials, modelId, metadata, flowStep, webSearchEnabled, webSearchOptions, onOutcome: keyHealthReporterFor({ platformId, providerConfigId }) })return billedLanguageModel({model,provider: credentials.provider,@@ -182,12 +181,11 @@ function createModel({ credentials, modelId, metadata, flowStep, billing, turnAl})}-function buildModel({ credentials, modelId, metadata, flowStep, openaiResponsesModel, webSearchEnabled, webSearchOptions, onOutcome }: {+function buildModel({ credentials, modelId, metadata, flowStep, webSearchEnabled, webSearchOptions, onOutcome }: {credentials: AiProviderCredentialsmodelId: stringmetadata?: ChatModelMetadataflowStep?: FlowStepMetadata- openaiResponsesModel: booleanwebSearchEnabled: booleanwebSearchOptions?: WebSearchOptionsonOutcome?: ProviderOutcomeReporter@@ -197,7 +195,6 @@ function buildModel({ credentials, modelId, metadata, flowStep, openaiResponsesMreturn createCloudflareGatewayModel({credentials,modelId,- openaiResponsesModel,routing: isNil(flowStep) ? 'compat' : 'submodel',...spreadIfDefined('metadata', cloudflareGatewayMetadata(flowStep)),...spreadIfDefined('onOutcome', onOutcome),@@ -209,7 +206,6 @@ function buildModel({ credentials, modelId, metadata, flowStep, openaiResponsesMoptions: {openRouterSettings: openRouterModelSettings({ provider, webSearchEnabled, options: webSearchOptions }),mistralViaOpenRouter: isNil(flowStep),- openaiResponsesModel,...spreadIfDefined('extraHeaders', flowStepMetadataHeaders(flowStep) ?? managedProviderMetadataHeaders({ provider, metadata })),...spreadIfDefined('onOutcome', onOutcome),},diff --git a/packages/server/worker/src/lib/execute/jobs/ai/execute-ai.ts b/packages/server/worker/src/lib/execute/jobs/ai/execute-ai.tsindex f87e9d87c9e..f653c3f2a45 100644--- a/packages/server/worker/src/lib/execute/jobs/ai/execute-ai.ts+++ b/packages/server/worker/src/lib/execute/jobs/ai/execute-ai.ts@@ -1,6 +1,6 @@-import { ActivepiecesAiBilling, ActivepiecesAiConsumerSource, AIProviderName, isNil, spreadIfDefined, tryCatch } from '@activepieces/core-utils'+import { ActivepiecesAiBilling, ActivepiecesAiConsumerSource, isNil, spreadIfDefined, tryCatch } from '@activepieces/core-utils'import { aiUtils, FlowStepMetadata } from '@activepieces/server-utils'-import { AiStepAction, ClassifyTextJobData, EngineResponseStatus, ExecuteAiJobData, getEffectiveProviderAndModel, ResolveAiProviderResponse, WorkerJobType } from '@activepieces/shared'+import { AiStepAction, ClassifyTextJobData, EngineResponseStatus, ExecuteAiJobData, ResolveAiProviderResponse, WorkerJobType } from '@activepieces/shared'import { generateText, ModelMessage, stepCountIs } from 'ai'import { JobContext, JobHandler, JobResult, JobResultKind } from '../../types'import { resolveAiFiles } from './ai-files'@@ -118,14 +118,12 @@ async function runTextStep({ data, resolved, modelId, flowStep, billing, maxRetrconst { provider } = credentialsconst webSearchEnabled = data.webSearch?.enabled ?? falseconst webSearchOptions = data.webSearch?.options- const { provider: effectiveProvider } = getEffectiveProviderAndModel({ provider, model: modelId })const tools = aiUtils.buildWebSearchToolsOrThrow({ provider, model: modelId, webSearchEnabled, options: webSearchOptions })const model = aiUtils.createModel({credentials,modelId,flowStep,billing,- openaiResponsesModel: webSearchEnabled && (effectiveProvider ?? provider) === AIProviderName.OPENAI,webSearchEnabled,webSearchOptions,})@@ -138,7 +136,6 @@ async function runTextStep({ data, resolved, modelId, flowStep, billing, maxRetr...spreadIfDefined('maxRetries', maxRetries),...spreadIfDefined('maxOutputTokens', data.maxOutputTokens),...spreadIfDefined('temperature', data.temperature),- ...spreadIfDefined('providerOptions', reasoningEffortFor({ action: data.action, provider })),...spreadIfDefined('stopWhen', Object.keys(tools).length === 0 ? undefined : stepCountIs(webSearchOptions?.maxUses ?? DEFAULT_WEB_SEARCH_STEPS)),})@@ -185,13 +182,6 @@ function classificationPrompt(data: ClassifyTextJobData): string {Text to classify: "${data.text ?? ''}"`}-function reasoningEffortFor({ action, provider }: { action: AiStepAction, provider: AIProviderName }): Record<string, Record<string, string>> | undefined {- if (action !== AiStepAction.SUMMARIZE_TEXT || provider !== AIProviderName.OPENAI) {- return undefined- }- return { [AIProviderName.OPENAI]: { reasoning_effort: 'minimal' } }-}-function toStepOutput({ data, text, sources }: { data: ExecuteAiJobData, text: string, sources: unknown }): unknown {switch (data.action) {case AiStepAction.ASK_AI: {