Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt

Use this file to discover all available pages before exploring further.

Tasks.aupdate patches selected fields on a task. Pass only the fields you want to change: anything left as None is ignored. For finer control over save semantics (especially when mutating Task attributes locally first), use task.asave() on the instance.
from xpander_sdk import Tasks, AgentExecutionStatus

tasks = Tasks()
updated = await tasks.aupdate(
    task_id="task_xyz",
    status=AgentExecutionStatus.Completed,
    result="Final summary: …",
)
print(updated.status.value)

Parameters

ParameterTypeRequiredDescription
task_idstrYesTask to update.
tool_call_payload_extensiondictNoExtra fields merged into every tool-call payload going forward.
sourcestrNoUpdate the origin tag.
statusAgentExecutionStatusNoNew status.
last_executed_node_idstrNoMove the task’s “current node” cursor (workflow agents).
resultstrNoFinal result string.
Fields with value None are stripped from the request: only what you pass is sent.

Returns Task

The freshly-loaded task with updates applied. See Task.

Examples

Mark complete

await tasks.aupdate(
    task_id="task_xyz",
    status=AgentExecutionStatus.Completed,
    result="Done",
)

Mark errored

await tasks.aupdate(
    task_id="task_xyz",
    status=AgentExecutionStatus.Error,
    result="Connector failed: 503 Service Unavailable",
)

Update only payload extension

await tasks.aupdate(
    task_id="task_xyz",
    tool_call_payload_extension={"headers": {"X-Trace-ID": "abc-123"}},
)
This is rarely needed: payload extensions are usually set at task creation. Use this when you need to inject context after the task starts.

Sync version

tasks.update(task_id="task_xyz", status=AgentExecutionStatus.Completed)

When to use this vs. task.asave()

UseWhen
Tasks().aupdate(task_id=..., field=...)You only need to set a couple of fields and don’t have a Task instance loaded.
task.asave()You’ve mutated the Task instance directly (e.g. set task.result = "..."). asave PATCHes everything except configuration and (by default) deep_planning.
The @on_task runtime auto-saves the task at the end of the handler: you don’t usually call aupdate or asave yourself inside a handler.

Errors

Raises ModuleException. Common statuses:
StatusCause
404Task doesn’t exist.
409Concurrent update conflict. Reload and retry.
500Server error.