Skip to main content

Branch

Picks one of its output branches at random each time it runs.

Purpose

Varies behaviour so automation is less uniform — alternate routes, randomise which strategy runs, or split work between two paths.

The branches you wire on the canvas are the candidate list. There is no separate configuration of what can be chosen.

When to use it

  • Alternating between several equivalent routines so runs are not identical.
  • Splitting traffic between two strategies to compare them.
  • Choosing a starting direction, target, or order at random.

When not to use it

  • To decide based on data — use If.
  • When one path must always run first — Branch gives no ordering guarantee (except that noRepeat cycles).
  • To retry — use a Loop or a retry policy.

Requirements

Every branch port must be wired. Validation enforces it, because an unconnected branch would randomly dead-end the run.

How it runs

  1. Build the candidate list from the node's wired branch ports (branch1branchN).
  2. Pick one using the chosen Mode.
  3. Route down the selected branch and record which one was chosen (output: selectedBranch, mode, branchCount).

Settings

SettingTypeRangeNotes
Modechoicerandom, noRepeat, weightedRequired
Branch countinteger2–8Required. Each adds a port on the canvas
Weightsmap1–100 per branchWeighted mode; a missing entry defaults to 1

The three modes

ModeBehaviour
randomUniform. Can repeat the same branch consecutively
noRepeatA shuffled bag — every branch is used before any repeats
weightedHigher weight is chosen more often

noRepeat is usually what people mean by "random". Uniform random will happily pick the same branch three times running; the no-repeat bag will not.

The no-repeat bag spans loop iterations within one run and resets between runs.

Ports

PortTaken whenRequired
branch1…branchNThat branch was selectedAll required
FatalThe mode or branch count is invalidNever followed

Branch is the strictest node in the product for wiring: every single branch port must be connected.

Basic example

A 50/50 split between two routes:

  • Mode: Random
  • Branch count: 2

Realistic example — vary the scan order

Scanning the same direction first on every run is a recognisable pattern. Rotating it is one node:

Branch chooses; a variable records the choice; a switch acts on it. Separating "choose" from "act" keeps the graph readable and lets later nodes know which route was taken.

Advanced example — weighted strategies

Run an expensive thorough routine one time in five, and a fast routine the rest:

  • Mode: Weighted
  • Branch count: 2
  • Weights: branch1 = 4 (fast), branch2 = 1 (thorough)

Best practices

  • Wire every branch. It is required, and an unwired one would dead-end the run.
  • Prefer noRepeat for variety. Uniform random clusters.
  • Record the choice in a variable so later nodes and the run log can tell what happened.
  • Keep branches equivalent in outcome. Random selection should vary how, not whether, the work gets done.
  • Use weights instead of nesting Branch nodes to express uneven odds.

Performance notes

  • Selection is a pure computation — effectively free.
  • The cost is entirely in what the branches do. If one branch is much slower, your average run time is the weighted average, not the fast path.

Memory notes

  • The no-repeat bag is a small per-run structure; negligible.
  • Nothing persists between runs — the bag resets each run.

Common mistakes

MistakeWhat happensFix
Leaving a branch unwiredValidation error; would dead-end at run timeWire all of them
Expecting Random to alternateUniform random repeatsUse noRepeat
Using Branch for a data decisionNon-deterministic behaviourUse If
Weights that do not sum to 100Not a problem — they are relativeNo fix needed
Branches with different outcomesRuns succeed or fail at randomMake branches equivalent

Troubleshooting

The same branch keeps being chosen. Mode is random. Switch to noRepeat.

Validation fails on the node. One or more branch ports is unwired.

A branch never seems to run. In weighted mode its weight may be very low relative to the others.

Lowering the branch count removed an edge. Expected — trailing ports are dropped and orphaned edges pruned.

FAQ

How many branches can I have? 2 to 8.

Does no-repeat reset between runs? Yes. It spans loop iterations within a run only.

What weight does a branch get if I omit it? 1.

Can I see which branch was chosen? Yes — the output records selectedBranch, and it appears in the run log.

  • If — decide on data instead of chance
  • Variable — record the choice
  • Loop — repetition, where no-repeat spans iterations
  • Wait — random durations, the other source of variation