ComfyUI Node

AZAll Chat History

Multi-turn chat that survives a queue reset

By cronos3k·Created 5 months ago·Updated 5 months ago· 0
AZAll Chat History
  • config
  • history_json
  • formatted_history
session_namechat
user_message
assistant_message
max_turns20
clear_historyfalse

The standard ComfyUI LLM setup is one shot: prompt in, answer out, then the context vanishes. AgentAZAll_ChatHistory fixes that by persisting a conversation as JSON on disk and letting you add to it turn by turn - so run 1 says "write a mystery opening," run 2 says "now introduce the detective," and the LLM still knows it wrote a mystery opening. True multi-turn chat, across queue runs and restarts.

The pattern is a loop, and the pack's demo makes it concrete: one ChatHistory node with user_message wired to your input, the LLM, then a second ChatHistory node with assistant_message wired to the LLM's response, both sharing the same session_name. The load-and-add happens in node one, the save-assistant in node two, and the whole thing rides the same JSON file.

How it works

Each execution, the node loads the existing history for the session, appends any new user_message and/or assistant_message you've fed it, trims the transcript down to max_turns (keeping the most recent), and writes it back to disk as <mailbox>/<agent>/<date>/notes/chat-history-<session>.txt - a JSON array of {"role": ..., "content": ...} objects. It emits both the raw JSON and a human-readable rendering.

That file is the conversation. Because it's a note in the mailbox tree, it inherits the whole pack's file-based persistence: plain text, inspectable, survives restarts.

The inputs that matter

  • config (required) - from AZAll Setup.
  • session_name (required, default chat) - the conversation's identity. Two nodes that share a name share a history; different names, different threads. This is the knob you set once and keep consistent.
  • user_message - new user turn to append.
  • assistant_message - the LLM's reply to append (wire from the LLM node).
  • max_turns (default 20, 1–100) - how many turns of context to keep; older turns get trimmed. Note the JSON is actually capped at max_turns * 2 entries (each turn is a user+assistant pair).
  • clear_history - set true to wipe the session and start fresh.

Two outputs: history_json (the raw transcript, what you'd feed a context window) and formatted_history (the [User]: ... / [Assistant]: ... rendering, better for human eyeballs and for prompt assembly).

Installing it

In cronos3k/comfyui-agentazall - Manager search "AgentAZAll", or:

cd ComfyUI/custom_nodes
git clone https://github.com/cronos3k/comfyui-agentazall.git
pip install "agentazall>=1.0.13"
# restart ComfyUI

No models, no keys - the persistence is just files.

Common issues

The two classic mistakes: forgetting that it's append-only per run (if you wire the same node to both the user input and the LLM output, you'll double-add the assistant turn), and letting max_turns bite you - with a long session, older context silently falls off the end, so don't expect it to remember run 1 of 50. History is also per-day on disk; the read side searches back for the latest copy, but a new date can surprise you if you expected one uninterrupted thread. If a session seems to have vanished, check mailbox_dir hasn't moved (the pack-wide cwd gotcha). When it works, it's genuinely the nicest way to get a real conversation out of ComfyUI.

CategoryAgentAZAll/Messaging

Inputs (6)

NameTypeDefaultDescription
configAZALL_CONFIG
session_nameSTRINGchat
user_messageoptSTRING
assistant_messageoptSTRING
max_turnsoptINT201–100
clear_historyoptBOOLEANfalse

Outputs (2)

NameTypeDescription
history_jsonSTRING
formatted_historySTRING