Skip to content

Commit 9776c6f

Browse files
committed
Fix copilot run workflow
1 parent 5f446ad commit 9776c6f

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 {
@@ -76,26 +77,29 @@ export class RunWorkflowClientTool extends BaseClientTool {
7677
}
7778
logger.debug('Using active workflow', { activeWorkflowId })
7879

79-
const workflowInput = params.workflow_input ? { input: params.workflow_input } : undefined
80-
if (workflowInput?.input) {
80+
const workflowInput = params.workflow_input || undefined
81+
if (workflowInput) {
8182
logger.debug('Workflow input provided', {
82-
inputPreview: String(workflowInput.input).slice(0, 120),
83+
inputFields: Object.keys(workflowInput),
84+
inputPreview: JSON.stringify(workflowInput).slice(0, 120),
8385
})
8486
}
8587

8688
setIsExecuting(true)
8789
logger.debug('Set isExecuting(true) and switching state to executing')
8890
this.setState(ClientToolCallState.executing)
8991

92+
const executionId = uuidv4()
9093
const executionStartTime = new Date().toISOString()
9194
logger.debug('Starting workflow execution', {
9295
executionStartTime,
93-
executionId: this.toolCallId,
96+
executionId,
97+
toolCallId: this.toolCallId,
9498
})
9599

96100
const result = await executeWorkflowWithFullLogging({
97101
workflowInput,
98-
executionId: this.toolCallId,
102+
executionId,
99103
})
100104

101105
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)