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.
Backend.areport_external_task logs a task that was executed outside the xpander.ai runtime (for example, in a queue worker, a Lambda, or a different process) so it shows up in the same task history, metrics, and observability views as platform-managed tasks.
Use this when you’ve called an LLM yourself (outside of an @on_task handler) but still want the run to count toward agent metrics and appear in the dashboard.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
agent_id | str | No¹ | XPANDER_AGENT_ID env var | Agent the run is associated with. Falls back to agent.id if agent is provided. |
agent | Agent | No¹ | None | Pre-loaded Agent instance. Takes precedence over agent_id. |
id | str | No | None | External task identifier. Re-using the same ID updates the existing record. |
input | str | No | None | Input prompt for the run. |
llm_response | Any | No | None | The raw LLM response object (provider-specific). Stored verbatim for debugging. |
tokens | Tokens | No | None | Token usage. Used by metrics. |
is_success | bool | No | True | Whether the run completed successfully. Sets task status accordingly. |
result | str | No | None | Final result string. |
duration | float | No | 0 | Wall-clock duration in seconds. |
used_tools | list[str] | No | None | Names of tools the run called. |
configuration | Configuration | No | Module’s config | Override SDK configuration for this call. |
agent_id or agent must resolve. The method also reads XPANDER_AGENT_ID as a final fallback.
Returns Task
The platform-side Task record after persistence. Re-using id returns the updated record; new ids create a fresh task.
Examples
Idempotent updates
Pass the sameid to update an in-progress task as it makes progress:
Using a pre-loaded agent
Reporting a failure
is_success=False marks the task as failed in the dashboard.

