Get Next Task • AI Agent SDK

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

get_next_task

Method

</div>

This is a method of the Task class in the 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
def get_next_task(context: Dict[str, Any]) -> Optional[str]

Parameters

ParamField Dict[str, Any]

Dictionary containing variables for evaluation.

Returns

ResponseField Optional[str]

then_task if condition is True, else_task if False. None if no routing is configured.

Uses

  • evaluate_when

Source

View on GitHub

praisonaiagents/task/task.py at line 1021


Related Documentation