10 Find Similar Successful Prompts
What worked the last time I generated something like this?
- text_agent_config
- ranked_context
- json
- success
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:
- Queries
source_collection(defaulttext_agent_ledger) for records matching yourproject_name, newest first, up tolimit(default 12). - Builds a text context from those records using
field_paths_csv(defaultpayload.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. - Sends that context plus your
query_promptto 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." - 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), andsuccess.
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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text_agent_config | ZMONGO_TEXT_AGENT_CONFIG | — | |
| query_prompt | STRING | — | |
| source_collectionopt | STRING | text_agent_ledger | — |
| limitopt | INT | 121–50 | — |
| field_paths_csvopt | STRING | payload.final_prompt,payload.best_positive_prompt,payload.evolution.best.positive_prompt,payload.score,payload.notes,record_type,created_at | — |
| refresh_tokenopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| ranked_context | STRING | — |
| json | STRING | — |
| success | BOOLEAN | — |