ComfyUI Node

Recast Latent

A cast for the compressed pixel space

By bobmagicii·Created 2 years ago·Updated 2 years ago· 1
Recast Latent
  • latent
  • LATENT

Recast Latent is a pass-through node with a type on it: LATENT in, same LATENT out, nothing changed in between. It exists to unstick the same class of ComfyUI bug as its siblings - a dynamic "anything" output from another pack that the graph can't resolve into a concrete type until it's queued once and allowed to fail.

If you're new enough that "latent" needs a definition: it's the compressed representation the diffusion model actually denoises in - the VAE encoder squashes your pixels into a smaller tensor, the sampler works on that, and the VAE decoder turns it back into an image. The latent wire in a ComfyUI graph connects things like an empty-latent generator or a VAE encode to the KSampler. It's a normal, boring connection - until one end is a wildcard node that declares it accepts "anything."

That's the failure mode this node targets, and its own source docstring spells it out: nodes from other packages that can take dynamic things will sometimes fail to set themselves up on first load if they're fed from a dynamic output, and putting a typecaster in the chain lets the link resolve knowing its input type. The author's README describes the whole family in one code-flavored line - emptyLatent = (Latent)emptyLatent; - a cast that changes the declared type without touching the value. onRun returns its input, full stop.

Where you'd actually use it: some packs emit a latent (or "anything" that's secretly a latent) from a router, a switcher, or a model-bundle helper, and the downstream KSampler's LATENT socket refuses to resolve the link. Drop Recast Latent between them and the wire is concretely typed from the moment the workflow loads. It costs nothing at runtime - there's no math here, just a type declaration on the wire.

The whole interface

One required input, one output, no parameters.

  • latent (LATENT) - in.
  • LATENT - out.

Installing it

It's part of the ComfyKit Custom Nodes pack (bobmagicii/comfykit-custom-nodes). In ComfyUI Manager, search "ComfyKit Custom Nodes"; or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/bobmagicii/comfykit-custom-nodes

Restart ComfyUI afterward. No requirements.txt, no model downloads - pure Python over core ComfyUI modules.

The limits, stated plainly

A cast fixes the label, not the data. If the anything-output is secretly an image and you cast it to LATENT, the downstream will be handed an image wearing a LATENT badge, and the sampler will fail when it actually runs - you've deferred the problem, not solved it. Make sure the upstream is genuinely producing latents (check the VAE encode / empty latent it comes from) and that the downstream truly wants LATENT. If it wants pixels, that's Recast Image's job. Same family, same logic, different socket - and still the most harmless node you'll add to a graph, because it cannot alter the data by construction.

Categorybobmagicii

Inputs (1)

NameTypeDefaultDescription
latentLATENT

Outputs (1)

NameTypeDescription
LATENTLATENT