Niutonian GLM-4.6V Agentic Sampler
A KSampler that argues with itself until it likes the picture
- model
- glm_model
- vae
- positive
- negative
- latent_image
- latent
- verified_image
- is_match
- summary
This is the flashy one in the pack: a KSampler that won't hand over the image until a vision model agrees it's good enough. You sample, it decodes, a locally-running GLM-4.6V looks at the result and answers a question you set, and if the answer is no, it bumps the seed and starts over. "Agentic" is a heavy word for it - it's really a verify-and-reroll loop - but the idea is genuinely useful: instead of you sitting there re-rolling by hand, the model critiques and self-corrects.
Here's the honest part, because this is where people get burned. The verification is crude. The node checks GLM's answer for substrings like yes, match, correct, accurate, and good, and calls that a match. And the default verification_prompt - "Does this image match the description?" - doesn't actually include any description. Point a vision model at an image and ask it that, with no reference text, and it will almost always say yes, so you pay for the whole loop and get nothing. If you use this node, the verification prompt is the input you must write yourself: "Is the main subject a red fox standing on snow, facing left, with no people in frame?" Phrase it so a yes/no answer is natural, and the crude keyword check will actually work.
How it works
Under the hood it wraps ComfyUI's own sampler (comfy.sample.sample) - all the standard KSampler machinery - then decodes the latents with your VAE, saves a temp PNG, and asks GLM to judge it (verification generation runs at temperature 0.3, capped at 256 tokens). No match means current_seed += 1 and another full pass, up to max_retries + 1 attempts total. It's a real loop, and it's why the node costs what it costs: each attempt is a complete diffusion pass plus a VLM pass plus a VAE decode. With the default max_retries of 3 you're signing up for up to 4× the sampling time. Set it to 1 if you just want a light sanity check, and keep steps modest.
The inputs that matter
- verification_prompt - the one that makes or breaks it. Write a specific, checkable question (see above). This is not a place to keep the default.
- max_retries (default 3, 1–10) - how many re-rolls after the first attempt. Each one is a full regeneration, so treat it as a time budget.
- Everything else is your normal KSampler kit:
model,seed,steps,cfg,sampler_name,scheduler,positive,negative,latent_image,denoise- plusglm_modelfrom the Loader andvae.
It outputs four things:
- latent and verified_image - the final sample and its decoded image, so you can preview or continue the graph.
- is_match - a BOOLEAN saying whether GLM approved. Wire it into a switch or a conditional to gate a second pass, a face detailer, or a different prompt branch.
- summary - GLM's one-line verdict plus which attempt succeeded.
Installing it
Same shared install as the whole pack. ComfyUI Manager → search "comfyui_Niutonian_GLM_4_6V" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Niutonian/comfyui_Niutonian_GLM_4_6V
cd comfyui_Niutonian_GLM_4_6V
pip install -r requirements.txt
Remember the first run downloads ~9GB of GLM weights from HuggingFace, and the pack pins transformers>=5.0.0rc0 - a prerelease that can conflict with other node packs. If unrelated nodes break after install, that's the cause.
Common issues
- It always passes on the first try - your verification prompt is too vague. Give GLM something concrete to check.
- It never passes - your prompt is too strict or asks about something the image can't satisfy, and you're burning 4× sampling time. Loosen the criterion or lower
max_retries. - OOM - all that decoding stacks up. Enable 4-bit on the Loader, keep the image small (the pack's own README recommends 1024×1024 or below for grey/decode trouble), and trim
max_tokenselsewhere.
If a single-image verify loop is more machinery than you need, the Describer gives you the same GLM eyes with none of the re-rolling. But for that one workflow where you know exactly what a good result looks like, this node automates the part of re-rolling you were doing by hand.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| glm_model | GLM_MODEL | — | |
| vae | VAE | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| sampler_name | COMBO | euler | 17 options: euler, euler_ancestral, heun, dpm_2, dpm_2_ancestral, lms, +11 |
| scheduler | COMBO | normal | 6 options: normal, karras, exponential, sgm_uniform, simple, ddim_uniform |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | — | |
| verification_prompt | STRING | Does this image match the description? | — |
| max_retries | INT | 31–10 | — |
| denoise | FLOAT | 1.000–1 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| verified_image | IMAGE | — |
| is_match | BOOLEAN | — |
| summary | STRING | — |