Skip to content

Commit 65de273

Browse files
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
1 parent c0b22a6 commit 65de273

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

apps/sim/blocks/blocks/workflow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const WorkflowBlock: BlockConfig = {
4242
outputs: {
4343
success: { type: 'boolean', description: 'Execution success status' },
4444
childWorkflowName: { type: 'string', description: 'Child workflow name' },
45+
childWorkflowId: { type: 'string', description: 'Child workflow ID' },
4546
result: { type: 'json', description: 'Workflow execution result' },
4647
error: { type: 'string', description: 'Error message' },
4748
childTraceSpans: {

apps/sim/blocks/blocks/workflow_input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const WorkflowInputBlock: BlockConfig = {
4141
outputs: {
4242
success: { type: 'boolean', description: 'Execution success status' },
4343
childWorkflowName: { type: 'string', description: 'Child workflow name' },
44+
childWorkflowId: { type: 'string', description: 'Child workflow ID' },
4445
result: { type: 'json', description: 'Workflow execution result' },
4546
error: { type: 'string', description: 'Error message' },
4647
childTraceSpans: {

apps/sim/executor/utils/block-data.ts

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import {
2+
extractFieldsFromSchema,
3+
parseResponseFormatSafely,
4+
} from '@/lib/core/utils/response-format'
15
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
26
import { isTriggerBehavior, normalizeName } from '@/executor/constants'
37
import type { ExecutionContext } from '@/executor/types'
@@ -43,23 +47,53 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema {
4347
const schema: OutputSchema = {}
4448
for (const field of inputFormat) {
4549
if (!field.name) continue
46-
schema[field.name] = {
47-
type: (field.type || 'any') as 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any',
48-
}
50+
schema[field.name] = { type: field.type || 'any' }
4951
}
5052

5153
return schema
5254
}
5355

56+
function getEvaluatorMetricsSchema(block: SerializedBlock): OutputSchema | undefined {
57+
if (block.metadata?.id !== 'evaluator') return undefined
58+
59+
const metrics = block.config?.params?.metrics
60+
if (!Array.isArray(metrics) || metrics.length === 0) return undefined
61+
62+
const validMetrics = metrics.filter(
63+
(m: { name?: string }) => m?.name && typeof m.name === 'string'
64+
)
65+
if (validMetrics.length === 0) return undefined
66+
67+
const schema: OutputSchema = { ...(block.outputs as OutputSchema) }
68+
for (const metric of validMetrics) {
69+
schema[metric.name.toLowerCase()] = { type: 'number' }
70+
}
71+
return schema
72+
}
73+
74+
function getResponseFormatSchema(block: SerializedBlock): OutputSchema | undefined {
75+
const responseFormatValue = block.config?.params?.responseFormat
76+
if (!responseFormatValue) return undefined
77+
78+
const parsed = parseResponseFormatSafely(responseFormatValue, block.id)
79+
if (!parsed) return undefined
80+
81+
const fields = extractFieldsFromSchema(parsed)
82+
if (fields.length === 0) return undefined
83+
84+
const schema: OutputSchema = {}
85+
for (const field of fields) {
86+
schema[field.name] = { type: field.type || 'any' }
87+
}
88+
return schema
89+
}
90+
5491
export function getBlockSchema(
5592
block: SerializedBlock,
5693
toolConfig?: ToolConfig
5794
): OutputSchema | undefined {
5895
const blockType = block.metadata?.id
5996

60-
// For blocks that expose inputFormat as outputs, always merge them
61-
// This includes both triggers (start_trigger, generic_webhook) and
62-
// non-triggers (starter, human_in_the_loop) that have inputFormat
6397
if (
6498
blockType &&
6599
BLOCKS_WITH_INPUT_FORMAT_OUTPUTS.includes(
@@ -74,6 +108,16 @@ export function getBlockSchema(
74108
}
75109
}
76110

111+
const evaluatorSchema = getEvaluatorMetricsSchema(block)
112+
if (evaluatorSchema) {
113+
return evaluatorSchema
114+
}
115+
116+
const responseFormatSchema = getResponseFormatSchema(block)
117+
if (responseFormatSchema) {
118+
return responseFormatSchema
119+
}
120+
77121
const isTrigger = isTriggerBehavior(block)
78122

79123
if (isTrigger && block.outputs && Object.keys(block.outputs).length > 0) {

0 commit comments

Comments
 (0)