Skip to content

Commit 6cc5d1e

Browse files
committed
fix deployed context propagation
1 parent de752fa commit 6cc5d1e

File tree

11 files changed

+23
-2
lines changed

11 files changed

+23
-2
lines changed

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export class AgentBlockHandler implements BlockHandler {
321321
_context: {
322322
workflowId: ctx.workflowId,
323323
workspaceId: ctx.workspaceId,
324+
isDeployedContext: ctx.isDeployedContext,
324325
},
325326
},
326327
false,
@@ -1074,6 +1075,7 @@ export class AgentBlockHandler implements BlockHandler {
10741075
workflowVariables: ctx.workflowVariables || {},
10751076
blockData,
10761077
blockNameMapping,
1078+
isDeployedContext: ctx.isDeployedContext,
10771079
})
10781080

10791081
return this.processProviderResponse(response, block, responseFormat)

apps/sim/executor/handlers/api/api-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class ApiBlockHandler implements BlockHandler {
7878
workflowId: ctx.workflowId,
7979
workspaceId: ctx.workspaceId,
8080
executionId: ctx.executionId,
81+
isDeployedContext: ctx.isDeployedContext,
8182
},
8283
},
8384
false,

apps/sim/executor/handlers/condition/condition-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export async function evaluateConditionExpression(
4040
_context: {
4141
workflowId: ctx.workflowId,
4242
workspaceId: ctx.workspaceId,
43+
isDeployedContext: ctx.isDeployedContext,
4344
},
4445
},
4546
false,

apps/sim/executor/handlers/function/function-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class FunctionBlockHandler implements BlockHandler {
3838
_context: {
3939
workflowId: ctx.workflowId,
4040
workspaceId: ctx.workspaceId,
41+
isDeployedContext: ctx.isDeployedContext,
4142
},
4243
},
4344
false,

apps/sim/executor/handlers/generic/generic-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class GenericBlockHandler implements BlockHandler {
6666
workflowId: ctx.workflowId,
6767
workspaceId: ctx.workspaceId,
6868
executionId: ctx.executionId,
69+
isDeployedContext: ctx.isDeployedContext,
6970
},
7071
},
7172
false,

apps/sim/executor/handlers/human-in-the-loop/human-in-the-loop-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ export class HumanInTheLoopBlockHandler implements BlockHandler {
627627
_context: {
628628
workflowId: ctx.workflowId,
629629
workspaceId: ctx.workspaceId,
630+
isDeployedContext: ctx.isDeployedContext,
630631
},
631632
blockData: blockDataWithPause,
632633
blockNameMapping: blockNameMappingWithPause,

apps/sim/lib/workflows/executor/execution-core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export async function executeWorkflowCore(
318318
executionId,
319319
workspaceId: providedWorkspaceId,
320320
userId,
321-
isDeployedContext: triggerType !== 'manual',
321+
isDeployedContext: !metadata.isClientSession,
322322
onBlockStart,
323323
onBlockComplete: wrappedOnBlockComplete,
324324
onStream,

apps/sim/providers/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export interface ProviderRequest {
167167
reasoningEffort?: string
168168
verbosity?: string
169169
thinkingLevel?: string
170+
isDeployedContext?: boolean
170171
}
171172

172173
export const providers: Record<string, ProviderConfig> = {}

apps/sim/providers/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ export function prepareToolExecution(
981981
workflowVariables?: Record<string, any>
982982
blockData?: Record<string, any>
983983
blockNameMapping?: Record<string, string>
984+
isDeployedContext?: boolean
984985
}
985986
): {
986987
toolParams: Record<string, any>
@@ -998,6 +999,9 @@ export function prepareToolExecution(
998999
...(request.workspaceId ? { workspaceId: request.workspaceId } : {}),
9991000
...(request.chatId ? { chatId: request.chatId } : {}),
10001001
...(request.userId ? { userId: request.userId } : {}),
1002+
...(request.isDeployedContext !== undefined
1003+
? { isDeployedContext: request.isDeployedContext }
1004+
: {}),
10011005
},
10021006
}
10031007
: {}),

apps/sim/tools/workflow/executor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ export const workflowExecutorTool: ToolConfig<
4242
inputData = {}
4343
}
4444
}
45+
// Use draft state for manual runs (not deployed), deployed state for deployed runs
46+
const isDeployedContext = params._context?.isDeployedContext
4547
return {
4648
input: inputData,
4749
triggerType: 'api',
48-
useDraftState: false,
50+
useDraftState: !isDeployedContext,
4951
}
5052
},
5153
},

0 commit comments

Comments
 (0)