Lock
The tiny node that freezes your seed while you change everything else
- output_value
Every ComfyUI graph is quietly full of numbers that fight you. Seeds, steps, cfg, dimensions - you tweak one and a sampler upstream burps out something you didn't ask for. Lock is a 20-line answer to that: it remembers the last integer you gave it, and when you flip its switch, it refuses to let that number change no matter what the rest of the graph does.
It ships in fylrid2's comfyui_lock_previous_value pack, and it's pure plumbing - the kind of node that never touches pixels, just holds a value still so you can fiddle with everything else. If you only ever need to pin a KSampler seed, the built-in fixed control_after_generate already does that, and honestly you should reach for that first. Where Lock earns its keep is when you want to freeze a number you don't control the source of - a seed that gets overwritten somewhere upstream, or a value you want held at last-run's number while you deliberately change the incoming one. Think "one seed, five samplers" from the plumbing playbook, but with a latch on it.
How it works
The mechanism is refreshingly honest. The node keeps a dictionary in memory, keyed by a name string. Every run it does one of two things:
lockis off: store the currentvalueundername, then pass it through.lockis on: ignore the incoming value entirely and return whatever's already stored.
So you run with the lock off to "record" a number, flip it on, and from then on the output is a statue. Toggle it back off, run again, and it re-arms with the new value. Toggling the checkbox is what kicks the node to update, which makes it feel natural in practice.
The state lives on the node instance in the running Python process. That has real consequences: it resets when you restart ComfyUI, each copy of the node you place gets its own private dictionary (no sharing between duplicates), and nothing is saved with the workflow JSON.
The inputs and outputs that matter
Three inputs, one output - all of it from the node's schema:
value(INT, default 0) - the number you're feeding in, either typed in the widget or wired from elsewhere.name(STRING, default "seed") - the slot key. Keep it to "seed" and you get one latch; give different nodes different names and you can lock several values in a single instance.lock(BOOLEAN, default false) - the switch that freezes things.output_value(INT) - the held number, wired into any INT socket: a KSampler seed (right-click → convert widget to input, then connect), steps, cfg, width, height.
Note the type: INT only. Floats, strings, latents need not apply - this is a seed-and-steps tool, not a general freeze.
How to install
Easiest path: ComfyUI Manager → search "lockValue" (or the repo name comfyui_lock_previous_value) and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/fylrid2/comfyui_lock_previous_value
Restart ComfyUI. That's the whole install - the pack declares zero runtime dependencies, so no pip step, no model files, no hidden downloads. License is GPL-3.0 if that matters to you.
Common gotchas
- A locked node ignores your edits. Change
valuewhilelockis on and nothing happens - that's the feature, but it confuses people. Unlock, run, relock. - The lock evaporates on restart. The dictionary is in-memory only, so after a fresh launch the first run simply stores whatever comes in. Don't treat it as a saved workflow property.
- "seed" and "Seed" are different slots. Name matching is exact string matching. Pick one spelling and stick to it.
- The README is a cookiecutter scaffold. It's the generated Comfy-Org template with placeholder text, and the shipped tests still import a nonexistent
Examplenode. Don't go looking for documentation there - the source insrc/lockvalue/nodes.pyis the real spec, and it's twenty lines.
It's a one-trick node, lightly known and barely discussed anywhere. If the trick is the one you need - hold this number, don't touch it - it does exactly that with zero fuss.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| value | INT | 0 | — |
| name | STRING | seed | — |
| lock | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_value | INT | — |