Nodes/ComfyUI-LLM-Session/LLM Session Chat
ComfyUI Node

LLM Session Chat

Persistent multi-turn chat with local GGUF models using file-based history.

By kantan-kanto·Created 7 months ago·Updated about a month ago· 27
LLM Session Chat
  • media
  • assistant_text
user_text
session_iddefault
model(No GGUF models found in models/LLM/)
mmproj(Auto-detect)
system_promptYou are a helpful assistant.
max_tokens512
temperature0.70
top_p0.90
n_gpu_layers0
n_ctx4096
persistent_cacheoff
runtime_cacheLlamaTrieCache
log_leveltiming
suppress_backend_logstrue
repeat_penalty1.12
repeat_last_n256
rewrite_continuetrue
max_turns12
summarize_old_historytrue
summary_chunk_turns3
max_tokens_summary128
summary_max_chars1500
dynamic_max_tokenstrue
min_generation_tokens96
safety_margin_tokens64
history_dir
reset_sessionfalse
stream_to_consolefalse
enable_thinkingfalse
CategoryLLM/Session

Inputs (30)

NameTypeDefaultDescription
user_textSTRINGUser message for this turn
session_idSTRINGdefaultSession ID (maps to a history file). Same ID continues the chat.
modelCOMBO(No GGUF models found in models/LLM/)GGUF model file in models/LLM/
mmprojCOMBO(Auto-detect)Manual selection is recommended.
system_promptSTRINGYou are a helpful assistant.System prompt (conversation policy). Saved into the history file.
max_tokensINT5121–32768Maximum tokens to generate for this turn
temperatureFLOAT0.700–2Sampling temperature
top_pFLOAT0.900.05–1Nucleus sampling (top_p). Lower = safer/more conservative.
n_gpu_layersINT0-1–200Number of layers to offload to GPU. 0=CPU. -1=all.
n_ctxINT4096512–131072Context length (must be supported by the model)
mediaopt*Optional IMAGE tensor/batch or AUDIO input for this turn only (never saved to history)
persistent_cacheoptCOMBOoffPersistent cache backend. LlamaDiskCache stores cache data under a session-specific cache directory in output/llm_session_sessions/cache/.
runtime_cacheoptCOMBOLlamaTrieCacheRuntime cache backend. KV_cache uses save_state/load_state, RAM/Trie use llama.cpp cache in memory.
log_leveloptCOMBOtimingConsole logging verbosity for LLM Session Chat.
suppress_backend_logsoptBOOLEANtrueSuppress backend stdout/stderr during generation.
repeat_penaltyoptFLOAT1.121–2Repetition penalty to reduce looping outputs (especially on continue).
repeat_last_noptINT2560–4096Apply repeat_penalty over the last N tokens. 0 disables.
rewrite_continueoptBOOLEANtrueRewrite inputs starting with 'continue' into an explicit continuation instruction to reduce repetition.
max_turnsoptINT120–200Keep only the last N turns in live context. 0 means no prior turns.
summarize_old_historyoptBOOLEANtrueSummarize overflow turns into a rolling summary when turns exceed max_turns.
summary_chunk_turnsoptINT31–50Summarize overflow in chunks of this many turns (reduces summary frequency).
max_tokens_summaryoptINT12816–2048Max tokens for summary generation (kept small for speed).
summary_max_charsoptINT1500200–20000If the rolling summary exceeds this size, it will be re-summarized to stay compact.
dynamic_max_tokensoptBOOLEANtrueDynamically shrink max_tokens (and/or turns) when prompt would exceed n_ctx.
min_generation_tokensoptINT961–4096Minimum tokens to allow for generation when dynamic_max_tokens is enabled.
safety_margin_tokensoptINT640–2048Token margin reserved to reduce the chance of exceeding n_ctx.
history_diroptSTRINGOptional directory for history files and session-scoped disk caches. Empty uses output/llm_session_sessions/
reset_sessionoptBOOLEANfalseIf true, overwrite existing session history file with a fresh session. Session disk cache is kept.
stream_to_consoleoptBOOLEANfalseStream tokens to console while generating.
enable_thinkingoptBOOLEANfalseEnable model thinking/reasoning output for supported chat formats.

Outputs (1)

NameTypeDescription
assistant_textSTRING