Nodes/ComfyUI-ZMongo/10 Find Similar Successful Prompts
ComfyUI Node

10 Find Similar Successful Prompts

What worked the last time I generated something like this?

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
10 Find Similar Successful Prompts
  • text_agent_config
  • ranked_context
  • json
  • success
query_prompt
source_collectiontext_agent_ledger
limit12
field_paths_csvpayload.final_prompt,payload.best_positive_prompt,payload.evolution.best.positive_prompt,payload.score,payload.notes,record_type,created_at
refresh_token

If you've been using the ZMongo text-agent suite - "10 Save Prompt Provenance Ledger" writing every successful prompt, critic score, and evolution history into the ledger collection - then this node is the reward. "10 Find Similar Successful Prompts" takes a new prompt you're about to run, digs through your saved generation history, and has an LLM rank the most relevant past successes as context you can feed back into your workflow. It's a memory of "what worked" that your future prompts get to consult.

How it works

The two required inputs are text_agent_config (a typed ZMONGO_TEXT_AGENT_CONFIG that comes out of "10 Text Agent Session" - it carries your project name, model, collection names, and the session) and query_prompt, the new prompt you're working on. From there it:

  1. Queries source_collection (default text_agent_ledger) for records matching your project_name, newest first, up to limit (default 12).
  2. Builds a text context from those records using field_paths_csv (default payload.final_prompt,payload.best_positive_prompt,payload.evolution.best.positive_prompt,payload.score,payload.notes,record_type,created_at) - this is the list of fields it pulls out of each saved record, capped at roughly 16k characters so the context stays bounded.
  3. Sends that context plus your query_prompt to Gemini (through the session's /api/chat) with a system instruction to rank the stored records by usefulness for improving the new prompt - "focus on successful reusable prompt fragments and warnings."
  4. Returns ranked_context (the LLM's ranked answer - wire this into a text viewer or an LLM context node), json (full payload with the source records and Gemini response), and success.

The whole thing is grounded in data you saved on purpose. No ledger records for your project → an empty context, which produces a mostly useless ranking. This node is only as good as your habit of logging prompts.

Install

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

Restart ComfyUI, or install "ComfyUI-ZMongo" via ComfyUI Manager.

Where people get burned

This is the deepest node in the 20-article pack - it assumes the whole text-agent stack is running: a "10 Text Agent Session" with a hosted session (Gemini calls go through the backend's /api/chat, so Local File Store mode won't satisfy it), a ledger you've actually been writing to, and a project name that matches across all of them. Skip any of that and you'll get empty or near-useless results, which looks like a bug but is really a missing dependency in your graph.

Second, the project-name filter is the hidden coupling. project_name is baked into the text_agent_config and used as the ledger query filter. If your Save node logged under "project_a" and this node's session config says "default", it will find zero records. Keep the project name consistent across the session, the save nodes, and this node.

Third, the default field_paths_csv assumes the ledger's standard schema (the payload.final_prompt / payload.evolution.best.* shape). If you customized what you save, adjust the CSV to your actual fields or the context will be full of blanks. And ranked_context is prose from an LLM, not structured data - treat it as a suggestion-rich string, not a parsed result.

CategoryZMongo/07 Text Agents/Provenance

Inputs (6)

NameTypeDefaultDescription
text_agent_configZMONGO_TEXT_AGENT_CONFIG
query_promptSTRING
source_collectionoptSTRINGtext_agent_ledger
limitoptINT121–50
field_paths_csvoptSTRINGpayload.final_prompt,payload.best_positive_prompt,payload.evolution.best.positive_prompt,payload.score,payload.notes,record_type,created_at
refresh_tokenoptSTRING

Outputs (3)

NameTypeDescription
ranked_contextSTRING
jsonSTRING
successBOOLEAN