Skip to content

Commit f5a6c47

Browse files
feat(start-block): add run metadata toggle with trusted <start.metadata> outputs (#5700)
* feat(start-block): add run metadata toggle with trusted <start.metadata> outputs * fix(start-block): fail-soft email lookup, consistent nested metadata propagation, toggle parsing parity * improvement(start-block): enumerate metadata fields in toggle description for agent schema * fix(start-block): carry metadata chain through toggle-off children, preserve fail-soft null email * fix(start-block): recover metadata chain from seeded start output after resume
1 parent d7f0a11 commit f5a6c47

13 files changed

Lines changed: 791 additions & 9 deletions

File tree

apps/sim/blocks/blocks/start_trigger.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ export const StartTriggerBlock: BlockConfig = {
2525
type: 'input-format',
2626
description: 'Add custom fields beyond the built-in input, conversationId, and files fields.',
2727
},
28+
{
29+
id: 'runMetadata',
30+
title: 'Add run metadata',
31+
type: 'switch',
32+
mode: 'advanced',
33+
defaultValue: false,
34+
description:
35+
'Expose trusted, server-injected run metadata under <start.metadata>: userEmail, workspaceId, workflowId, executionId, executionType, executionMode, startTime. Fields describe the invoking run — inside a custom block they identify the calling user and workflow.',
36+
},
2837
],
2938
tools: {
3039
access: [],

apps/sim/executor/execution/executor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export class DAGExecutor {
436436
this.contextExtensions.metadata?.useDraftState ??
437437
this.contextExtensions.isDeployedContext !== true,
438438
},
439+
startRunMetadata: this.contextExtensions.startRunMetadata,
439440
environmentVariables: this.environmentVariables,
440441
workflowVariables: this.workflowVariables,
441442
decisions: {
@@ -620,6 +621,7 @@ export class DAGExecutor {
620621
const blockOutput = buildStartBlockOutput({
621622
resolution: startResolution,
622623
workflowInput: this.workflowInput,
624+
runMetadata: this.contextExtensions.startRunMetadata,
623625
})
624626

625627
state.setBlockState(startResolution.block.id, {

apps/sim/executor/execution/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
BlockLog,
77
BlockState,
88
NormalizedBlockOutput,
9+
StartBlockRunMetadata,
910
StreamingExecution,
1011
} from '@/executor/types'
1112
import type { RunFromBlockContext } from '@/executor/utils/run-from-block'
@@ -192,6 +193,12 @@ export interface ContextExtensions {
192193
dagIncomingEdges?: Record<string, string[]>
193194
snapshotState?: SerializableExecutionState
194195
metadata?: ExecutionMetadata
196+
/**
197+
* Trusted run metadata injected into the Start block output when its
198+
* "Add run metadata" toggle is enabled. Built server-side at the two
199+
* Executor construction sites — never from caller-supplied input.
200+
*/
201+
startRunMetadata?: StartBlockRunMetadata
195202
/**
196203
* AbortSignal for cancellation support.
197204
* When aborted, the execution should stop gracefully.

0 commit comments

Comments
 (0)