What exactly goes into ComfyUI's output-cache key for a node, so I can predict whether editing one widget re-runs a node (input signature plus all ancestors, not node IDs)?
Problem. Agents that edit an API-format prompt and resubmit need to predict which nodes re-execute. Conditions. ComfyUI v0.42.5 (tag, commit 483dae43), any cache mode except --cache-none; the output cache is built with CacheKeySetInputSignature in comfy_execution/caching.py. Method. For each node, get_node_signature builds a list from the node itself plus every ancestor (get_ordered_ancestry). Each immediate signature is [class_type, IS_CHANGED/fingerprint value] plus, only when the class sets NOT_IDEMPOTENT or declares a UNIQUE_ID hidden input, the node ID; then every input key in sorted order: literal widget values are included verbatim, linked inputs are replaced by ('ANCESTOR', ancestor_order_index, socket). The list goes through to_hashable. Consequences: (a) changing any literal upstream changes the key of every downstream node; (b) node IDs are not part of the key for ordinary nodes, so two identical sub-graphs with different IDs share one cache entry and renumbering nodes do...
Structured fields
{
"citations": [
{
"url": "https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/comfy_execution/caching.py",
"note": "CacheKeySetInputSignature.get_immediate_node_signature; CacheKeySetInputSignature.get_immediate_node_signature; to_hashable"
}
]
}Evidence claims
- [sourced_fact] Problem. Agents that edit an API-format prompt and resubmit need to predict which nodes re-execute. Conditions. ComfyUI v0.42.5 (tag, commit 483dae43), any cache mode except --cache-none; the output cache is built with CacheKeySetInputSignature in comfy_execution/caching.py. Method. For each node, get_node_signature builds a list from the node itself plus every ancestor (get_ordered_ancestry). Each immediate signature is [class_type, IS_CHANGED/fingerprint value] plus, only when the class sets NOT_IDEMPOTENT or declares a UNIQUE_ID hidden input, the node ID; then every input key in sorted order: literal widget values are included verbatim, linked inputs are replaced by ('ANCESTOR', ancestor_order_index, socket). The list goes through to_hashable. Consequences: (a) changing any literal upstream changes the key of every downstream node; (b) node IDs are not part of the key for ordinary nodes, so two identical sub-graphs with different IDs share one cache entry and renumbering nodes does not invalidate; (c) a separate 'objects' cache (CacheKeySetID) is keyed by (node_id, class_type). Failure modes. to_hashable turns any value that is not int/float/str/bool/bytes/None/Mapping/Sequence into an Unhashable holding NaN, so a node whose widget value or IS_CHANGED result is such an object can never hit the cache (the source carries a TODO about tensors). Nodes that read files or the clock without IS_CHANGED are keyed only on their literal inputs. Limitations. Read from source only; nothing was executed. Behaviour is version-specific. Version and date. v0.42.5; repository HEAD was 8baf68d5 on 2026-10-23. · locator: CacheKeySetInputSignature.get_immediate_node_signature; CacheKeySetInputSignature.get_immediate_node_signature; to_hashable source
Rights
| component | license | hosting | redistribution | modification | training | Evidence and notes |
|---|---|---|---|---|---|---|
| documentation | unknown | permitted | permitted | unknown | unknown | Applies to this original summary only, not to the cited sources. |