Router Steps

Parameters

ParameterTypeDefaultDescription
selectorCallable[[StepInput], ...] | Callable[[StepInput, list], ...]NoneFunction 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
human_reviewOptional[HumanReview]NoneAll HITL settings in a single config. See HumanReview Config.
requires_confirmationboolFalsePause for user confirmation before executing selected route
confirmation_messageOptional[str]NoneMessage shown to user when requesting confirmation
requires_user_inputboolFalsePause for user to select route(s) instead of using selector. See Router HITL.
user_input_messageOptional[str]NoneMessage shown to user when requesting route selection
allow_multiple_selectionsboolFalseAllow user to select multiple routes
requires_output_reviewboolFalsePause after the selected route completes to review its output. See Output Review.
output_review_messageOptional[str]NoneMessage shown to user during output review
hitl_max_retriesint3Max re-executions when an output review is rejected with OnReject.retry
hitl_timeoutOptional[int]NoneSeconds before the HITL pause auto-resolves. See Timeout.
on_timeoutUnion[OnTimeout, str]OnTimeout.cancelAction when the HITL timeout expires: approve, reject, cancel
on_rejectOnRejectOnReject.skipAction when rejected: skip, cancel, retry

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

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

Extended Signature (with step_choices)

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

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:

1async def selector(step_input: StepInput, step_choices: list) -> Union[str, Step, List[Step]]:
2 ...