Skip to main content
For repeatable work, see Working with routines and Triggers; event triggers are Soon. A task is an instruction the Mobilerun agent carries out on a connected device.
  • Run a task: test a prompt in the Task runner or submit it from code.
  • Configure the agent: choose a model, execution limits, and output format.
  • Monitor tasks: watch progress, inspect results, and manage task history.

Run a task

In the dashboard’s Task runner, choose Select device, enter your prompt, and pick a Model. Adjust Steps, Timeout (s), and options such as Recording, Vision, Accessibility, or Structured output, then choose Run task. Watch the device stream as the agent works.
  • Give a specific, action-oriented goal; break complex work into clear steps and include relevant context.
  • Refine the prompt, test unexpected UI states, and compare approaches before production use.
  • A Task runner session keeps app installations, login state, and files until you end the session or switch devices.
For the API or SDK, use the same device and task prompt. These existing examples include an idempotency key for safe request retries:
You can also run tasks through the Mobilerun MCP server.

Configure the agent

Model selection

Use your own OpenAI, Anthropic, or Google key on any plan: Bring your own model key.
Faster models reduce latency and cost for simple tasks; advanced models trade those for reasoning and accuracy on complex work. Set llmModel in the API/SDK or choose a model in the Task runner; omitted, it uses mobilerun/mobile-agent-fast. The live catalog is the source of truth: use GET /v1/models, mobilerun.api.models.list(), or the dashboard model picker, especially after a “model unavailable” error. For the open source Framework, use Framework configuration.

Structured output

Set outputSchema to a JSON Schema when extracting data, validating a flow, or passing results to another system. The agent formats its output to match that structure.

Best practices

  • Set reasonable step and time limits for the work.
  • Enable reasoning for complex tasks that need planning.
  • Attach saved credentials rather than putting secrets in the prompt.
  • Use structured output when processing results programmatically.

Monitor tasks

The task list shows runs in reverse chronological order, with ID, prompt, device, status, duration, and creation time. Live status and progress update automatically; new tasks appear at the top without refreshing.

Task status

completed, failed, and cancelled are terminal states. The status response’s terminal flag becomes true; task.wait() returns once a task reaches one of them.

Busy devices

Each device runs one task at a time; further tasks queue automatically. After promotion from the queue, acquiring the device has a separate 30-second contention limit. If it remains busy, the task fails with Device is currently in use. Try again when the current task has finished. Wait for a result with task.wait() before submitting more work when you need to inspect it first.

Task details and recordings

Open a task to see its action trajectory, step screenshots, interacted UI elements, available reasoning, and timestamps. Details include structured output when requested; failed runs show error information, the last successful step, and screenshots of the failure.

Task recording

Set recordingEnabled: true to record from running until completion, failure, or cancellation. Status, list, and detail responses include recordingId and recordingDeviceId once recording starts; they are null while queued, disabled, or unable to start. Recording is best-effort: a recording failure does not change the task outcome. An unsupported device rejects creation with HTTP 400 DEVICE_RECORDING_UNSUPPORTED; if unsupported capability is discovered only after the task starts, the task fails rather than running without recording.

Execution checkpoint

For abnormal terminal outcomes (timeout, worker loss, cancellation, or agent failure), the status response’s optional execution object classifies the termination and preserves a compact checkpoint. Successful tasks leave it null; list, detail, SSE, and webhook payloads are unchanged. Filter by Status, Date Range, or Device, or search by prompt text or task ID.

Task actions

  • View Task Stream: watch a running task’s live device stream.
  • Cancel Running Tasks: stop execution and mark the task cancelled. REST uses POST /tasks/{id}/cancel; the SDKs call it task.stop().
  • Retry Failed Tasks: create a new task with the same configuration.

Idempotent task creation

Send Idempotency-Key with POST /tasks when retrying after network errors or timeouts, or dispatching work with at-least-once delivery. Keys are scoped to the calling owner, accept 1–128 characters, and should be reproducible for the same logical job, such as its UUID. The same key and identical body return the original task’s id, status, and streamUrl. Reusing the key with a different body returns HTTP 409 with Idempotency-Key was already used with a different request. Reuse a key only for retries; generate a new one when inputs change. See the creation examples above.

Task statistics

Use GET /tasks/stats to summarize outcomes without paging through task history. Tasks count in their creation-time bucket. The response includes buckets (including empty intervals) and totals with succeeded, failed, cancelled, and running counts; running covers every unfinished task. successRate is succeeded / (succeeded + failed), excluding cancellations, or null when neither succeeded nor failed. durationSeconds contains p50/p95 finished-task runtimes; topFailures lists up to five failure messages and counts. Invalid window order, a window longer than 90 days, or hourly buckets beyond 7 days return HTTP 422.