Lesson 13 / 25

Variable Aggregator and Merging Branches

Bring branches back together.

One variable from many paths

When different branches produce the same kind of result (an answer from the billing branch or the technical branch), a variable aggregator merges them into one variable, so downstream nodes and the end node have a single reference regardless of which branch ran. Without it you must duplicate downstream nodes per branch. Keep the merged variable's type identical across branches. Dify's node names, menus and options change between versions; check the current Dify documentation.

Before and after aggregation

Aggregation avoids duplicated end logic.

without aggregator                          with aggregator
billing LLM  -> format -> end A             billing LLM   \
technical LLM -> format -> end B            technical LLM  -> aggregator(answer) -> format -> end
general LLM  -> format -> end C             general LLM   /

Aggregate before formatting

Merge branch answers first, then apply shared formatting and safety checks once.

Quick check: What problem does the variable aggregator solve?

  • It trains the classifier
  • It lets downstream nodes use one variable regardless of which branch ran
  • It deletes branches
  • It uploads documents
Answer

It lets downstream nodes use one variable regardless of which branch ran — Merge results from alternative paths.