Tasks API
Task management API reference for the xpander SDK
Task Methods
The Tasks API provides methods for creating, monitoring, and managing tasks assigned to xpander agents.
add_task() / addTask()
Creates a new task for the agent with the specified input.
Parameter | Type | Required | Description |
---|---|---|---|
input | string | Yes | Task description or user message |
thread_id | string | No | Thread ID for connecting related tasks |
files | List[Dict] | No | Files to attach to the task |
use_worker | boolean | No | Whether to use a worker for execution (default: true) |
Returns: Task object
After calling add_task()
, the agent’s execution
property is initialized, and agent.messages
is populated with system instructions and the user input.
is_finished() / isFinished()
Checks if the current task has finished.
Returns: boolean
- True
if task has finished, False
otherwise.
A task is considered finished when the AI model calls the xpfinish-agent-execution-finished
tool or if the task has failed.
get_execution_status() / getExecutionStatus()
Fetches the latest status of the current task.
Returns: Task status object with the following properties:
retrieve_execution_result() / retrieveExecutionResult()
Retrieves the result of a completed task, including the thread ID which can be used to connect related tasks.
Returns: Result object with the following properties:
list_executions() / listExecutions()
Lists tasks for the current agent.
Returns: Array of task objects.
get_execution() / getExecution()
Gets a task by ID.
Parameter | Type | Required | Description |
---|---|---|---|
execution_id | string | Yes | ID of the task |
Returns: Task object
Task Execution Properties
agent.execution
The current execution task object, available after calling add_task()
.
To retrieve the thread ID, you should use the result from retrieve_execution_result()
rather than the execution object.
Type Definitions
Execution
Represents a task assigned to an agent.
ExecutionStatus
Represents the current status of a task.
ExecutionResult
Represents the result of a completed task.