Skip to main content
The step_choices parameter provides ultimate flexibility for dynamic routing, allowing Router selectors to return strings, Step objects, or lists of Steps for chained execution. It enables complex logic where available paths are inspected at runtime rather than hard-coded.

Key Benefits

When your routing logic needs flexible return types or dynamic access to available choices, step_choices is the right tool.
  1. Flexible Returns: Return string names, Step objects, or lists as needed
  2. Dynamic Selection: Use step_choices to inspect available options at runtime
  3. Step Chaining: Return List[Step] to execute multiple steps in sequence
  4. Nested Containers: Use nested lists in choices for grouped sequential execution
  5. Reusable Logic: Build routing functions that adapt to any set of choices

Selector Return Types Summary

Return TypeDescriptionExample
strStep name - Router resolves from choicesreturn "Tech Research"
StepStep object directlyreturn step_map["writer"]
List[Step]Chain multiple stepsreturn [researcher, writer, reviewer]

Examples

Developer Resources