10 Prompt Evolver
Generate N variants, keep the best one
- text_agent_config
- best_positive_prompt
- best_negative_prompt
- json
- success
- refresh
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_promptequals your base prompt - Gemini didn't return parseable JSON, so the node fell back. Checkjson→raw_textto 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_modetoo narrow. Raise the session temperature toward 0.7-1.0 and loosen the mode string. - Token costs surprise you - every variant plus the
bestselection rides one request. Dialvariant_countdown 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.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| text_agent_config | ZMONGO_TEXT_AGENT_CONFIG | — | |
| base_prompt | STRING | — | |
| variant_count | INT | 41–20 | — |
| context_packopt | STRING | — | |
| mutation_modeopt | STRING | cinematic, specific, production-ready | — |
| target_modelopt | STRING | ComfyUI image/video model | — |
| save_to_ledgeropt | BOOLEAN | true | — |
| refresh_tokenopt | STRING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| best_positive_prompt | STRING | — |
| best_negative_prompt | STRING | — |
| json | STRING | — |
| success | BOOLEAN | — |
| refresh | STRING | — |