Dispatch
Description
The Dispatch node splits a single incoming text into multiple parts and routes them to different output anchors. It is the primary tool for parallelizing work: instead of sending a huge document to a single Agent (which might truncate or lose focus), you can slice it into manageable chunks and process them simultaneously or sequentially across multiple branches.
It supports various splitting strategies (by character, word, line, or block) and includes an Overlap feature to preserve context across cuts, which is critical for maintaining narrative or logical continuity when processing long texts with AI.
Configuration Properties
🔢 Output Count Section
NumericUpDown (default: 2)
Defines the number of output anchors. The node will attempt to distribute the split content across these outputs.
Note: If the splitting results in more chunks than the Output Count, the behavior depends on the implementation (typically round-robin distribution or filling outputs sequentially).
️ Split Mode Section
ComboBox
Selects the strategy used to cut the text:
Character
Splits the text strictly by character count. Useful for hard limits (e.g., respecting a model's context window strictly by token approximation).
Word
Splits the text by word boundaries. Ensures words are never cut in half. Good for general text processing where sentence integrity matters less than word integrity.
Line
Splits the text line by line (based on newline characters \n or \r\n). Ideal for processing lists, CSV data, code, or log files where each line is a distinct record.
Block
Splits the text into larger blocks, typically paragraphs or fixed-size chunks. Useful for splitting a book or article into chapters or sections.
Custom Pattern
Splits the text using a specific string delimiter provided in the Pattern field.
Technical Note: Uses String.Split with the exact pattern provided. It does not use Regular Expressions by default (unless specified in code), so the pattern is treated as a literal string (e.g., "---" or "###").
🔍 Pattern Section (Custom Mode Only)
TextBox
Visible only when Split Mode is set to Custom Pattern.
Enter the exact string sequence that marks a split point.
Example: If your text uses *** to separate scenes, enter *** here.
🔁 Overlap Section
NumericUpDown (default: 0)
Defines the number of units (characters, words, or lines, depending on the Split Mode) that are repeated at the beginning of the next chunk.
Example: If splitting by Line with Overlap = 1, the last line of Chunk 1 will be repeated as the first line of Chunk 2.
Why use it? When splitting a story for an AI to summarize, the last sentence of the previous chunk helps the model understand the context of the new chunk, preventing disjointed summaries.
Usage Example
"Parallel Translation of a Long Document":
- A File Read node loads a 50-page story.
- A Dispatch node with:
- Output Count:
4 - Split Mode:
Block(orLineif pages are separated by newlines) - Overlap:
1(to keep the last paragraph's context)
- Output Count:
- Four Agent nodes (Translator A, B, C, D) receive one chunk each and translate it simultaneously.
- A Merge node reassembles the translated chunks in order.
⚠️ Pitfalls to Avoid
Output Count vs. Chunk Count: If you set Output Count to 2 but your text only has 1 paragraph (1 chunk), the second output will receive nothing (or an empty string). Ensure your splitting strategy actually produces enough chunks for your outputs.
Overlap Duplication: Remember that Overlap intentionally duplicates data. If you merge the outputs back together later (e.g., with a MergeNode), you will have duplicate lines/words at the junctions. You may need a CodeNode or FilterNode to clean up the overlaps after processing.
Custom Pattern Exact Match: The Custom Pattern is a literal string match, not a Regex (unless the underlying code specifically uses Regex.Split). If you expect "---" to split, but the text has "-- -", it will not split. Be precise with your delimiters.
Empty Chunks: If your text has consecutive delimiters (e.g., two blank lines when splitting by Line), you might generate empty chunks. Check if the node filters these out (like StringSplitOptions.RemoveEmptyEntries does) or if you need to handle empty strings downstream.