diff --git a/apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts b/apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts index 538641921a..7f92ba8b0d 100644 --- a/apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts +++ b/apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts @@ -1,4 +1,5 @@ import { Loader2, MinusCircle, Play, XCircle } from 'lucide-react' +import { v4 as uuidv4 } from 'uuid' import { BaseClientTool, type BaseClientToolMetadata, @@ -12,7 +13,7 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store' interface RunWorkflowArgs { workflowId?: string description?: string - workflow_input?: string + workflow_input?: Record } export class RunWorkflowClientTool extends BaseClientTool { @@ -76,10 +77,11 @@ export class RunWorkflowClientTool extends BaseClientTool { } logger.debug('Using active workflow', { activeWorkflowId }) - const workflowInput = params.workflow_input ? { input: params.workflow_input } : undefined - if (workflowInput?.input) { + const workflowInput = params.workflow_input || undefined + if (workflowInput) { logger.debug('Workflow input provided', { - inputPreview: String(workflowInput.input).slice(0, 120), + inputFields: Object.keys(workflowInput), + inputPreview: JSON.stringify(workflowInput).slice(0, 120), }) } @@ -87,15 +89,17 @@ export class RunWorkflowClientTool extends BaseClientTool { logger.debug('Set isExecuting(true) and switching state to executing') this.setState(ClientToolCallState.executing) + const executionId = uuidv4() const executionStartTime = new Date().toISOString() logger.debug('Starting workflow execution', { executionStartTime, - executionId: this.toolCallId, + executionId, + toolCallId: this.toolCallId, }) const result = await executeWorkflowWithFullLogging({ workflowInput, - executionId: this.toolCallId, + executionId, }) setIsExecuting(false) diff --git a/apps/sim/stores/panel-new/copilot/tools.ts b/apps/sim/stores/panel-new/copilot/tools.ts index 31063ae6d7..ed88e27cce 100644 --- a/apps/sim/stores/panel-new/copilot/tools.ts +++ b/apps/sim/stores/panel-new/copilot/tools.ts @@ -3,14 +3,14 @@ export const COPILOT_TOOLS = [ { id: 'run_workflow', description: - 'Execute the current workflow. Use this to run workflows that require manual execution or chat input.', + 'Execute the current workflow. Use this to run workflows that require manual execution or input fields.', parameters: { type: 'object', properties: { workflow_input: { - type: 'string', + type: 'object', description: - 'Optional chat or message to include with the workflow execution. If the workflow requires chat input, you must supply a chat message here.', + '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}', }, }, required: [],