Skip to main content

Conditional Execution

The when parameter controls whether a step runs based on runtime conditions:
Both handle_urgent and handle_normal wait for classify to complete. Only the one whose condition is met will execute.

Skipped Steps

If a step’s condition is not met, it is skipped along with all its dependents:
If validate_input returns "invalid", both process and save_results are skipped. save_results depends on process, which never runs. Not all dependents of a skipped step are skipped. When a step uses depends_on, it only waits for the referenced steps to resolve (either complete or be skipped) — it doesn’t need their data. This is useful when you don’t know which branch will run:
handle_new and handle_existing have inverse conditions, so only one runs. finalize depends on both via depends_on, so it waits for both to resolve (one completes, the other is skipped) and then executes regardless.

Conditional with Agents

Use an LLM to make routing decisions:
The classifier agent decides which handler runs. Only the matching branch executes.