Skip to main content

Parameters

ParameterTypeDefaultDescription
selectorCallable[[StepInput], ...] | Callable[[StepInput, list], ...]RequiredFunction to select steps dynamically. Can optionally accept step_choices as second parameter
choicesWorkflowStepsRequiredAvailable steps for selection. Supports nested lists (becomes Steps container)
nameOptional[str]NoneName of the router step
descriptionOptional[str]NoneDescription of the router step

Selector Return Types

The selector function can return any of the following:
Return TypeDescription
strStep name as string - Router resolves it from choices
StepStep object directly
List[Step]List of steps for chaining execution

Selector Function Signatures

Basic Signature

def selector(step_input: StepInput) -> Union[str, Step, List[Step]]:
    ...

Extended Signature (with step_choices)

def selector(step_input: StepInput, step_choices: list) -> Union[str, Step, List[Step]]:
    ...
The step_choices parameter provides access to the prepared Step objects from Router.choices, enabling dynamic selection based on available options.

Async Support

Both signatures support async functions:
async def selector(step_input: StepInput, step_choices: list) -> Union[str, Step, List[Step]]:
    ...