Nodes/ComfyUi-Ollama-YN/My Ollama Save Context
ComfyUI Node

My Ollama Save Context

Freeze an Ollama conversation so you can pick it up tomorrow

By wujm424606·Created 2 years ago·Updated 2 years ago· 84
My Ollama Save Context
      context
      filenamecontext

      MyOllamaSaveContext exists to solve a genuinely annoying problem: Ollama's conversation context doesn't survive between runs. The context output from My Ollama Generate Advance is Ollama's internal token array - the state that lets a multi-turn conversation stay coherent - and it only lives as long as the graph run that produced it. Close the workflow, restart ComfyUI, and it's gone.

      This node pickles that context to disk so you can restore it later with My Ollama Load Context. It's the difference between "I have to start this prompt-iteration conversation from scratch" and "I saved my place and can resume exactly where I left off." That's a real workflow for people doing long, iterative prompt brainstorming: run a session, save the context, close everything, and come back tomorrow without the model having amnesia.

      How it works

      It's an output node (it's marked OUTPUT_NODE in the source, so it can run at the end of a chain), and it does one thing: takes the context string and pickles it to ComfyUi-Ollama-YN/file/saved_contexts/<filename>_<timestamp>.pickle. The timestamp is added automatically, so you never overwrite a previous save unless you really want a folder full of them.

      The filename input is just the base name - context by default - and the timestamp keeps each save unique. There are no outputs, because there's nothing to hand on; this is a terminal node in the graph.

      The inputs

      • context - wire this from My Ollama Generate Advance's context output. That's the only realistic source, since it's the one node in the pack that returns the token context array.
      • filename - the base name for the pickle file. Defaults to context; give it something descriptive if you'll have several saved sessions to tell apart.

      That's the entire surface area. If you've been clicking around looking for a "save conversation as text" button - that's not this. This saves the model's internal state, not a readable transcript.

      Installing it

      Shared pack install. ComfyUI Manager (search "ComfyUi-Ollama-YN"), or:

      cd ComfyUI/custom_nodes
      git clone https://github.com/wujm424606/ComfyUi-Ollama-YN.git
      # restart ComfyUI
      

      The only Python deps are ollama, pandas, and aiohttp - pickling is stdlib. No model download involved; this node never touches a model.

      The one gotcha that will trip you up

      The README calls it out explicitly: after you save a context, the My Ollama Load Context node won't show the new file in its dropdown until you restart ComfyUI. The file list is generated when the node loads, so a save made in the current session is invisible to it. Save → keep working → restart when you're ready to load. Annoying, but harmless once you know it's coming. And since each save is timestamped, don't be surprised when the folder fills up with incremental files after a long session - it's by design, not a leak.

      CategoryMy Ollama

      Inputs (2)

      NameTypeDefaultDescription
      contextSTRING
      filenameSTRINGcontext

      Outputs (0)

      No outputs