Skip to content

Commit 963d8d6

Browse files
committed
fix(copilot): run workflow supports input format and fix run id (#2018)
1 parent b2dcb2a commit 963d8d6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Loader2, MinusCircle, Play, XCircle } from 'lucide-react'
2+
import { v4 as uuidv4 } from 'uuid'
23
import {
34
BaseClientTool,
45
type BaseClientToolMetadata,
@@ -12,7 +13,7 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
1213
interface RunWorkflowArgs {
1314
workflowId?: string
1415
description?: string
15-
workflow_input?: string
16+
workflow_input?: Record<string, any>
1617
}
1718

1819
export class RunWorkflowClientTool extends BaseClientTool {
@@ -103,26 +104,29 @@ export class RunWorkflowClientTool extends BaseClientTool {
103104
}
104105
logger.debug('Using active workflow', { activeWorkflowId })
105106

106-
const workflowInput = params.workflow_input ? { input: params.workflow_input } : undefined
107-
if (workflowInput?.input) {
107+
const workflowInput = params.workflow_input || undefined
108+
if (workflowInput) {
108109
logger.debug('Workflow input provided', {
109-
inputPreview: String(workflowInput.input).slice(0, 120),
110+
inputFields: Object.keys(workflowInput),
111+
inputPreview: JSON.stringify(workflowInput).slice(0, 120),
110112
})
111113
}
112114

113115
setIsExecuting(true)
114116
logger.debug('Set isExecuting(true) and switching state to executing')
115117
this.setState(ClientToolCallState.executing)
116118

119+
const executionId = uuidv4()
117120
const executionStartTime = new Date().toISOString()
118121
logger.debug('Starting workflow execution', {
119122
executionStartTime,
120-
executionId: this.toolCallId,
123+
executionId,
124+
toolCallId: this.toolCallId,
121125
})
122126

123127
const result = await executeWorkflowWithFullLogging({
124128
workflowInput,
125-
executionId: this.toolCallId,
129+
executionId,
126130
})
127131

128132
setIsExecuting(false)

apps/sim/stores/panel-new/copilot/tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ export const COPILOT_TOOLS = [
33
{
44
id: 'run_workflow',
55
description:
6-
'Execute the current workflow. Use this to run workflows that require manual execution or chat input.',
6+
'Execute the current workflow. Use this to run workflows that require manual execution or input fields.',
77
parameters: {
88
type: 'object',
99
properties: {
1010
workflow_input: {
11-
type: 'string',
11+
type: 'object',
1212
description:
13-
'Optional chat or message to include with the workflow execution. If the workflow requires chat input, you must supply a chat message here.',
13+
'JSON object with key-value mappings where each key is an input field name required by the workflow. For example: {"message": "Hello", "temperature": 0.7}',
1414
},
1515
},
1616
required: [],

0 commit comments

Comments
 (0)