Nodes/Comfy DV Nodes/Ollama History Length
ComfyUI Node

Ollama History Length

How much conversation is the model carrying?

By darth-veitcher·Created 2 years ago·Updated about a month ago· 2
Ollama History Length
  • history
  • length

Ollama History Length is the simplest node in the ComfyUI Ollama Model Manager pack, and it does exactly one thing: count the messages in a conversation history and hand you the number as an INT. It sounds trivial. It's actually the node you reach for when you're building chat workflows that need to make decisions.

How it works

You feed it an OLLAMA_HISTORY (the history output from any Ollama Chat Completion), and it returns the count of messages in that list. A fresh one-turn exchange comes back as 3 (system + user + assistant); a five-turn conversation is more like 11. That's the entire mechanism - no network calls, no model involved, pure arithmetic on the history structure.

The inputs and outputs

  • history (required) - the OLLAMA_HISTORY connection.
  • length (output) - an INT with the message count.

Because the output is a plain INT, this node is not marked as an output-only node - you can feed its number into comparison logic, conditionals, or anything else that wants a count. That's the whole point of it.

Installing it

It ships with the ComfyUI Ollama Model Manager pack: Manager → search "Ollama Manager" → Install → restart, or git clone https://github.com/darth-veitcher/comfyui-ollama-model-manager into ComfyUI/custom_nodes and run python install.py. Python 3.12+, deps auto-installed.

When you'll actually reach for it

Context management is the honest use case. Every message you keep feeding a chat node eats into the model's context window, and long conversations degrade into the model "forgetting" the start. If your workflow needs to trim or summarize history once it crosses a threshold, this count is what you gate on. It's also handy purely for debugging - a number that tells you whether your history chain is accumulating turns correctly or staying stuck at one. It won't fix anything on its own, but it's the observation tool that tells you something needs fixing.

Categorydv/ollama

Inputs (1)

NameTypeDefaultDescription
historyOLLAMA_HISTORY

Outputs (1)

NameTypeDescription
lengthINT