NanoBanana - Multi-Turn Chat
A chat node that remembers what it said last turn
- network
- response
- conversation_history
Most LLM nodes in ComfyUI are one-shot: prompt in, answer out, amnesia. This node is the exception. It keeps conversation history, so you can hold an actual back-and-forth - ask a question, follow up, correct it, ask again - and the model remembers the thread. The state lives in the graph, not hidden inside the node, which is both the feature and the thing you have to understand.
It's for the workflows that genuinely need multi-turn reasoning: refining an idea by iterating on it verbally, a Q&A session over a spec you pasted into the first message, an agent-ish loop where each turn's answer feeds the next decision. If you only need "one question, one answer," the pack's plain Text Generation node is cheaper and simpler - this one carries conversation baggage by design.
How it works
The state mechanism is refreshingly boring: history is a JSON string that flows through the graph. On each run you pass the previous turn's history in via conversation_history, the node appends your new message, sends the whole thread to the model, and returns both the response and an updated conversation_history JSON. Wire the history output back into the history input of the same node and you've built a loop that accumulates context.
Inputs:
- message - the new user message for this turn.
- conversation_history - JSON from a previous turn. Leave empty to start fresh.
- model - defaults to
gemini-2.5-flash(sensible: flash is cheap enough to chat with). - system_instruction - sets the persona/constraints.
- temperature - default 0.7.
Outputs: response (the model's answer) and conversation_history (the JSON to feed forward).
Two implementation notes that matter. The history JSON is an array of {role, text} entries - user and model turns alternating - so if you ever need to hand-editor reset the thread, just clear the input. And if you feed it malformed JSON it logs a warning and starts fresh rather than crashing, which is the right failure mode for a graph that re-runs constantly.
Installation
Part of the NanoBanana2 pack:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai
ComfyUI Manager: search NanoBanana2. Needs a Gemini API key from aistudio.google.com.
Gotchas
The big gotcha is context bloat: every turn re-sends the entire history, so a long conversation costs more tokens each message and eventually hits the context window. For long threads, prune the history JSON or restart with a summary. Also remember the whole pack re-executes on every queue - if you don't wire the history output back to the input, the node "forgets" between runs, and that's expected, not a bug. And since history is just a string, you can't attach images to the chat (unlike a vision node); keep it text.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | NanoBanana - API key. Leave blank to use GEMINI_API_KEY env var. | |
| model | COMBO | gemini-2.5-flash | NanoBanana - model for chat. |
| custom_model | STRING | Override with a custom model ID. | |
| message | STRING | The new user message to send. | |
| conversation_historyopt | STRING | JSON conversation history from previous turn. Leave empty to start fresh. | |
| system_instructionopt | STRING | System instruction for the chat. | |
| temperatureopt | FLOAT | 0.700–2 | Controls randomness. |
| networkopt | NB_NETWORK | Optional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |
| conversation_history | STRING | — |