Task Class
The Task class represents a single task with full execution details and event streaming capabilities. It provides methods for monitoring task progress, streaming events, and managing task lifecycle.Properties
id
agent_id
status
internal_status
input
result
events_streaming
created_at
updated_at
output_format
output_schema
Class Methods
aload(task_id, configuration=None)
Asynchronously load a task by its ID.
task_id(str): Unique identifier for the taskconfiguration(Optional[Configuration]): SDK configuration
Task object with full details.
Example:
- [
ModuleException](/API reference/exceptions): If the task is not found or access is denied.
load(task_id, configuration=None)
Synchronously load a task by its ID.
aload()
Returns: Complete Task object.
Example:
Instance Methods
aset_status(status)
Asynchronously change the task’s execution status.
status(AgentExecutionStatus): New status for the task
set_status(status)
Synchronously change the task’s execution status.
aset_status()
Example:
asave()
Asynchronously save task changes back to the xpander platform.
Task object with server-side changes.
Example:
- [
ModuleException](/API reference/exceptions): If the save operation fails.
save()
Synchronously save task changes.
Task object.
Example:
astop()
Asynchronously stop the task execution.
Task object with updated status.
Example:
- [
ModuleException](/API reference/exceptions): If the task cannot be stopped.
stop()
Synchronously stop the task execution.
Task object.
Example:
aevents()
Asynchronously stream task events in real-time.
TaskUpdateEvent objects.
Example:
events_streaming=True when creating the task.
events()
Synchronously stream task events.
TaskUpdateEvent objects.
Example:
get_files()
Get PDF files from task input, formatted for Agno integration.
get_images()
Get image files from task input, formatted for Agno integration.
get_human_readable_files()
Get human-readable files from task input with their content.
aget_activity_log()
Asynchronously retrieve the activity log for this task.
AgentActivityThread object containing complete activity log including messages, tool calls, reasoning steps, sub-agent triggers, and authentication events.
Example:
- [
ModuleException](/API reference/exceptions): If the activity log cannot be retrieved or doesn’t exist.
get_activity_log()
Synchronously retrieve the activity log for this task.
AgentActivityThread object with complete activity log.
Example:
- [
ModuleException](/API reference/exceptions): If the activity log cannot be retrieved or doesn’t exist.
to_message()
Convert task input to a formatted message string.
Usage Examples
Complete Task Lifecycle Management
Task Status Management
Internal Status Tracking
Theinternal_status field provides optional custom context information with a 255 character limit. It’s set once before the task is saved or returned.
Error Handling with Tasks
Batch Task Monitoring
File Handling with Agno Integration
Task Activity Log Analysis
Related Classes
- [
Agent](/API reference/agents/API reference/agent): Agent that creates and manages tasks
Related Types
- [AgentExecutionStatus](/API reference/types#agentexecutionstatus): Task execution statuses
- [TaskUpdateEvent](/API reference/types#taskupdateevent): Event data structure
- [TaskUpdateEventType](/API reference/types#taskupdateeventtype): Event type enumeration
- [AgentExecutionInput](/API reference/types#agentexecutioninput): Task input configuration
Related Modules
- [Agents Module](/API reference/agents): Create and manage agents
- [Events Module](/API reference/events): Event-driven programming
- [Tools Repository](/API reference/tools): Tool integration and management

