> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# when • Rust AI Agent SDK

> when: Alias for route (matches Python SDK naming) Creates a conditional routing step.

# when

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**workflow\_aliases**](../modules/workflow_aliases) module.

Alias for route (matches Python SDK naming) Creates a conditional routing step.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def when(
    condition: F,
    if_true: Arc<crate::agent::Agent>,
    if_false: Option<Arc<crate::agent::Agent>>,
) -> crate::workflows::FlowStep
where
    F: Fn(&str) -> bool + Send + Sync + 'static,
```

## Parameters

<ParamField query="condition" type="F" required={true}>
  No description available.
</ParamField>

<ParamField query="if_true" type="Arc<crate::agent::Agent>" required={true}>
  No description available.
</ParamField>

<ParamField query="if_false" type="Option<Arc<crate::agent::Agent>>" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField
  name="Returns"
  type="crate::workflows::FlowStep
where
F: Fn(&str) -> bool + Send + Sync + 'static,"
>
  The result of the operation.
</ResponseField>

## Uses

* `route`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/parity/workflow_aliases.rs#L123">
  `praisonai/src/parity/workflow_aliases.rs` at line 123
</Card>
