Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions apps/sim/lib/copilot/tools/client/workflow/run-workflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Loader2, MinusCircle, Play, XCircle } from 'lucide-react'
import { v4 as uuidv4 } from 'uuid'
import {
BaseClientTool,
type BaseClientToolMetadata,
Expand All @@ -12,7 +13,7 @@ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
interface RunWorkflowArgs {
workflowId?: string
description?: string
workflow_input?: string
workflow_input?: Record<string, any>
}

export class RunWorkflowClientTool extends BaseClientTool {
Expand Down Expand Up @@ -76,26 +77,29 @@ 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),
})
}

setIsExecuting(true)
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)
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/stores/panel-new/copilot/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down