History Builder
Giving the pack's LLM nodes a memory across turns
- previous_history
- history
The pack's LLM nodes - Grok Generate Text, FreedomGPT Generate Text, the OpenAI/Gemini family - are stateless by default: each call gets a prompt and forgets everything before it. History Builder is the node that changes that. It assembles a HISTORY object from user and assistant messages, so you can chain multiple LLM calls into something that remembers what it said, turn after turn.
That matters more than it sounds. "Here's a character description - now write the first scene, now continue" only works if the second call knows the first scene. A refiner that critiques your prompt needs the original prompt in context. Any conversational workflow needs state, and History Builder is how this pack threads state between LLM nodes. Its outputs are explicitly compatible with the pack's other language model nodes, so it's the designed-in way to do it, not a hack.
How it works
The mechanism is boring in the best way: a list of (role, message) tuples, appended in order. Feed it previous_history and it starts from that; add user_message and it appends ("user", message); add assistant_message and it appends ("assistant", message). Blank messages are skipped, so a node with only a user message is a valid one-turn history builder. The result is a HISTORY object you wire into any of the pack's text, image, or vision nodes - and back into History Builder's previous_history input for the next turn, which is the whole loop.
The inputs that matter
previous_history(optional) - the history from an earlier call. Wire this in to keep growing one conversation instead of starting over.user_message(optional) - what the "user" said this turn.assistant_message(optional) - what the "assistant" replied.
One output: history - ready to feed the next LLM node, or back into this node's own previous_history socket.
Installing it
History Builder ships in ComfyUI-YogurtNodes. Install via ComfyUI Manager (search "ComfyUI-YogurtNodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Restart ComfyUI; it's under "Yogurt Nodes". No API key of its own - it's pure data plumbing, the keys live on the LLM nodes it feeds.
Where people get burned
Two things to keep straight. First, order matters and it's your job to maintain it: the history is whatever sequence you append, so keep user and assistant messages alternating if the model expects a normal conversation (most chat models get confused by two user turns in a row). Second, history isn't infinite - every appended turn grows the request, and long histories eat tokens (and cost money) on the paid nodes. When a conversation starts to behave oddly or get expensive, prune it: don't pass the full previous_history, or start a fresh builder. It's a dumb little list, and treating it like one is exactly right.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| previous_historyopt | HISTORY | 之前的会话历史 | |
| user_messageopt | STRING | 用户消息内容 | |
| assistant_messageopt | STRING | 助手回复内容 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| history | HISTORY | — |