edit_workflow
Apply batched graph edits to a ComfyUI workflow: add/remove nodes, connect ports, set widgets, titles or modes, and update layouts or subgraphs.
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}
{"op": "set_widget", "node_id": int, "input": str, "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
All but replace_in_widget have a definition-scoped twin taking an extra "definition_id" for subgraph edits: add_node_to_definition, remove_node_from_definition, and connect/set_widget/set_title/set_mode_in_definition. A malformed op reports its own required keys.
Layout/group ops (no definition twin): set_pos {node_id, pos:[x,y], size?:[w,h]}; add_group {title, node_ids, color?}; set_group {group_id, title?, node_ids?, color?}; remove_group {group_id} ('#N' in inspect_workflow). organize_workflow re-lays out and re-groups, so run these after it.
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; a failing op stops the batch (graph unchanged past that point). Widget values and link types are checked live - "force": true on set_widget/add_node/connect overrides; on connect it also lets a frontend-only input (no /object_info entry - rgthree switches, dynamic collectors) be wired by creating the socket.
Result is a compact delta; summary=true or inspect_workflow 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 | |||