> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobilerun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Tasks

> Monitor all your agent tasks, track execution history, and view live progress of running tasks.

The Tasks tab provides a comprehensive view of all agent tasks associated with your account. Monitor active executions in real-time and review historical task data.

## Overview

The Tasks tab displays:

* All tasks you have executed
* Currently running tasks with live status updates
* Task history with execution details and results

## Task List

Your task list shows every task in reverse chronological order, with the most recent tasks at the top. Each task entry displays:

| Field | Description |
| - | - |
| **Task ID** | Unique identifier for the task |
| **Prompt** | The instruction given to the agent |
| **Device** | The device the task ran on |
| **Status** | Current task state |
| **Duration** | Total execution time |
| **Timestamp** | When the task was created |

## Task Status

Tasks progress through several states during execution:

| Status, with API value | Description |
| - | - |
| **`queued`** | Task is accepted and waiting for a free device |
| **`created`** | Task record created, about to start |
| **`running`** | Agent is actively executing the task |
| **`paused`** | Execution is temporarily suspended |
| **`cancelling`** | A cancel request is being applied |
| **`completed`** | Task finished successfully |
| **`failed`** | Task encountered an error and stopped |
| **`cancelled`** | Task was stopped before completion |

> [!TIP]
>
> When you poll a task, treat `completed`, `failed`, and `cancelled` as the terminal states. Stop
> polling once the status is one of these three values.

### Busy Devices

Each device runs one task at a time. When you create a task for a device that another task is already using, the new task waits for the device to become free before it starts.

Queued tasks wait for the preceding task to finish. After a task is promoted from the queue, acquiring the device has a separate 30-second contention limit. If another operation still holds the device after that limit, the task fails. The task status becomes `failed` and its `message` field contains:

```text theme={null}
Device is currently in use. Try again when the current task has finished.
```

Tasks submitted to the same device queue automatically. If you need to inspect a result before submitting the next task, poll until the current task reaches a terminal state:

```ts theme={null}
let status = await client.tasks.getStatus(taskId);
while (!['completed', 'failed', 'cancelled'].includes(status.status)) {
  await new Promise((r) => setTimeout(r, 3000));
  status = await client.tasks.getStatus(taskId);
}
// The device is free; start the next task
```

## Live Updates

The Tasks tab updates in real-time. When a task is running:

* Status changes appear instantly
* Execution progress is visible without refreshing
* New tasks appear at the top of the list automatically

> [!NOTE]
>
> You do not need to refresh the page to see task updates. The interface synchronizes automatically with the server.

## Task Details

Click on any task to view its full details:

### Execution Trajectory

The trajectory shows every action the agent took during execution:

* Screenshots at each step
* UI elements the agent interacted with
* Decisions and reasoning (when available)
* Timestamps for each action

### Task Output

For tasks with structured output schemas, view the extracted data in a formatted display. This is useful for:

* Data extraction tasks
* Verification workflows
* Automated testing results

### Error Information

For failed tasks, the details view shows:

* Error messages and stack traces
* The last successful step before failure
* Screenshots capturing the failure state

### Execution checkpoint

When a task ends abnormally (timeout, worker loss, cancellation, or an agent failure), the task status response includes an optional `execution` object. It classifies why the task ended and preserves a compact checkpoint of what the agent had done so far, so you can decide whether to retry, resume from context, or surface a better error to your users.

The `execution` field is only present for abnormal terminal outcomes. Tasks that complete successfully leave it as `null`.

| Field | Description |
| - | - |
| **`terminationReason`** | Why the task ended: `execution_timeout`, `worker_lost`, `cancelled`, or `agent_failed` |
| **`retrySafety`** | Whether the task is safe to retry. Currently always `unknown` |
| **`checkpoint.steps`** | Number of steps the agent completed |
| **`checkpoint.plan`** | The agent's most recent plan, if any |
| **`checkpoint.currentSubgoal`** | The subgoal the agent was working on at termination |
| **`checkpoint.progressSummary`** | A short summary of what the agent had accomplished |

Example response from `GET /tasks/{task_id}/status`:

```json theme={null}
{
  "status": "failed",
  "succeeded": false,
  "message": "Task exceeded the execution timeout",
  "steps": 12,
  "execution": {
    "terminationReason": "execution_timeout",
    "retrySafety": "unknown",
    "checkpoint": {
      "steps": 12,
      "plan": "Open the settings app and toggle Wi-Fi off",
      "currentSubgoal": "Locate the Wi-Fi toggle",
      "progressSummary": "Opened Settings and scrolled to Network"
    }
  }
}
```

> [!NOTE]
>
> Existing task list, task detail, SSE, and webhook payloads are unchanged. The `execution` field is only added to the task status response.

## Filtering and Search

Find specific tasks using the available filters:

| Filter | Description |
| - | - |
| **Status** | Show only tasks with a specific status |
| **Date Range** | Filter by execution date |
| **Device** | Show tasks that ran on a specific device |
| **Search** | Find tasks by prompt text or task ID |

## Task Actions

From the task list, you can:

### View Task Stream

For running tasks, click to open the live device stream and watch the agent execute in real-time.

### Cancel Running Tasks

Stop a task that is currently in progress. The agent will halt execution and the task will be marked as cancelled.

> [!NOTE]
>
> The REST API endpoint for cancellation is `POST /tasks/{id}/cancel`. The TypeScript and Python SDKs name this method `client.tasks.stop(taskId)` it hits the same `/cancel` endpoint.

### Retry Failed Tasks

Re-run a failed task with the same configuration. This creates a new task with identical parameters.

## Idempotent task creation

`POST /tasks` accepts an optional `Idempotency-Key` request header so retries after a
network error or timeout do not create duplicate tasks. If the same owner sends another
request with the same key and identical body, the API returns the original task instead
of creating a new one.

Use it when:

* Your client retries `POST /tasks` after connection errors or timeouts.
* A queue worker or job runner may deliver the same task creation more than once.
* You dispatch tasks from a workflow that guarantees at-least-once delivery.

### How keys are compared

* Keys are scoped to the calling owner and can be any string between 1 and 128 characters. Use a value your client can regenerate on retry, such as a UUID tied to the upstream job.
* The API also fingerprints the request body. If the same key arrives with a different body, the request is rejected with `409 Conflict` and the message `Idempotency-Key was already used with a different request`.
* Replays return the original task's `id`, `status`, and `streamUrl`, so downstream code can keep polling or streaming without special-casing the retry.

### Example

```bash theme={null}
curl https://api.mobilerun.ai/v1/tasks \
  -H "Authorization: Bearer $MOBILERUN_CLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0f8d1e6c-1c1d-4d5b-9c1a-2f0f4b4b1a55" \
  -d '{
    "deviceId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "task": "Open Gmail and read the latest email"
  }'
```

> [!TIP]
>
> Reuse the same key for every retry of the same logical request. Generate a fresh key
> whenever the task inputs change so the API creates a new task instead of returning
> `409 Conflict`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.