Merge

Description

The Merge node is the counterpart to the Dispatch node. It collects text from multiple input anchors and combines them into a single output string, inserting a configurable separator between each piece. It is the primary tool for reassembling content that was previously split into parallel branches (e.g., after translating multiple chunks of a document with separate Agents).

It is a convergence node: it waits for all its active input connections to deliver data before producing its output. The order of concatenation follows the anchor index (input 0 first, then input 1, etc.), ensuring deterministic and predictable results.


Configuration Properties

🔢 Input Count Section

NumericUpDown (default: 2)
Defines the number of input anchors. Each anchor represents one piece of content to merge. The node dynamically adds or removes input anchors when this value changes.

💡 Tip: Set this value to match the number of parallel branches you want to recombine. If you split a document into 4 chunks with a Dispatch node, set Input Count to 4 here.


🔗 Separator Section

TextBox
The string inserted between each piece of content in the final output.

  • Leave empty to concatenate directly (no separator).
  • Enter \n or press Enter in the box to insert a newline between pieces.
  • Enter , for comma-separated lists.
  • Enter --- or ### for visual section breaks.

The separator is inserted between pieces, not after the last one. For example, with 3 inputs (A, B, C) and separator \n, the output is A\nB\nC (no trailing newline).


Usage Example

"Reassemble translated document chunks":

  1. A Dispatch node splits a long document into 4 chunks (Output Count: 4).
  2. Four Agent nodes translate each chunk independently.
  3. A Merge node with:
    • Input Count: 4
    • Separator: \n\n (double newline to preserve paragraph breaks)
  4. The output is the complete translated document, with chunks reassembled in the correct order.

"Build a CSV line from multiple fields":

  1. Three Input nodes (or Template nodes) provide: Alice, 30, Engineer.
  2. A Merge node with:
    • Input Count: 3
    • Separator: ,
  3. Output: Alice,30,Engineer

⚠️ Pitfalls to Avoid

Input Count mismatch: If you set Input Count to 4 but only connect 3 branches, the fourth input will receive an empty string (or nothing, depending on the executor). The output will contain an extra separator at the end (e.g., A\nB\nC\n). Always match the input count to the actual number of connected branches.

Order matters: The merge order is strictly based on anchor index (0, 1, 2...), not on the order in which data arrives. If your parallel branches produce results at different times (e.g., one Agent is slower), the merge still respects the anchor order. This is usually what you want, but be aware that the output order is fixed, not temporal.

Empty inputs are included: If one of your branches produces an empty string (e.g., an Agent that found nothing to say), the Merge node still includes it with the separator. For example, merging A, "", C with separator \n produces A\n\nC (double newline). If you want to skip empty inputs, use a Filter node downstream or a Code node with custom logic.

Separator is literal: The separator is inserted as-is, without any special character interpretation. If you want a newline, you must actually type a newline in the TextBox (press Enter), not type \n as two characters. The box does not interpret escape sequences.

Convergence waits for all inputs: The Merge node only produces output when all its active input connections have delivered data. If one branch is blocked or never sends data (e.g., a conditional branch that was skipped), the Merge node will wait indefinitely. Ensure all branches are guaranteed to produce output, or use a Switch node to route around the Merge when a branch is inactive.

Not a source node: The Merge node has only input anchors, no output anchor until execution. It cannot start a workflow on its own — it must be downstream of at least one source node (Input, Memory Read in FixedKey mode, etc.).