Nodes/ComfyUI Agent Bridge/Agent Variant Switch
ComfyUI Node

Agent Variant Switch

An A/B/C/D box that only runs the branch you pick

By abuzreq·Created 23 days ago·Updated 23 days ago· 1
Agent Variant Switch
  • candidates
  • selected
  • index
  • label
◄selected1►
◄labels►

Comparing variants shouldn't cost three renders

If you want to know which of three prompts, three LoRAs or four seeds actually looks best, the naive graph runs all of them and you delete two-thirds of the output. The usual fix is a switch node, and the usual switch node picks automatically - rgthree's Any Switch takes the first non-null input, which is great when the graph should decide and useless when you should.

Agent Variant Switch is the human one. You connect N candidates, it draws labelled radio buttons on the node, and whichever button is lit is the only branch that gets evaluated. Then it records your pick for the agent.

The lazy part is the whole trick

The candidates input is an autogrow slot - it grows live as you connect things, up to ten. The slots share a single match-type template, which means everything you connect must be the same type. Feed it three MODELs, or three LATENTs, or three IMAGEs; you can't mix a MODEL into slot 1 and a LATENT into slot 2. That's a feature dressed as a limitation: because the type is shared, the output's type is inferred from what's plugged in, so the same node serves as a model switch, a latent switch, an image switch, a conditioning switch.

The slots are declared lazy, and the node implements check_lazy_status to ask ComfyUI for only the selected candidate when it hasn't been computed yet. So the unselected branches genuinely never execute - no wasted sampler time, no wasted VRAM. A four-seed comparison becomes one render plus four radio buttons. That's the reason to use this over a pile of Mute nodes.

Inputs, and the two that matter

  • candidates - the grown slots. Connect at least one; the node raises an error if every slot is empty rather than quietly passing nothing through.
  • selected - the 1-based index of the candidate to pass on. This is what the radio buttons drive when you click them, and it's also the one you'd set programmatically.
  • labels - one label per line, in candidate order, shown next to the radio buttons. Same trap as everywhere in this pack: blank lines are dropped, so the survivors get renumbered and your third candidate inherits the fourth line's name. Write them all.

If you leave a label line short, the node fills in candidate N for the gaps, so an unlabelled switch still works - you just get buttons that say "candidate 2," which is exactly as useless for a human as it sounds.

Outputs

  • selected - the winning value, passed through untouched. Type follows whatever you connected.
  • index - the 1-based INT that was actually used.
  • label - the matching label as a STRING.

index is more useful than it looks. Feed it into a save-text or a filename node and your outputs self-document: run five variants across five rounds and the filename tells you which branch produced it. label is a plain string, so you can forward it into an AgentReportSink alongside whatever the branch produced.

The pick is recorded, and the agent gets it

Every execution writes {index, label, count, labels} into the node's UI output, which lands in ComfyUI's own /history and is picked up by the pack's run events as switch_picks:

"switch_picks": [{"node": "27", "index": 2, "label": "B · scale in.mid ×0.7", "labels": ["…"]}]

That's the loop closing. An agent proposes three variants with labels, you click one and hit Run, and the next event it polls says index: 2, label: "B · scale in.mid ×0.7" - no transcription, no "the second one, I mean the blue one." It also means the picks are all in one session log you can read back later.

selected is clamped rather than trusted: set it to 5 with two candidates connected and you get candidate 2, not an error. Convenient when a vote drives it - pair it with Agent Feedback's chosen_index output and the round's winning image selects the next round's branch, with the −1 no-vote case falling back to candidate one.

Install

Same pack, same rules. ComfyUI ≥ 0.18 and frontend ≥ 1.40 - this is the node most sensitive to that floor, since autogrow and match-type inputs are both new-frontend features. No Python dependencies; the pack deliberately doesn't pin your frontend so installing it can't move you off a version that works.

cd ComfyUI/custom_nodes
git clone https://github.com/abuzreq/ComfyUI-Agent-Bridge

ComfyUI Manager search is Agent Bridge; comfy-cli is comfy node install comfyui-agent-bridge. Restart, then look under the agent_bridge category.

Where people get burned

No candidates input at all. Old frontend. The node will look like an empty shell with a selected int and a labels box. Update ComfyUI - this is not a bug you can configure around.

"Type mismatch" when connecting slot 2. The slots are one mirrored type. You can't compare a MODEL against a CLIP in the same switch. If you genuinely need to compare different kinds of thing, use two switches.

A node you expected to run didn't. That's the lazy evaluation earning its keep. Anything upstream of an unselected candidate is skipped, including side-effect nodes - a save-image or a report sink sitting on candidate 3 won't fire unless candidate 3 wins. Read it as a feature, but know it.

The switch always picks candidate 1. Something upstream is feeding selected a value of −1 or 0 and it's clamping up. Check whatever wrote it.

Categoryagent_bridge

Inputs (3)

NameTypeDefaultDescription
candidatesCOMFY_AUTOGROW_V3—
selectedINT11–101-based index of the connected candidate to pass on
labelsSTRINGOne label per line, in candidate order (shown as radio buttons)

Outputs (3)

NameTypeDescription
selectedCOMFY_MATCHTYPE_V3—
indexINT—
labelSTRING—