> ## 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.

# Get Next Task • AI Agent SDK

> get_next_task: Get the next task name based on the 'when' condition evaluation.

# get\_next\_task

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Task**](../classes/Task) class in the [**task**](../modules/task) module.

Get the next task name based on the 'when' condition evaluation.

This provides a simple routing mechanism for Task objects,
similar to AgentFlow's when() function.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def get_next_task(context: Dict[str, Any]) -> Optional[str]
```

## Parameters

<ParamField query="context" type="Dict" required={true}>
  Dictionary containing variables for evaluation.
</ParamField>

### Returns

<ResponseField name="Returns" type="Optional[str]">
  then\_task if condition is True, else\_task if False.
  None if no routing is configured.
</ResponseField>

## Uses

* `evaluate_when`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/task/task.py#L842">
  `praisonaiagents/task/task.py` at line 842
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Tasks Concept" icon="list-check" href="/docs/concepts/tasks" />

  <Card title="Task Configuration" icon="gear" href="/docs/configuration/task-config" />

  <Card title="Task Validation" icon="check-double" href="/docs/features/task-validation-feedback" />
</CardGroup>
