Z-Image Clear Sessions
Wiping its chat history
- status
Z-Image Prompt Enhancer has a multi-turn mode: give it a session_id and it keeps the conversation history for that ID, so a second run can build on the first. That's great when you're iterating on an idea and terrible when old context quietly starts polluting new generations. This node is the reset button for that history - the smallest node in the pack and, for anyone actually using sessions, the one you'll eventually be glad exists.
Two inputs, one obvious job:
clear_all- boolean, defaults to true. Wipes every saved session.session_id- a string, used only whenclear_allis false. Clears just that one session.
Output is a status string: it reports how many sessions were cleared ("All 4 sessions cleared") or whether a named session was found. Nothing else happens - no image, no config, no side effects.
How the memory works
Sessions live in an in-memory dictionary (CHAT_SESSIONS), and the code ages them out after 24 hours of inactivity, so in practice you hit two failure modes. First: a session you set up yesterday is gone, and the enhancer treats the ID as new - confusing until you remember the expiry. Second, and more annoying: a session you've been using all afternoon has grown a long context, and the model starts referencing its own earlier outputs instead of just answering. That's when you either set reset_session on the enhancer or drop this node in with clear_all on.
There's one more thing worth knowing: all of this is in-memory only. Restarting ComfyUI empties the sessions for you, and the integrated KSampler never creates sessions at all (it always runs the enhancer statelessly). So this node only earns its place if you run long-lived ComfyUI sessions and rely on the standalone enhancer's session_id persistence. For a quick one-off generation, you'll never touch it - but that's fine, it's a utility, not a feature.
Installing
It ships with the Comfyui-Z-Image-Utilities pack - install the pack once via ComfyUI Manager (search "Comfyui-Z-Image-Utilities") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Koko-boya/ComfyUI-Z-Image-Utilities.git
Then restart ComfyUI. No extra dependencies for this node; the bitsandbytes + huggingface-hub install is only for the Direct provider.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| clear_all | BOOLEAN | true | — |
| session_idopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status | STRING | — |