From e7af482c005d81f1abe7a67fe9b4ce76d7ea2e60 Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:29:54 -0700 Subject: [PATCH 1/4] Update AGENTS.md --- AGENTS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index bd6a3e5e8..b9fb45073 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -181,6 +181,11 @@ tensors just to use tensor methods for scalar or structural calculations. - Avoid unnecessary casts and transfers. Preserve the intended compute dtype, storage dtype, bias dtype, and original tensor shape metadata. +- Keep model-native latent layout handling inside the model or latent-format + owner, not in helper nodes. Do not collapse, expand, pack, or unpack latent + dimensions in nodes or other caller-side adapters just to satisfy a model + forward; the model path should consume and return the native latent shape for + that model family. - Assume inputs to the main model forward are already in the compute dtype by default, except integer inputs such as some model timestep tensors. Do not add defensive or convenience casts in model code; it is better for invalid dtype @@ -244,6 +249,10 @@ - Model implementations should add the minimal number of ComfyUI nodes required to run the model. Reuse existing nodes as much as possible; adapting the model to work with existing nodes is strongly preferred over creating new nodes. +- Nodes should output only values they own. Do not add pass-through outputs for + workflow convenience unless the node is explicitly an output node. Existing + models, latents, conditioning, or other inputs should flow directly to the + next consumer instead of being re-emitted unchanged. - Node-level code must not patch model code directly. Any node behavior that modifies, wraps, hooks, or changes model behavior must go through the model patcher class instead of reaching into model internals. From eb838e232606e97d2e55da493fc5014c18df1937 Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:36:19 -0700 Subject: [PATCH 2/4] Update AGENTS.md with node behavior rules --- AGENTS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index b9fb45073..e2e67c915 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -253,6 +253,10 @@ workflow convenience unless the node is explicitly an output node. Existing models, latents, conditioning, or other inputs should flow directly to the next consumer instead of being re-emitted unchanged. +- Nodes should expose only inputs they actually read to produce current + behavior. Do not add placeholder, pass-through, compatibility, or + workflow-shaping inputs that are ignored or could flow directly to another + node. - Node-level code must not patch model code directly. Any node behavior that modifies, wraps, hooks, or changes model behavior must go through the model patcher class instead of reaching into model internals. From 8a207df6880c85e2269b4332251e63d1eddb5998 Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:41:30 -0700 Subject: [PATCH 3/4] Update AGENTS.md --- AGENTS.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e2e67c915..d36988914 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -177,8 +177,11 @@ - Do not use tensors as general-purpose Python data structures. Keep metadata, bookkeeping, counters, flags, shape math, padding math, index planning, memory estimates, and control-flow decisions in plain Python values unless the data - must participate directly in tensor computation. Avoid creating temporary - tensors just to use tensor methods for scalar or structural calculations. + must participate directly in tensor computation. Split points, slice + boundaries, sequence offsets, and similar structural indices should be Python + ints/lists after validation, not CPU tensors kept only to drive Python-side + control flow. Avoid creating temporary tensors just to use tensor methods for + scalar or structural calculations. - Avoid unnecessary casts and transfers. Preserve the intended compute dtype, storage dtype, bias dtype, and original tensor shape metadata. - Keep model-native latent layout handling inside the model or latent-format From 25b6a157001e7f401cafd58e06d225f601a84fec Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:58:26 -0700 Subject: [PATCH 4/4] Clarify tensor usage and structural metadata guidelines --- AGENTS.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d36988914..5236a00cf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -177,11 +177,14 @@ - Do not use tensors as general-purpose Python data structures. Keep metadata, bookkeeping, counters, flags, shape math, padding math, index planning, memory estimates, and control-flow decisions in plain Python values unless the data - must participate directly in tensor computation. Split points, slice - boundaries, sequence offsets, and similar structural indices should be Python - ints/lists after validation, not CPU tensors kept only to drive Python-side - control flow. Avoid creating temporary tensors just to use tensor methods for - scalar or structural calculations. + must participate directly in tensor computation. Do not create tensors for + structural metadata that is only used for Python-side control flow. Sequence + lengths, cumulative offsets, split indices, window counts, slice boundaries, + and repeat counts should be kept as Python ints/lists from the point they are + computed. Do not build them as CPU/GPU tensors and then cast, move, validate, + or convert them back to Python for `split`, `tensor_split`, indexing plans, + loops, or cache keys. Avoid creating temporary tensors just to use tensor + methods for scalar or structural calculations. - Avoid unnecessary casts and transfers. Preserve the intended compute dtype, storage dtype, bias dtype, and original tensor shape metadata. - Keep model-native latent layout handling inside the model or latent-format