Nodes/DJZ-Nodes/Think Tag Seeker
ComfyUI Node

Think Tag Seeker

Strip <think> reasoning out of LLM output before it hits your prompt

By MushroomFleet·Created 2 years ago·Updated 5 months ago· 78
Think Tag Seeker
    • STRING
    • STRING
    text

    If you've piped an LLM into a ComfyUI workflow recently, you've met the <think> tag. Reasoning models - DeepSeek-R1, Qwen with reasoning enabled, and a growing pile of RLM-finetuned models - emit their chain-of-thought wrapped in <think>...</think> before the actual answer. That reasoning text is gold for debugging and garbage for a text encoder. ThinkSeeker (shown in the UI as "Think Tag Seeker") exists to split the two apart: thinking on one output, clean response on the other.

    How it works

    It's a regex job, done right:

    • re.findall(r'<think>(.*?)</think>', text, re.DOTALL) grabs every thinking block, and they're joined with newlines into one thinking output.
    • The tags are stripped from the original text and the remainder, trimmed, becomes the response output.

    Two details matter. The DOTALL flag means thinking can span multiple lines and still match - which it always will, since reasoning output is usually paragraphs. And if there are no think tags at all, the thinking output is an empty string and the full text comes through as the response. No crash, no mangling, just a clean pass-through. That makes it safe to drop into a pipeline that sometimes gets thinking output and sometimes doesn't.

    Inputs and outputs

    One input: text (multiline). Two outputs, both STRING:

    • output 1 - the extracted thinking text
    • output 2 - the response text, tags removed

    Wire the response into your prompt builder (or CLIP/LLM encoder) and the thinking into a Show Text node if you want to watch the reasoning. Yes, both outputs are unnamed strings in the schema - the first is thinking, the second is response, in that order. Get them backwards and you'll be very confused about your "response."

    Why you need it

    ComfyUI's modern text-encoder world (covered in the prompt-engineering lore) is increasingly LLM-driven, and once you're on a chat-template encoder, the raw LLM output is your prompt. If you paste reasoning-model output straight in, you're prompting with "Let me think about this step by step" noise. ThinkSeeker is the extract-then-use pattern in one node - the same job a regex node from another pack would do, but without you writing the pattern.

    Install

    Ships in DJZ-Nodes by Drift Johnson. ComfyUI Manager → "DJZ-Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/DJZ-Nodes
    cd DJZ-Nodes
    pip install -r requirements.txt
    

    Restart ComfyUI. Zero dependencies beyond Python's re - this node is about as lightweight as DJZ gets, which is saying something for a pack whose requirements list includes librosa and trimesh.

    Gotchas

    It only understands <think> tags - if your model emits [thinking], reasoning, or no delimiters at all, this node sees plain text and passes it through. It also doesn't validate that tags are balanced; an unclosed <think> leaves the response polluted. For the common R1/Qwen case it's exactly right, just don't expect it to know every reasoning format in the wild.

    CategoryCustom-Nodes

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (2)

    NameTypeDescription
    STRINGSTRING
    STRINGSTRING