Signpost AI Logo
WorkersTools

Combine

📸 Screenshots

Here are visual examples of this section:

Combine - Worker Configuration Interface Combine - Worker Configuration Interface

1. Overview and Purpose

The Combine worker merges multiple inputs into a single output value. It supports two modes: concatenating all inputs together, or selecting the first non-empty input value. This worker is useful for merging data streams or implementing fallback logic in workflows.

2. Configuration Parameters

The Worker accepts the following parameters:

  • mode: Specifies the combination mode - either "concat" to concatenate all inputs or "nonempty" to select the first non-empty input
  • inputCount: Optional parameter that specifies the number of input fields to create

3. Input/Output Handles

  • input1: Input handle - accepts any data type for the first input value
  • input2: Input handle - accepts any data type for the second input value
  • output: Output handle - returns the combined result based on the selected mode
  • Additional input handles are created dynamically based on the inputCount parameter

4. Usage Examples with Code

// Example: Concatenating strings
const combineWorker = agent.createWorker('combine', {
  mode: 'concat'
});

// Example: Using first non-empty value as fallback
const fallbackWorker = agent.createWorker('combine', {
  mode: 'nonempty'
});

5. Integration Examples

The Combine worker is commonly used to merge outputs from parallel processing branches or to implement fallback mechanisms when primary data sources may be empty.

6. Best Practices

  • Use "nonempty" mode for fallback scenarios where you want the first available value
  • Use "concat" mode when you need to merge all input data together
  • Ensure input types are compatible when using concat mode (all strings or all arrays)
  • Consider the order of inputs as they are processed sequentially

7. Troubleshooting Tips

  • If concat mode produces unexpected results, verify all inputs are the same data type
  • Empty arrays and null values are treated as empty in "nonempty" mode
  • The worker will use the last input value if all inputs are empty in "nonempty" mode
  • Input fields are sorted numerically for consistent processing order