Nodes/MRLN Nodes/Prompt Enhance (MRLN)
ComfyUI Node

Prompt Enhance (MRLN)

An LLM rewrite that can't lose your trigger words

By master-merlin·Created about a month ago·Updated 28 days ago· 3
Prompt Enhance (MRLN)
    • prompt
    • report
    backend
    model
    temperature0.20
    seed0
    max_tokens512
    timeout60
    free_vram
    on_error
    llm
    prompt
    system

    LLM prompt-enhancers are everywhere now, and the community has learned their failure modes the hard way: they add detail you never asked for, they emit chat instead of a clean prompt, and they eat your trigger words. Prompt Enhance (MRLN) is built around those specific failures rather than pretending they don't exist. It's the optional LLM rewrite stage of this pack, and it takes exactly ONE wire - the llm output of the Prompt Template node.

    That wire is the interesting part. It doesn't just carry the rendered prompt; it carries the selected profile's system prompt - which tells the LLM how the target image model wants its prompts, prose for KREA/FLUX, tags for SDXL/Pony - plus the LoRA trigger words riding the prompt. Those trigger words are protected: demanded verbatim in the system prompt, verified after the rewrite, and any span the model dropped or mutated is re-injected. An enhancement can never disarm a LoRA, which is more than most enhancers on the market can claim.

    How it works

    Backends are local Ollama / LM Studio (URLs configured in the Composer's Settings tab) or cloud Anthropic / OpenAI / Gemini / OpenRouter (API keys stored server-side, never in node widgets - in the browser, only keyed backends are even listed). The rewrite is deterministic per seed where the backend supports it, cached per input so re-queues never re-call, and a failing backend passes the original prompt through instead of killing the render - switchable with on_error.

    Ollama gets special treatment: free_vram: after call (the default) unloads the LLM immediately so the diffusion model gets the GPU back. On a single card that's the difference between an enhancer you can live with and one that OOMs every render.

    The inputs that matter

    • backend and model - model is required for Ollama; LM Studio falls back to its loaded model; cloud backends fall back to a sensible default.
    • temperature - keep it low. 0.2 is the default, and it's the right number for faithful rewrites.
    • free_vram - after call is the one-GPU recommendation. keep 5m if you're iterating hard, always keep only on a second GPU.
    • on_error - pass through means a dead backend never kills a render; raise stops the queue loudly instead.

    There are two optional inputs worth knowing: prompt enhances any other STRING and wins when both it and llm are wired (use it on text from any node), and system overrides the profile's system prompt when you want to steer the rewrite yourself.

    Outputs: prompt - the enhanced prompt, or the original on pass-through - and report, which tells you backend, model, seed, cache/VRAM state, or the pass-through reason.

    The honest take

    The README says it plainly: this node is best on thin hand-typed prompts and tag→prose conversion - the curated library usually renders better un-rewritten. So it's not a "make everything better" button. It's for when you have a rough idea you want expanded for a specific target model, or a tag list you want turned into prose for a FLUX/KREA-class model. The max_tokens handling is a nice touch: a keep-everything rewrite can never be shorter than its input, so the cap auto-raises rather than silently truncating the tail of a long prompt (the report notes when that happens).

    How to install it

    Same pack, same note: ComfyUI Manager can't find this pack yet - the registry flagged v0.1.1 on six severity: info matches (including the LLM backend calls, which is part of why it's flagged), so it's absent from Manager's search. Review hiccup, not a broken node. Manual install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/master-merlin/comfyui-mrln-nodes ComfyUI-MRLN-Nodes
    

    Restart ComfyUI. No extra Python dependencies - requirements.txt is deliberately empty. You'll want Ollama running if you use the local path, but that's a separate install.

    Common issues

    • The render works but the prompt is unchanged - backend unreachable with on_error: pass through. Check the report output; it names the reason.
    • VRAM contention on one GPU - Ollama and the diffusion model fighting over the card. Set free_vram to after call and don't keep the LLM resident.
    • "Model name required" - Ollama needs a real model id like gemma3:12b; it won't guess.

    A dead backend never breaks a render by default, which is the right default - but it also means "it silently did nothing" is the failure mode to watch for.

    CategoryMRLN/prompt

    Inputs (11)

    NameTypeDefaultDescription
    backendCOMBOLLM backend. Local: Ollama / LM Studio (URLs in the Composer's Settings tab). Cloud backends need an API key stored there — in the browser only keyed ones are listed.
    modelSTRINGModel name, e.g. 'gemma3:12b' (Ollama) or an LM Studio model id. Required for Ollama; LM Studio falls back to its loaded model; cloud backends fall back to a sensible default. In the browser this becomes a dropdown of installed models plus pull suggestions Ollama downloads on pick.
    temperatureFLOAT0.200–2Sampling temperature — keep low for faithful rewrites.
    seedINT00–18446744073709550000LLM seed for reproducible rewrites (where the backend supports it). 0 derives a stable seed from the prompt + system text, so identical inputs enhance identically.
    max_tokensINT51216–8192Generation cap for the rewrite. Auto-raised when the input is longer than the cap allows — a keep-everything rewrite can never be shorter than its input (the report notes when this happens).
    timeoutINT605–600Seconds to wait for the backend before giving up.
    free_vramCOMBOOllama keep_alive: 'after call' unloads the LLM immediately so the diffusion model gets the VRAM back (recommended on one GPU); 'keep 5m' keeps it warm for rapid iteration; 'always keep' pins it loaded until Ollama stops (second GPU / big VRAM). LM Studio manages its own lifetime.
    on_errorCOMBOWhen the backend is unreachable or errors: pass the ORIGINAL prompt through (render never dies, report says why) or raise and stop the queue.
    llmoptSTRINGThe Prompt Template node's llm output — the single wire: {target, prompt, protect, system, params}. It carries the rendered prompt, the profile's system prompt, and the LoRA trigger words that are enforced verbatim (dropped ones are re-injected).
    promptoptSTRINGOptional override: enhance this STRING instead of the prompt carried inside the llm input (wins when both are wired). Use it to enhance text from any other node.
    systemoptSTRINGSystem prompt override. Empty = use the llm input's system prompt; set both and this one wins (template guides, user decides).

    Outputs (2)

    NameTypeDescription
    promptSTRINGThe enhanced prompt (or the original on pass-through).
    reportSTRINGWhat happened: backend, model, seed, cache/VRAM state, or the pass-through reason.