Nodes/ComfyUI-ZMongo/10 Prompt Evolver
ComfyUI Node

10 Prompt Evolver

Generate N variants, keep the best one

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
10 Prompt Evolver
  • text_agent_config
  • best_positive_prompt
  • best_negative_prompt
  • json
  • success
  • refresh
base_prompt
variant_count4
context_pack
mutation_modecinematic, specific, production-ready
target_modelComfyUI image/video model
save_to_ledgertrue
refresh_token

Prompt Evolver is the "make me a better version of this prompt" node. You hand it a base_prompt, it asks Gemini to produce a handful of improved variants - each with a positive prompt, a negative prompt, a reason, and a self-assessed score - then it picks the best one and hands you the winner as best_positive_prompt and best_negative_prompt, ready for wiring into conditioning.

It's the same family as Prompt Critic, but with a different temperament: the critic reviews one prompt, the evolver explores a space. If you have a prompt that's almost right, or you're stuck in a rut of the same generic phrasing, this is the node that shakes the tree. variant_count defaults to 4 and caps at 20 - remember every variant is a Gemini call bundled into one request, so each run costs real tokens on the hosted backend.

How it works

The node builds an evolution prompt containing your base_prompt, the mutation_mode (default cinematic, specific, production-ready - the author's idea of a good mutation direction), the target_model, and any context_pack. It calls Gemini with a JSON schema that requires each variant to carry index, positive_prompt, negative_prompt, reason, and score, plus a best selection. It uses your session's temperature but never below 0.2, so the variants actually vary.

The output parses that JSON and extracts the best positive and negative prompts. If Gemini returns garbage, it falls back to returning your original base_prompt with an empty negative rather than crashing. With save_to_ledger on (default), the whole evolution - variants, best pick, reasoning - is stored in the ledger as a prompt_evolution record, so you can look back at what won and why.

Inputs and outputs that matter

  • text_agent_config - from a Text Agent Session node. Required, and it needs a hosted API session.
  • base_prompt - the starting point.
  • variant_count - 1 to 20, default 4.
  • mutation_mode - the direction mutations should take.
  • context_pack - optional project memory/context to steer the variants.
  • save_to_ledger - default true.

Outputs: best_positive_prompt and best_negative_prompt (the two you'll actually use), plus json (full evolution payload), success, and refresh.

Installing it

Pack-level, same as every ZMongo node:

cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo

Restart ComfyUI or install via ComfyUI Manager. The requirements.txt is heavy (pymongo, langchain, sentence-transformers, transformers), so the first install takes a while.

Common issues

  • best_positive_prompt equals your base prompt - Gemini didn't return parseable JSON, so the node fell back. Check jsonraw_text to see what came back; usually the model dropped the schema.
  • Variants all look the same - temperature too low on your Text Agent Session, or mutation_mode too narrow. Raise the session temperature toward 0.7-1.0 and loosen the mode string.
  • Token costs surprise you - every variant plus the best selection rides one request. Dial variant_count down for everyday use.
  • Negative prompt output is empty - the model didn't supply one for the winner. On many modern guidance-distilled models the negative does little anyway; restate constraints positively instead.
CategoryZMongo/07 Text Agents/Prompt Agents

Inputs (8)

NameTypeDefaultDescription
text_agent_configZMONGO_TEXT_AGENT_CONFIG
base_promptSTRING
variant_countINT41–20
context_packoptSTRING
mutation_modeoptSTRINGcinematic, specific, production-ready
target_modeloptSTRINGComfyUI image/video model
save_to_ledgeroptBOOLEANtrue
refresh_tokenoptSTRING

Outputs (5)

NameTypeDescription
best_positive_promptSTRING
best_negative_promptSTRING
jsonSTRING
successBOOLEAN
refreshSTRING