edit_workflow
Apply ordered, all-or-nothing batches of node, link, widget, and layout edits to ComfyUI workflows, returning a delta or full summary.
Instructions
Apply batched edits. Each op is a dict with 'op' plus:
{"op": "add_node", "class_type": str, "title"?: str, "ref"?: str, "widgets"?: {name: value}} # later ops may use a ref as a node id
{"op": "remove_node", "node_id": int}
{"op": "connect", "from_node": int, "from_output": str|int, "to_node": int, "to_input": str} # replaces a link
{"op": "disconnect", "node_id": int, "input": str}
{"op": "set_widget", "node_id": int, "input": str | "index": int, "value": any}
{"op": "replace_in_widget", "node_id": int, "input": str, "old": str, "new": str} # 'old' must match once
{"op": "set_title", "node_id": int, "title": str}
{"op": "set_mode", "node_id": int, "mode": int} # 0 normal, 2 mute, 4 bypass
{"op": "set_resolution", "width": int, "height": int} # all latents + size patches
{"op": "copy_nodes", "from_workflow": id, "node_ids": [int], "ref"?: str} # + links among them
Subgraph twins add "definition_id": add_node_to_definition, remove_node_from_definition, connect/set_widget/set_title/set_mode_in_definition.
Layout ops (no twin): set_pos {node_id, pos:[x,y], size?:[w,h]}; set_color {node_id, color, bgcolor?}; add_group {title, node_ids, color?}; set_group {group_id, title?, node_ids?, color?, bounding?:[x,y,w,h]}; remove_group {group_id} ('#N' in inspect_workflow). organize_workflow redoes all layout.
Slot/widget names come from get_node_info. Virtual classes: Note/MarkdownNote take one widget 'text'; Reroute/PrimitiveNode take none at add - connect a PrimitiveNode to a widget input to mirror its type, then set_widget 'value' (+ 'control_after_generate' for number/combo, to advance each run).
Ops apply in order, all or nothing (a failing op changes nothing). Widget values and link types are checked live - "force": true on set_widget/add_node/connect overrides; on connect it also creates a frontend-only input (rgthree switches, dynamic collectors).
Result is a delta; summary=true gives the full graph.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| summary | No | ||
| operations | Yes | ||
| workflow_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||