From 65de27330eed081eefe2b8ce0638785512972e97 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 6 Feb 2026 00:14:43 -0800 Subject: [PATCH] fix(resolver): response format and evaluator metrics in deactivated branch (#3152) * fix(resolver): response format in deactivated branch * add evaluator metrics too * add child workflow id to the workflow block outputs * cleanup typing --- apps/sim/blocks/blocks/workflow.ts | 1 + apps/sim/blocks/blocks/workflow_input.ts | 1 + apps/sim/executor/utils/block-data.ts | 56 +++++++++++++++++++++--- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/apps/sim/blocks/blocks/workflow.ts b/apps/sim/blocks/blocks/workflow.ts index d30ab4c6d..37d0826aa 100644 --- a/apps/sim/blocks/blocks/workflow.ts +++ b/apps/sim/blocks/blocks/workflow.ts @@ -42,6 +42,7 @@ export const WorkflowBlock: BlockConfig = { outputs: { success: { type: 'boolean', description: 'Execution success status' }, childWorkflowName: { type: 'string', description: 'Child workflow name' }, + childWorkflowId: { type: 'string', description: 'Child workflow ID' }, result: { type: 'json', description: 'Workflow execution result' }, error: { type: 'string', description: 'Error message' }, childTraceSpans: { diff --git a/apps/sim/blocks/blocks/workflow_input.ts b/apps/sim/blocks/blocks/workflow_input.ts index 24c3b3f67..febed399c 100644 --- a/apps/sim/blocks/blocks/workflow_input.ts +++ b/apps/sim/blocks/blocks/workflow_input.ts @@ -41,6 +41,7 @@ export const WorkflowInputBlock: BlockConfig = { outputs: { success: { type: 'boolean', description: 'Execution success status' }, childWorkflowName: { type: 'string', description: 'Child workflow name' }, + childWorkflowId: { type: 'string', description: 'Child workflow ID' }, result: { type: 'json', description: 'Workflow execution result' }, error: { type: 'string', description: 'Error message' }, childTraceSpans: { diff --git a/apps/sim/executor/utils/block-data.ts b/apps/sim/executor/utils/block-data.ts index 9875c79e9..a5ef28d99 100644 --- a/apps/sim/executor/utils/block-data.ts +++ b/apps/sim/executor/utils/block-data.ts @@ -1,3 +1,7 @@ +import { + extractFieldsFromSchema, + parseResponseFormatSafely, +} from '@/lib/core/utils/response-format' import { normalizeInputFormatValue } from '@/lib/workflows/input-format' import { isTriggerBehavior, normalizeName } from '@/executor/constants' import type { ExecutionContext } from '@/executor/types' @@ -43,23 +47,53 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema { const schema: OutputSchema = {} for (const field of inputFormat) { if (!field.name) continue - schema[field.name] = { - type: (field.type || 'any') as 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any', - } + schema[field.name] = { type: field.type || 'any' } } return schema } +function getEvaluatorMetricsSchema(block: SerializedBlock): OutputSchema | undefined { + if (block.metadata?.id !== 'evaluator') return undefined + + const metrics = block.config?.params?.metrics + if (!Array.isArray(metrics) || metrics.length === 0) return undefined + + const validMetrics = metrics.filter( + (m: { name?: string }) => m?.name && typeof m.name === 'string' + ) + if (validMetrics.length === 0) return undefined + + const schema: OutputSchema = { ...(block.outputs as OutputSchema) } + for (const metric of validMetrics) { + schema[metric.name.toLowerCase()] = { type: 'number' } + } + return schema +} + +function getResponseFormatSchema(block: SerializedBlock): OutputSchema | undefined { + const responseFormatValue = block.config?.params?.responseFormat + if (!responseFormatValue) return undefined + + const parsed = parseResponseFormatSafely(responseFormatValue, block.id) + if (!parsed) return undefined + + const fields = extractFieldsFromSchema(parsed) + if (fields.length === 0) return undefined + + const schema: OutputSchema = {} + for (const field of fields) { + schema[field.name] = { type: field.type || 'any' } + } + return schema +} + export function getBlockSchema( block: SerializedBlock, toolConfig?: ToolConfig ): OutputSchema | undefined { const blockType = block.metadata?.id - // For blocks that expose inputFormat as outputs, always merge them - // This includes both triggers (start_trigger, generic_webhook) and - // non-triggers (starter, human_in_the_loop) that have inputFormat if ( blockType && BLOCKS_WITH_INPUT_FORMAT_OUTPUTS.includes( @@ -74,6 +108,16 @@ export function getBlockSchema( } } + const evaluatorSchema = getEvaluatorMetricsSchema(block) + if (evaluatorSchema) { + return evaluatorSchema + } + + const responseFormatSchema = getResponseFormatSchema(block) + if (responseFormatSchema) { + return responseFormatSchema + } + const isTrigger = isTriggerBehavior(block) if (isTrigger && block.outputs && Object.keys(block.outputs).length > 0) {