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.acreate creates a new task. It’s equivalent to Agent.acreate_task but accepts agent_id directly, so you don’t need to load the Agent first. Use this when you only have an agent ID and want to skip the extra round-trip.
from xpander_sdk import Tasks

tasks = Tasks()
task = await tasks.acreate(
    agent_id="agent-123",
    prompt="Summarize the latest sales report",
    file_urls=["https://example.com/sales.csv"],
)
print(task.id, task.status.value)

Parameters

Identical to Agent.acreate_task, with agent_id required up front:
ParameterTypeRequiredDefaultDescription
agent_idstrYesAgent to invoke.
existing_task_idstrNoNoneContinue an existing task.
promptstrNo""Natural-language input.
file_urlslist[str]No[]URLs of files to attach.
user_detailsUserNoNoneEnd-user context.
agent_versionstrNoNonePin a specific agent version.
tool_call_payload_extensiondictNoNoneExtra fields merged into every tool-call payload.
sourcestrNoNoneOrigin tag.
worker_idstrNoNonePin to a specific worker.
run_locallyboolNoFalseMark as locally executed.
output_formatOutputFormatNoNoneOutput format.
output_schemadictNoNoneJSON schema.
events_streamingboolNoFalseEnables task.aevents().
additional_contextstrNoNoneExtra context appended to system prompt.
instructions_overridestrNoNoneExtra instructions for this run.
test_run_node_idstrNoNone(Internal) Test workflow node.
user_oidc_tokenstrNoNoneOIDC token for connector pre-auth.
expected_outputstrNoNoneExpected output description.
mcp_serverslist[MCPServerDetails]No[]Per-task MCP servers.
triggering_agent_idstrNoNoneTriggering agent ID.
titlestrNoNoneDisplay title.
think_modeThinkModeNoDefaultDefault or Harder.
disable_attachment_injectionboolNoFalseSkip auto-injection of human-readable file content.
return_metricsboolNoFalseReturn metrics (Workflow → Agent only).
user_tokensdictNoNonePre-computed user tokens for MCP auth.
See Agent.acreate_task for parameter details and examples.

Returns Task

The created task. Starts in Pending. See Task.

When to use this vs. Agent.acreate_task

UseWhen
Tasks().acreate(agent_id=..., ...)You only have an agent_id (e.g. from a webhook or env var). One fewer round-trip than loading the agent first.
Agent.acreate_task(...)You already have the loaded Agent (e.g. inspecting its tools or graph first).
Both produce identical results; pick the one that matches what you have on hand.

Sync version

task = tasks.create(agent_id="agent-123", prompt="Hello!")

Errors

Raises ModuleException. Common statuses:
StatusCause
400Invalid input (bad output schema, malformed mcp_servers, etc.).
401 / 403Auth failure.
404Agent doesn’t exist.
500Server error.