Skip to main content
Example Use-Cases: Expert routing, content type detection, multi-path processing Dynamic routing workflows provide intelligent path selection while maintaining predictable execution within each chosen branch.

Selector Flexibility

The Router selector function supports multiple return types:
  • String: Return step name - Router resolves it from choices
  • Step: Return Step object directly
  • List[Step]: Return list of steps for chaining
The selector can also receive step_choices as an optional second parameter for dynamic selection.

Example: String-based Selector

The simplest approach - return the step name as a string:
branching_workflow.py

Example: Using step_choices Parameter

Access available choices dynamically for more flexible routing:
dynamic_routing.py

Example: Nested Choices

Nested lists in choices become Steps containers for sequential execution:
nested_routing.py

Developer Resources

Reference

For complete API documentation, see Router Steps Reference.