Skip to content

Commit 4ad1d53

Browse files
authored
fix(copilot): sanitize edit_workflow result state before returning it to the agent (#6904)
1 parent f9eaadf commit 4ad1d53

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ export async function executeSetBlockEnabled(
458458
blockId: params.blockId,
459459
enabled: params.enabled,
460460
affectedBlockIds: result.affectedBlockIds,
461-
workflowState: result.state,
462461
copilotSanitizedWorkflowState: sanitizeForCopilot(result.state),
463462
...(!result.changed
464463
? {

apps/sim/lib/copilot/tools/server/workflow/edit-workflow/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
loadWorkflowFromNormalizedTables,
3434
saveWorkflowToNormalizedTables,
3535
} from '@/lib/workflows/persistence/utils'
36+
import { sanitizeForCopilot } from '@/lib/workflows/sanitization/json-sanitizer'
3637
import { validateWorkflowState } from '@/lib/workflows/sanitization/validation'
3738
import { withBlockVisibility } from '@/blocks/visibility/server-context'
3839
import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check'
@@ -408,7 +409,7 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
408409
success: true,
409410
workflowId,
410411
workflowName: workflowName ?? 'Workflow',
411-
workflowState: { ...finalWorkflowState, blocks: layoutedBlocks },
412+
workflowState: sanitizeForCopilot(workflowStateForDb),
412413
workflowLint,
413414
...(workflowLintMessage && { workflowLintMessage }),
414415
...(inputErrors && {

0 commit comments

Comments
 (0)