Ollama Save Context
Write an Ollama conversation state to disk so it survives a restart
This is one of the pack's quiet utility nodes - it doesn't show up in the README's node list at all, but it does exactly one job and does it plainly: take a context string and write it to a file, so it's still there the next time you open ComfyUI. It's an output node in the same sense as Save Image - it runs as a terminal step even if nothing's connected downstream of it, because there's nothing downstream by design. It has no outputs.
Why you'd reach for it
Ollama's context is the token-level state that lets a follow-up prompt continue a conversation instead of starting cold. Normally that state lives in your graph only as long as ComfyUI is running with the same nodes wired up. If you want a conversation to survive a restart - or hand off to a completely different workflow later - you need to get it out of memory and onto disk. That's what this node is for.
The gotcha worth knowing before you wire it up
The context input here is typed STRING. That matters because this pack actually has two separate "context" concepts running in parallel, and they don't interconnect. The current-generation OllamaGenerateV2 node's context socket is a custom OLLAMA_CONTEXT type, and OllamaChat uses its own OLLAMA_HISTORY type for the same idea. Neither of those will plug into this node - ComfyUI won't let you connect mismatched socket types. What does match is the older, deprecated OllamaGenerateAdvance node, whose context output is plain STRING. In practice, this node pairs with that one, not with the current-gen nodes.
Inputs that matter
context(STRING, required) - the conversation state, typically wired straight fromOllamaGenerateAdvance'scontextoutput after a run withkeep_contextenabled.filename(default"context") - set this if you want to keep more than one saved conversation around; each distinct name should give you a separate saved file rather than overwriting the last one.
No outputs - this is a write-only, end-of-chain node.
Installing it
Same as the rest of the pack. Via ComfyUI Manager, search comfyui-ollama (by Stav Sapir) or ollama → stavsap. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/stavsap/comfyui-ollama
pip install -r requirements.txt
then restart. This particular node doesn't talk to your Ollama server at all - it's pure local file I/O, so there's nothing extra to configure for it specifically.
Common issues
Can't connect it to OllamaGenerateV2's context output. That's not a bug, it's a type mismatch - see above. This node speaks the older STRING-context format, not the newer typed socket.
Wondering where the file actually lands. The node's own inputs don't expose a save path, just a filename - check the node's right-click info or the ComfyUI output directory conventions rather than guessing at a location.
Looking for the modern equivalent. If you're building around the current-gen nodes, OllamaChat's history socket handles multi-turn state natively within a session, but as of this pack version there's no documented save/load pair for that OLLAMA_HISTORY type - persistence across restarts is still a V1-lineage feature.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| context | STRING | — | |
| filename | STRING | context | — |
Outputs (0)
No outputs