Skip to content

azad.predefined_tools.task_exit Module

azad.predefined_tools.task_exit

Predefined Task Exit Tool Schema and Metadata.

Attributes

TASK_EXIT_TOOL_METADATA module-attribute

TASK_EXIT_TOOL_METADATA = {'name': 'task_exit', 'description': 'Exits the current nested task in the mindmap structure and returns to the parent task', 'parameters': {'handoff_description': {'description': 'Description of the handoff back to the parent task, including results and findings', 'streamable': False}}, 'requires_approval': True, 'required_parameters': ['handoff_description'], 'examples': [{'explanation': 'Exit the current nested task with a summary of findings', 'parameters': {'handoff_description': [{'type': 'text', 'text': 'Analysis complete. I found 3 potential bugs in the code: 1) Null pointer in line 42, 2) Race condition in the async handler, 3) Memory leak in the resource cleanup.'}]}}], 'is_task_entry': False, 'is_task_exit': True, 'task_lifecycle_output_keypairs': {'handoff_description': HANDOFF_DESCRIPTION}}

Classes

TaskExitToolSchema

Bases: BaseModel

Input schema for the Task Exit tool.

This defines the required parameters when exiting a nested task.

Attributes
handoff_description class-attribute instance-attribute
handoff_description: List[Union[TextPart, ImagePart]] = Field(..., description='Description of the handoff back to the parent task, including results and findings')
model_config class-attribute instance-attribute
model_config = {'populate_by_name': True, 'extra': 'forbid'}
Functions
validate_handoff_description
validate_handoff_description() -> TaskExitToolSchema

Validate that handoff_description contains at least one content part.

Source code in azad/predefined_tools/task_exit.py
@model_validator(mode='after') # type: ignore
def validate_handoff_description(self) -> TaskExitToolSchema:
    """Validate that handoff_description contains at least one content part."""
    if not self.handoff_description:
        raise ValueError("handoff_description must contain at least one content part")
    return self
to_tool_result
to_tool_result() -> Dict[str, Any]

Convert to format expected by mindmap's add_task_exit method.

Source code in azad/predefined_tools/task_exit.py
def to_tool_result(self) -> Dict[str, Any]:
    """Convert to format expected by mindmap's add_task_exit method."""
    return {
        "handoff_description": self.handoff_description
    }
from_handoff_description classmethod
from_handoff_description(handoff_description: List[Union[TextPart, ImagePart]]) -> TaskExitToolSchema

Create a TaskExitToolSchema from a handoff description.

Source code in azad/predefined_tools/task_exit.py
@classmethod
def from_handoff_description(cls, handoff_description: List[Union[TextPart, ImagePart]]) -> TaskExitToolSchema:
    """Create a TaskExitToolSchema from a handoff description."""
    return cls(handoff_description=handoff_description)
apply_to_task
apply_to_task(task: Task, result_key='task_result') -> Tuple[TaskExitMessage, Optional[ToolMessage]]

Apply this task exit to a Task object.

Returns:

Source code in azad/predefined_tools/task_exit.py
def apply_to_task(self, task: Task,result_key="task_result") -> Tuple[TaskExitMessage, Optional[ToolMessage]]:
    """
    Apply this task exit to a Task object.

    Returns:
        A tuple of (TaskExitMessage, ToolMessage) created by exiting the task
    """
    return task.add_task_exit(handoff_description=self.handoff_description,payloadKey=result_key)

TaskExitOutputSchema

Bases: BaseModel

Output schema for the Task Exit tool.

This defines the structure of the result returned when a nested task is exited.

Attributes
handoff_description class-attribute instance-attribute
handoff_description: List[Union[TextPart, ImagePart]] = Field(..., description='The handoff description that was provided when exiting the task')
status class-attribute instance-attribute
status: Literal['exited', 'error'] = Field(..., description='Status of the task exit operation')
message class-attribute instance-attribute
message: Optional[str] = Field(None, description='Additional information about the task exit')
model_config class-attribute instance-attribute
model_config = {'populate_by_name': True, 'extra': 'forbid'}