Skip to content

holo-q/comfy-loopback-buffer

Repository files navigation

Comfy Loopback Buffer

Workflow-scoped loopback buffers for ComfyUI. Feed outputs back as inputs across queue runs with automatic history tracking, live previews, and frame sampling.

Why?

ComfyUI workflows execute in isolation - each queue run starts fresh. But many creative workflows need memory:

  • Iterative refinement: Feed the output of one generation as input to the next
  • Temporal effects: Sample from previous frames for animation consistency
  • A/B comparison: Reference earlier iterations while experimenting

This extension provides three nodes that give your workflows persistent memory without manual file juggling.

Installation

ComfyUI Manager (Recommended)

Search for "Comfy Loopback Buffer" in ComfyUI Manager and install.

Manual

cd ComfyUI/custom_nodes
git clone https://github.com/holo-q/comfy-loopback-buffer
# Restart ComfyUI

Nodes

Store Loopback

Writes an image to the loopback buffer and appends it to history.

Input Description
input_image Image to store
cache_path Buffer name (default: loopback_cache)
caching_enabled Toggle storage on/off

Sample Loopback

Reads from the buffer with history sampling support.

Input Description
cache_path Buffer name to read from
update_from_cache true: use latest stored image; false: reuse last loaded
history_indices Which frames to load (see below)
history_limit Max frames to keep (-1 uses default of 64)
empty_mode What to do when frames are missing
empty_width/height Dimensions for placeholder frames
starting_image Optional seed image when buffer is empty

Configure Loopback

Sets persistent configuration for a buffer (currently just history_limit).

History Sampling

The history_indices field specifies which past frames to load:

Syntax Result
1 Most recent frame
1,2,3 Three most recent frames (batched)
1-5 Frames 1 through 5 (batched)
5-1 Frames 5 through 1 in reverse order
1,3-5,7 Frames 1, 3, 4, 5, 7 (mixed syntax)

Index 1 is always the most recent. Index 0 is invalid (would be the current run).

Empty Frame Handling

When requested frames don't exist, empty_mode controls behavior:

Mode Behavior
error Fail with error message
skip Omit missing frames from batch
checkerboard Insert gray checkerboard placeholder
black / white / gray Solid color placeholder
transparent Transparent placeholder (RGBA)

Workflow Isolation

Each workflow gets its own cache namespace based on a hash of the workflow structure. Two different workflows using cache_path: loopback_cache won't collide - they write to separate directories.

To share a buffer across workflows, use an absolute path:

/tmp/shared_loopback

Live Preview

The Sample Loopback node shows a live preview widget displaying:

  • Current workflow key
  • Cache status (present/missing)
  • Requested frames with thumbnails
  • Which frames exist vs. are missing

The preview updates as you type in history_indices.

Development

cd ComfyUI/custom_nodes/comfy-loopback-buffer
uv sync --group dev
uv run pytest -v

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •