Nodes/LM Studio Tools for ComfyUI/📌 Get Assistant Message
ComfyUI Node

📌 Get Assistant Message

Grab a specific LLM reply out of the conversation history

By Hazukiaoi·Created about a year ago·Updated about a year ago· 24
📌 Get Assistant Message
  • message
  • text
index-1

If you've built a multi-turn conversation with this pack, you'll eventually hit the moment where you want one specific reply from the middle of it - and that's what 📌 Get Assistant Message is for. It pulls a single assistant (model) reply out of a MESSAGE object and hands it to you as plain text. In a one-shot workflow you'll never need it - 📡 LMStudio Request already gives you output_text for the latest reply. It starts earning its keep once you chain requests together and want an earlier answer.

The two inputs

  • message - the MESSAGE conversation object, e.g. the message_out from a Request node.
  • index - an integer, default -1. The indexing rule: -1 is the last assistant reply, 0 is the first, 1 the second, and so on.

Output is a single text string - the content of that reply. And one detail that surprises people: it indexes over assistant messages only. System and user turns don't count toward the index. So index 0 means the first reply the model gave, not the first message in the conversation.

Why you'd reach for it

The classic pattern is a two-stage LLM workflow. Stage one: "Draft five prompt variations for this image." Stage two: "Take prompt 3 and expand it with lighting details." Both stages are separate 📡 LMStudio Request nodes chained through message_out👤 User Prompt → next Request, so by the end your MESSAGE holds the whole history - and the last reply is stage two's output. The first stage's "prompt 3" is buried in there. That's this node's job: index = 2 (or whatever) to fish it out.

It's also handy for debugging. If you've been appending turns and something looks off, drop this node on the history with index -1, 0, and 1 into a Preview node to actually see what the model said at each step - faster than reading the ComfyUI console.

The failure modes (they're gentle)

  • Out-of-range index - you ask for reply 5 of 3. Rather than crashing, it returns an empty string. Your downstream nodes get "", which is usually safe but can silently look "fine" when it isn't.
  • No assistant messages at all - same thing: empty string.
  • The message content isn't plain text - if the conversation includes vision turns, the user messages are structured content, but assistant replies in this pack are always plain strings, so the output is safe to wire into anything expecting text.

Install and context

Pack install is the standard one - ComfyUI Manager, search "LM Studio Tools", or git clone https://github.com/Hazukiaoi/ComfyUI-LM_Studio_Tools into ComfyUI/custom_nodes, then restart. Only dependency is requests, and nothing downloads models; the model runs in LM Studio with its Local Server on.

A quick note on where this fits in the pack's design: the whole MESSAGE system is the author's own lightweight object - a list of {role, content} dicts in the standard OpenAI chat shape that the nodes pass around and the Request node posts straight to LM Studio. Get Assistant Message is just a read-only view onto that history. It's a small, specific tool, and it fills a real gap: without it, extracting a mid-conversation reply means either restructuring your whole workflow or reading raw console logs. Drop it on a wire, set the index, and you're done.

CategoryLM Studio Tools

Inputs (2)

NameTypeDefaultDescription
messageMESSAGE
indexINT-1

Outputs (1)

NameTypeDescription
textSTRING