Router with Step Choices
Use the Router step_choices parameter with string, step, and list selector returns.
A Router selector can declare a step_choices parameter. The router passes its prepared choices to that parameter. The selector can return a choice name, a step object, or a list of choices to run in sequence.
Selection options
Use step_choices to inspect the prepared choices at runtime. Return a list to run several choices in sequence. A nested list in choices is prepared as a grouped Steps container.
Selector Return Types Summary
| Return Type | Description | Example |
|---|---|---|
str | Step name - Router resolves from choices | return "Tech Research" |
Step | Step object directly | return step_map["writer"] |
List[Step] or List[str] | Run multiple choices in sequence | return [researcher, writer, reviewer] |
Examples
String Selector
Return step names as strings for simple resolution.
Dynamic Selector
Inspect step_choices to dynamically select steps.
Nested Selector
Select nested lists of steps as a single unit.