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
feat(chat): build requests with several jobs as a folder of small flows (#16115)
Hazem Adel5dc18c49493e
diff --git a/packages/server/api/src/app/mcp/tools/ap-build-flow.ts b/packages/server/api/src/app/mcp/tools/ap-build-flow.tsindex 278a8921522..8767bcfb1fe 100644--- a/packages/server/api/src/app/mcp/tools/ap-build-flow.ts+++ b/packages/server/api/src/app/mcp/tools/ap-build-flow.ts@@ -87,6 +87,7 @@ export const apBuildFlowTool = ({ mcp, userId }: McpToolContext, log: FastifyBas})flowId = flow.idconst createdIn = `${mcpUtils.folderSuffix(folder.folderName)}, externalId ${flow.externalId}`+ const solutionCheckHint = isNil(folder.folderName) ? '' : `\nOnce every flow and table in this folder is built, check how they fit together with ap_validate_flow({ folderName: ${JSON.stringify(folder.folderName)} }).`const triggerVersionResult = await mcpUtils.resolveLatestPieceVersion({ pieceName: trigger.pieceName, projectId, platformId, log })if (triggerVersionResult.error) {@@ -209,12 +210,12 @@ export const apBuildFlowTool = ({ mcp, userId }: McpToolContext, log: FastifyBasunknownProps: unknownPropFindings,}if (unknownPropFindings.length > 0) {- return { content: [{ type: 'text', text: `❌ Flow "${flowName}" created (id: ${flowId})${createdIn}, but some settings used property names that do NOT exist on the piece and were dropped — the flow does NOT behave as configured. Do NOT tell the user these settings were applied. Fix each with ap_update_step / ap_update_trigger using the correct property names:\n${unknownPropFindings.join('\n')}\nOpen: ${flowUrl}` }], structuredContent: structured }+ return { content: [{ type: 'text', text: `❌ Flow "${flowName}" created (id: ${flowId})${createdIn}, but some settings used property names that do NOT exist on the piece and were dropped — the flow does NOT behave as configured. Do NOT tell the user these settings were applied. Fix each with ap_update_step / ap_update_trigger using the correct property names:\n${unknownPropFindings.join('\n')}\nOpen: ${flowUrl}${solutionCheckHint}` }], structuredContent: structured }}if (invalidSteps.length === 0 && skippedSteps.length === 0) {- return { content: [{ type: 'text', text: `✅ Flow "${flowName}" created (id: ${flowId})${createdIn} with ${allSteps.length} ${stepWord}, all valid. Open: ${flowUrl}` }], structuredContent: structured }+ return { content: [{ type: 'text', text: `✅ Flow "${flowName}" created (id: ${flowId})${createdIn} with ${allSteps.length} ${stepWord}, all valid. Open: ${flowUrl}${solutionCheckHint}` }], structuredContent: structured }}- return { content: [{ type: 'text', text: `⚠️ Flow "${flowName}" created (id: ${flowId})${createdIn} with ${allSteps.length} ${stepWord} (${validCount} valid, ${invalidSteps.length} invalid: ${invalidSteps.join(', ')}).${skippedHint} Use ap_update_step or ap_update_trigger to fix. Open: ${flowUrl}` }], structuredContent: structured }+ return { content: [{ type: 'text', text: `⚠️ Flow "${flowName}" created (id: ${flowId})${createdIn} with ${allSteps.length} ${stepWord} (${validCount} valid, ${invalidSteps.length} invalid: ${invalidSteps.join(', ')}).${skippedHint} Use ap_update_step or ap_update_trigger to fix. Open: ${flowUrl}${solutionCheckHint}` }], structuredContent: structured }}catch (err) {if (flowId) {diff --git a/packages/server/api/src/app/mcp/tools/solution-validation.ts b/packages/server/api/src/app/mcp/tools/solution-validation.tsindex 263c8b4210e..d8556102765 100644--- a/packages/server/api/src/app/mcp/tools/solution-validation.ts+++ b/packages/server/api/src/app/mcp/tools/solution-validation.ts@@ -29,6 +29,7 @@ async function validate({ mcp, userId, folderName, log }: { mcp: ProjectScopedMc])const issues = [...flows.flatMap(validationIssues),+ ...flows.flatMap(subflowInputIssues),...steps.flatMap(({ flow, step }) => checkStep({ step, targetsByExternalId, tablesByExternalId }).map((message) => ({ flow, step, message }))),]return {@@ -52,6 +53,21 @@ function validationIssues(flow: PopulatedFlow): SolutionIssue[] {})}+function subflowInputIssues(flow: PopulatedFlow): SolutionIssue[] {+ if (!isPieceStep({ step: flow.version.trigger, pieceName: SUBFLOWS_PIECE_NAME, componentName: CALLABLE_FLOW_TRIGGER })) {+ return []+ }+ return flowStructureUtil.getAllSteps(flow.version.trigger).flatMap((step) => {+ const misreadKeys = unique(stringLeaves(step.settings).flatMap((text) => [...text.matchAll(TRIGGER_OUTPUT_KEY_PATTERN)].map((match) => match[1] ?? match[2])))+ .filter((key) => !CALLABLE_FLOW_OUTPUT_KEYS.includes(key))+ if (misreadKeys.length === 0) {+ return []+ }+ const fixes = misreadKeys.map((key) => `{{trigger['output'].${key}}} → {{trigger['output'].data.${key}}}`).join(', ')+ return [{ flow, step, message: `reads the subflow's inputs from the wrong place, so they are empty at run time. A Callable Flow puts its inputs under data: ${fixes}` }]+ })+}+function summarize({ folderName, flowCount, issues, unchecked }: { folderName: string | undefined, flowCount: number, issues: SolutionIssue[], unchecked: SolutionIssue[] }): string {const flowWord = flowCount === 1 ? 'flow' : 'flows'const uncheckedPart = unchecked.length === 0 ? '' : `\nThese connections could not be checked, so the solution is not verified:\n${unchecked.map(formatLine).join('\n')}`@@ -126,7 +142,10 @@ function checkCallFlow({ step, target }: { step: Step, target: PopulatedFlow | uconst payload = isNil(rawPayload) ? {} : parseObject(rawPayload)const missingKeys = isNil(contract) || isNil(payload) ? [] : Object.keys(contract).filter((key) => !(key in payload))const waitsForResponse = input['waitForResponse'] === true || input['waitForResponse'] === 'true'+ const payloadSchemaSaved = !isNil(readPath({ value: step.settings, path: ['propertySettings', 'flowProps', 'schema'] }))+ const sendsPayloadAsText = typeof rawPayload === 'string' && !payloadSchemaSaved && readsInputFields(target)return [+ ...(sendsPayloadAsText ? [`Call Flow sends its payload as JSON text, so "${targetName}" receives one string instead of its inputs. Set mode to "simple" and flowProps.payload to an object`] : []),...(missingKeys.length > 0 ? [`Call Flow to "${targetName}" does not send ${missingKeys.join(', ')}, which its Callable Flow sample data expects`] : []),...(waitsForResponse && !hasReturnResponse(target) ? [`Call Flow waits for a response, but "${targetName}" has no Return Response step`] : []),]@@ -157,6 +176,20 @@ function checkTableStep({ step, table }: { step: Step, table: SolutionTable | unreturn [`writes fields table "${tableName}" does not have: ${unknownFields.join(', ')}. Key form values by field externalId (raw records JSON by field name). Valid fields: ${validFields || 'none'}`]}+function stringLeaves(value: unknown): string[] {+ if (typeof value === 'string') {+ return [value]+ }+ if (Array.isArray(value)) {+ return value.flatMap(stringLeaves)+ }+ return isObject(value) ? Object.values(value).flatMap(stringLeaves) : []+}++function readsInputFields(flow: PopulatedFlow): boolean {+ return flowStructureUtil.getAllSteps(flow.version.trigger).some((step) => stringLeaves(step.settings).some((text) => INPUT_FIELD_REFERENCE_PATTERN.test(text)))+}+function hasReturnResponse(flow: PopulatedFlow): boolean {return flowStructureUtil.getAllSteps(flow.version.trigger).some((step) => isPieceStep({ step, pieceName: SUBFLOWS_PIECE_NAME, componentName: RETURN_RESPONSE_ACTION }))}@@ -266,6 +299,10 @@ const TABLES_PIECE_NAME = '@activepieces/piece-tables'const CALL_FLOW_ACTION = 'callFlow'const CALLABLE_FLOW_TRIGGER = 'callableFlow'const RETURN_RESPONSE_ACTION = 'returnResponse'+const CALLABLE_FLOW_OUTPUT_KEYS = ['data', 'callbackUrl']+const TRIGGER_OUTPUT_SOURCE = String.raw`trigger(?:\.output|\[['"]output['"]\])`+const INPUT_FIELD_REFERENCE_PATTERN = new RegExp(String.raw`${TRIGGER_OUTPUT_SOURCE}(?:\.data|\[['"]data['"]\])(?:\.|\[)`)+const TRIGGER_OUTPUT_KEY_PATTERN = new RegExp(String.raw`${TRIGGER_OUTPUT_SOURCE}(?:\.([A-Za-z_$][\w$]*)|\[['"]([^'"\]]+)['"]\])`, 'g')const UPDATE_RECORD_ACTION = 'tables-update-record'type SolutionIssue = {diff --git a/packages/server/api/src/assets/prompts/chat-system-prompt.md b/packages/server/api/src/assets/prompts/chat-system-prompt.mdindex 905a718a3d5..7d8d1c31af0 100644--- a/packages/server/api/src/assets/prompts/chat-system-prompt.md+++ b/packages/server/api/src/assets/prompts/chat-system-prompt.md@@ -266,7 +266,7 @@ Hard limits. Everything not listed here is your judgment to exercise.</discovery><guides>-You work in two phases. You start in **discovery** (understanding the goal, reading data) with only read/understand tools available. The moment you begin constructing, editing, testing, or running an automation, call `ap_set_phase('build')` (silent, no thinking status) — this unlocks the build/execution tools. Pair it with loading the guide: when you `ap_load_guide('build_flow')` or `ap_load_guide('one_time_task')`, also `ap_set_phase('build')`.+You work in two phases. You start in **discovery** (understanding the goal, reading data) with only read/understand tools available. The moment you begin constructing, editing, testing, running, or publishing (turning on) an automation, call `ap_set_phase('build')` (silent, no thinking status) — this unlocks the build/execution tools. Every new message starts in discovery again, so a "Turn it on" reply after a build needs `ap_set_phase('build')` before `ap_lock_and_publish`. Pair it with loading the guide: when you `ap_load_guide('build_flow')` or `ap_load_guide('one_time_task')`, also `ap_set_phase('build')`.When (and ONLY when) you commit to building a brand-new recurring automation via `build_flow`, also call `ap_set_build_plan` (silent, no thinking status) with `phase: 'detecting'`, a bold celebratory `tagline` about the exact busywork you're killing (e.g. "Say goodbye to copy-pasting leads"), and the steps you intend to build — this celebrates the moment in a single contained build card and keeps a live plan the user watches update; finish with `phase: 'done'` and the `flowId` to reveal Open / Test / Run. Details in `build_flow`. NEVER call it for one-time tasks, single actions, lookups, answers, or small edits to an existing automation — those get no card.@@ -274,7 +274,7 @@ Detailed playbooks load on demand with `ap_load_guide({ topic })` (silent, no th| topic | load it when ||-------|--------------|-| `build_flow` | You're about to construct/validate/test an automation (after discovery). |+| `build_flow` | You're about to construct/validate/test an automation (after discovery), including a solution of several flows and tables in one folder. || `one_time_task` | The user wants a one-shot action now, not a recurring automation. || `error_handling` | The user wants the automation to react to a step failing (success/failure branches). || `http_fallback` | A required app has no connection and the user can't/won't connect. |diff --git a/packages/server/api/src/assets/prompts/guides/build_flow.md b/packages/server/api/src/assets/prompts/guides/build_flow.mdindex a418eb356c8..ba609f17046 100644--- a/packages/server/api/src/assets/prompts/guides/build_flow.md+++ b/packages/server/api/src/assets/prompts/guides/build_flow.md@@ -33,6 +33,32 @@ The majority are 2–5 linear steps: a schedule or form/webhook trigger and a co**Exception — reprocessing safety is never "over-building".** The rule above does NOT license skipping an anti-reprocessing mechanism on a recurring flow that reads persistent data. That mechanism is required correctness (see the next section), not a "to be safe" extra — leaving it out is a silent bug, not a simpler flow.+## A use case with several jobs is a solution: small flows in one folder+Before you build, list the jobs in the request: intake, enrichment or processing, storage, reporting, approval, alerting. One job is one flow, as above. Two or more jobs, or a job several flows need, is a **solution**: build a folder of small flows, each doing one job, joined by subflows and Tables. Don't wait for the user to ask; most people don't know subflows exist. One big flow does every job in one place, so one failure breaks all of them and nobody can tell which part failed.++Example: "when an order comes in by webhook, save it, and send me a daily summary" is three jobs:+- **Receive orders** (webhook → Call Flow)+- **Save order** (Callable Flow → Tables create)+- **Daily order summary** (schedule → Tables find → message)++All three go in an `Order intake` folder with an `Orders` table.++**Shared work goes in one subflow.** When several entry points feed the same processing (a webhook and a form, two schedules, two apps), put that processing in ONE Callable subflow. Each entry flow then only receives its input and calls the subflow. Never copy the same steps into two flows: every later fix would have to be made twice. For example, "leads come from a webhook and a form; score each with AI and save it" is **Score and save lead** (Callable Flow → AI → Tables create), called by **Receive webhook lead** and **Receive form lead**.++How to build one:+1. **Folder:** `ap_create_folder` with a name for the whole solution. Pass that `folderName` to every `ap_build_flow` and `ap_create_table` in it.+2. **Names:** name each flow for its one job, in plain words ("Save order", not "Flow 2" or "Order flow helper").+3. **Order:** tables first, then subflows, then the flows that call them. Each step needs an id the previous one returned.+4. **Subflow:** trigger `@activepieces/piece-subflows` `callableFlow`, with `exampleData.sampleData` listing every input it takes, e.g. `{"orderId": "123", "email": "[email protected]"}`. Its steps read each input as `{{trigger['output'].data.<key>}}`, never `{{trigger['output'].<key>}}` (that is empty at run time). Add a `returnResponse` step only if a caller needs data back.+5. **Caller:** a `callFlow` step with `flowId` set to the subflow's **externalId** (the one `ap_build_flow` returned, not its flow id). Use `mode: "simple"` and send every key of the subflow's sample data in `flowProps.payload` as an object; a JSON-text payload arrives in the subflow as one string. Set `waitForResponse` only when the subflow has a Return Response step.+6. **Tables steps:** `table_id` is the table's **externalId**. Form `values` are keyed by field externalId.+7. **Check the whole solution:** after every flow passes its own checks, call `ap_validate_flow({folderName})`. Fix each issue it lists and run it again until it returns ✅. Use it as well to check whether an existing solution fits together, instead of inspecting flows by hand.+8. **Build card:** one card for the whole solution. `flowName` is the solution name, there is one step per flow and table, and `flowId` is the entry flow.++Testing: a Call Flow only reaches a subflow that is published and turned on, so a caller's test run fails at that step while the subflow is a draft. Test each subflow on its own with `ap_test_flow`, using mock trigger data shaped the way a caller delivers it: `{"data": <its sample data>}`. Test the caller's steps before the Call Flow.++Turning it on: one "Turn it on?" card for the whole solution. On yes, call `ap_set_phase('build')`, then publish the subflows first and the flows that call them last.+## Recurring flows must not reprocess**Before you build, answer one question: does this run more than once, and does it read data that persists between runs?** If a scheduled/recurring flow reads a source that keeps its data (a sheet, a Table, an inbox, any record set), that source holds the SAME rows again on the next run. A flow shaped `read-all → act → done` will redo run N's work on run N+1 — re-sending, re-paying, re-notifying. This is the #1 silent logic bug: it validates fine, a single test run looks perfect, and the damage only appears on the second run.@@ -119,8 +145,6 @@ Chat NEVER publishes on its own. A flow only runs once published, so once it val**After `ap_build_flow`** it creates the skeleton but does NOT validate configs or field mappings. You MUST: (1) `ap_validate_step_config` on the trigger and each step, (2) fix any errors with `ap_update_step`/`ap_update_trigger`, (3) `ap_validate_flow` to confirm all steps are valid.-**Several flows and tables in one folder** (subflows, Call Flow, shared tables)? After building them all, call `ap_validate_flow({folderName})` once. It checks every flow plus the connections between them (Call Flow targets and inputs, Return Response, table and field ids). To check whether an existing solution fits together, use it too, instead of inspecting flows by hand. Fix each issue it lists, then run it again.-## Test until it actually works — "valid" is NOT "working"`ap_validate_flow` only proves the config is structurally sound; it does NOT prove the mappings carry the right data. A step can return SUCCEEDED while passing an empty, wrong, or mis-referenced value — that is the #1 silent failure, and the user will see a broken automation that "validated fine." So never stop at validation. Actually run it:diff --git a/packages/server/api/test/integration/ce/mcp/mcp-tools.test.ts b/packages/server/api/test/integration/ce/mcp/mcp-tools.test.tsindex 1099ff575d9..115ee43a2b8 100644--- a/packages/server/api/test/integration/ce/mcp/mcp-tools.test.ts+++ b/packages/server/api/test/integration/ce/mcp/mcp-tools.test.ts@@ -2691,6 +2691,15 @@ describe('MCP Tools integration', () => {expect(builtContent.folderName).toBe('Order intake')expect(text(created)).toContain('in folder "Order intake"')expect(text(built)).toContain(`externalId ${builtFlow?.externalId}`)+ expect(text(built)).toContain('ap_validate_flow({ folderName: "Order intake" })')+ await apCreateFolderTool(mcp, mockLog).execute({ folderName: 'Order "rush"' })+ const quoted = await apBuildFlowTool({ mcp }, mockLog).execute({+ flowName: 'Quoted folder',+ folderName: 'Order "rush"',+ trigger: { pieceName: '@activepieces/piece-test-email', triggerName: 'new_email' },+ steps: [],+ })+ expect(text(quoted)).toContain('ap_validate_flow({ folderName: "Order \\"rush\\"" })')})it('ap_build_flow into a folder that does not exist creates nothing', async () => {diff --git a/packages/server/api/test/integration/ce/mcp/mcp-validate-solution.test.ts b/packages/server/api/test/integration/ce/mcp/mcp-validate-solution.test.tsindex 94c9cce52c4..a3a7440784f 100644--- a/packages/server/api/test/integration/ce/mcp/mcp-validate-solution.test.ts+++ b/packages/server/api/test/integration/ce/mcp/mcp-validate-solution.test.ts@@ -1,11 +1,13 @@-import { agentToolClassification, FlowActionType, PackageType, PieceType, ProjectScopedMcpServer } from '@activepieces/shared'+import { agentToolClassification, FlowActionType, FlowOperationType, flowStructureUtil, PackageType, PieceType, ProjectScopedMcpServer } from '@activepieces/shared'import { FastifyBaseLogger, FastifyInstance } from 'fastify'import { afterAll, beforeAll, describe, expect, it } from 'vitest'import { z } from 'zod'+import { flowService } from '../../../../src/app/flows/flow/flow.service'import { apBuildFlowTool } from '../../../../src/app/mcp/tools/ap-build-flow'import { apCreateFolderTool } from '../../../../src/app/mcp/tools/ap-create-folder'import { apCreateTableTool } from '../../../../src/app/mcp/tools/ap-create-table'import { apValidateFlowTool } from '../../../../src/app/mcp/tools/ap-validate-flow'+import { projectService } from '../../../../src/app/project/project-service'import { db } from '../../../helpers/db'import { mockProjectScopedMcpServer } from '../../../helpers/mcp-flow'import { createMockPieceMetadata } from '../../../helpers/mocks'@@ -104,7 +106,7 @@ describe('ap_validate_flow with folderName', () => {it('passes a solution whose subflow, call and table all fit together', async () => {const { mcp, table } = await createSolutionBase()const subflow = await buildSubflow({ mcp, withResponse: true, writeField: table.fieldExternalId, tableExternalId: table.externalId })- await buildCaller({ mcp, subflowExternalId: subflow.externalId, payload: { orderId: '{{trigger.body.id}}' }, waitForResponse: true })+ await buildCaller({ mcp, subflowExternalId: subflow.externalId, payload: { orderId: '{{trigger.data.id}}' }, waitForResponse: true })const result = await apValidateFlowTool({ mcp }, log).execute({ folderName: SOLUTION_FOLDER })const report = structured(result)@@ -115,6 +117,59 @@ describe('ap_validate_flow with folderName', () => {expect(text(result)).toContain('every connection checks out')})+ it('reports a subflow that reads its inputs from outside data, which are empty at run time', async () => {+ const { mcp, table } = await createSolutionBase()+ await buildSubflow({ mcp, withResponse: false, writeField: table.fieldExternalId, tableExternalId: table.externalId, inputRef: '{{trigger.orderId}}' })++ const messages = await issueMessages(mcp)++ expect(messages).toContainEqual(expect.stringContaining("A Callable Flow puts its inputs under data: {{trigger['output'].orderId}} → {{trigger['output'].data.orderId}}"))+ })++ it.each([+ { spelling: '{{trigger.output.orderId}}' },+ { spelling: '{{trigger["output"]["orderId"]}}' },+ ])('reports a subflow input read outside data in a builder-saved spelling: $spelling', async ({ spelling }) => {+ const { mcp, table } = await createSolutionBase()+ const subflow = await buildSubflow({ mcp, withResponse: false, writeField: table.fieldExternalId, tableExternalId: table.externalId })+ const { data: [flow] } = await flowService(log).list({ projectIds: [mcp.projectId], externalIds: [subflow.externalId], includeTriggerSource: false })+ const step = flowStructureUtil.getStepOrThrow('step_1', flow.version.trigger)+ const { platformId } = await projectService(log).getOneOrThrow(mcp.projectId)+ await flowService(log).update({+ id: flow.id, projectId: mcp.projectId, userId: null, platformId,+ operation: { type: FlowOperationType.UPDATE_ACTION, request: { ...step, settings: { ...step.settings, input: { table_id: table.externalId, values: { values: [{ [table.fieldExternalId]: spelling }] } } } } },+ })++ const messages = await issueMessages(mcp)++ expect(messages).toContainEqual(expect.stringContaining("{{trigger['output'].data.orderId}}"))+ })++ it('reports a Call Flow that sends its payload as JSON text, which the subflow receives as one string', async () => {+ const { mcp, table } = await createSolutionBase()+ const subflow = await buildSubflow({ mcp, withResponse: false, writeField: table.fieldExternalId, tableExternalId: table.externalId })+ await buildFlow({ mcp, flowName: 'Receive order', steps: [+ { type: FlowActionType.PIECE, displayName: 'Enrich', pieceName: '@activepieces/piece-subflows', actionName: 'callFlow', input: { flowId: subflow.externalId, mode: 'advanced', flowProps: { payload: '{"orderId": "{{trigger.data.id}}"}' }, waitForResponse: false } },+ ] })++ const messages = await issueMessages(mcp)++ expect(messages).toContainEqual(expect.stringContaining('sends its payload as JSON text'))+ expect(messages).not.toContainEqual(expect.stringContaining('does not send'))+ })++ it('accepts a JSON-text payload when the subflow parses its data itself', async () => {+ const { mcp, table } = await createSolutionBase()+ const subflow = await buildSubflow({ mcp, withResponse: false, writeField: table.fieldExternalId, tableExternalId: table.externalId, inputRef: '{{trigger.data}}' })+ await buildFlow({ mcp, flowName: 'Receive order', steps: [+ { type: FlowActionType.PIECE, displayName: 'Enrich', pieceName: '@activepieces/piece-subflows', actionName: 'callFlow', input: { flowId: subflow.externalId, mode: 'advanced', flowProps: { payload: '{"orderId": "{{trigger.data.id}}"}' }, waitForResponse: false } },+ ] })++ const messages = await issueMessages(mcp)++ expect(messages).not.toContainEqual(expect.stringContaining('JSON text'))+ })+it('reports a call that misses a subflow input and waits for a response the subflow never returns', async () => {const { mcp, table } = await createSolutionBase()const subflow = await buildSubflow({ mcp, withResponse: false, writeField: table.fieldExternalId, tableExternalId: table.externalId })@@ -186,7 +241,7 @@ describe('ap_validate_flow with folderName', () => {const { mcp, table } = await createSolutionBase()await buildFlow({ mcp, flowName: 'Store orders', steps: [{ type: FlowActionType.PIECE, displayName: 'Save raw', pieceName: '@activepieces/piece-tables', actionName: 'tables-create-records', input: { table_id: table.externalId, records: '{"Order id": "1", "Customer": "x"}' } },- { type: FlowActionType.PIECE, displayName: 'Save dynamic', pieceName: '@activepieces/piece-tables', actionName: 'tables-create-records', input: { table_id: '{{trigger.tableId}}', values: { values: [] } } },+ { type: FlowActionType.PIECE, displayName: 'Save dynamic', pieceName: '@activepieces/piece-tables', actionName: 'tables-create-records', input: { table_id: '{{trigger.data.tableId}}', values: { values: [] } } },] })const report = structured(await apValidateFlowTool({ mcp }, log).execute({ folderName: SOLUTION_FOLDER }))@@ -200,7 +255,7 @@ describe('ap_validate_flow with folderName', () => {it('marks a Call Flow whose target is an expression as unchecked, never as verified', async () => {const { mcp } = await createSolutionBase()- await buildCaller({ mcp, subflowExternalId: '{{trigger.body.flow}}', payload: {}, waitForResponse: true })+ await buildCaller({ mcp, subflowExternalId: '{{trigger.data.flow}}', payload: {}, waitForResponse: true })const result = await apValidateFlowTool({ mcp }, log).execute({ folderName: SOLUTION_FOLDER })@@ -246,13 +301,13 @@ async function createSolutionBase(): Promise<{ mcp: ProjectScopedMcpServer, tablreturn { mcp, table: { id: table.id, externalId: table.externalId, fieldExternalId: table.fields[0].externalId } }}-async function buildSubflow({ mcp, withResponse, writeField, tableExternalId }: { mcp: ProjectScopedMcpServer, withResponse: boolean, writeField: string, tableExternalId: string }): Promise<{ externalId: string }> {+async function buildSubflow({ mcp, withResponse, writeField, tableExternalId, inputRef = '{{trigger.data.orderId}}' }: { mcp: ProjectScopedMcpServer, withResponse: boolean, writeField: string, tableExternalId: string, inputRef?: string }): Promise<{ externalId: string }> {const result = await apBuildFlowTool({ mcp }, log).execute({flowName: 'Enrich order',folderName: SOLUTION_FOLDER,trigger: { pieceName: '@activepieces/piece-subflows', triggerName: 'callableFlow', input: { mode: 'simple', exampleData: { sampleData: { orderId: '123' } } } },steps: [- { type: FlowActionType.PIECE, displayName: 'Save order', pieceName: '@activepieces/piece-tables', actionName: 'tables-create-records', input: { table_id: tableExternalId, values: { values: [{ [writeField]: '{{trigger.orderId}}' }] } } },+ { type: FlowActionType.PIECE, displayName: 'Save order', pieceName: '@activepieces/piece-tables', actionName: 'tables-create-records', input: { table_id: tableExternalId, values: { values: [{ [writeField]: inputRef }] } } },...(withResponse ? [{ type: FlowActionType.PIECE, displayName: 'Respond', pieceName: '@activepieces/piece-subflows', actionName: 'returnResponse', input: { mode: 'simple', response: { response: { saved: true } } } }] : []),],})