---
title: "Introducing agent: run a task in a phone app from one prompt"
description: "Lusor's POST /v1/agent runs a task on a phone from one prompt and returns text or JSON in your schema, with a recording, a spending cap and known limits."
author: "Josiah Richards"
canonical: "https://lusor.ai/blog/introducing-agent-for-phone-apps"
updated: "2026-11-25"
---

[Blog](https://lusor.ai/blog) / [Integrations](https://lusor.ai/blog/integrations)

# Introducing agent: run a task in a phone app from one prompt

Lusor's agent call takes a task in plain words, works a phone's apps to do it, and returns the answer as text or as JSON in your shape, with a recording of every run. Here is how to start one, read it, cap what it spends and check what it did.

Agent · November 24, 2026 · Updated November 25, 2026 · 7 min read

By Josiah Richards

## TL;DR

- POST /v1/agent takes a task in plain words. An AI agent works the phone's apps to do it and returns the answer as data: text, or the object a JSON Schema describes.
- Use agent when the work needs judgment, such as signing in, searching, filling a form or finding the screen that holds the data. There is no app field, so name the app in the prompt.
- The result is { success, status, data, expiresAt }, the shape of Firecrawl's agent call, plus recordingUrl. Every run is recorded.
- A task reads processing while it works and awaiting\_human when the agent stopped to ask a person. Read GET /v1/agent/{id} until it is neither.
- maxCredits caps what one run may spend. A run that reaches it ends failed, with stopReason credit\_limit\_reached.

Some data in a phone app sits behind a sign-in, a search or a form, and you may not know which screen holds it. Lusor's agent call takes the task in plain words. An AI agent works the phone's apps to do it, and the task returns the answer as `data`, as text or as the object your JSON Schema describes. Every run is recorded.

Lusor's app-data API is modeled on Firecrawl's, so agent takes a `prompt` and a `schema` and answers `{ success, status, data, expiresAt }`. Lusor adds `recordingUrl`, because every phone run is recorded. The [agent docs](https://docs.lusor.ai/app-data/agent) have every field.

## When should you use agent instead of scrape?

When the work needs judgment. Signing in, searching, filling a form and moving through an app to reach the data are agent work. When you already know the screen, Lusor's scrape call reads it with fixed rules and no agent, as [scrape a phone app like a web page](https://lusor.ai/blog/scrape-phone-apps-like-web-pages) explains. To see which screens Lusor already knows in an app, call map, covered in [introducing map for phone apps](https://lusor.ai/blog/introducing-map-for-phone-apps).

There is no `app` field. Name the app in the prompt, which can be up to 8,192 characters.

## How do you run a task?

An agent call holds a phone while the agent works, so it is a task. Start it with `POST /v1/agent`.

```bash
curl "https://api.lusor.ai/v1/agent" \
  -H "X-Api-Key: $LUSOR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "In Settings, open General, then About, and read the iOS version and the model name.",
    "schema": {
      "type": "object",
      "properties": {
        "version": { "type": "string" },
        "model": { "type": "string" }
      },
      "required": ["version", "model"]
    }
  }'
```

The call answers `202` at once with the task's `id`, and with a `liveViewUrl` when the run can be watched.

```json
{
  "id": "8b2d4f71-…",
  "liveViewUrl": "https://…"
}
```

Set `TASK_ID` to that `id`, then read `GET /v1/agent/{id}` until `status` is neither `processing` nor `awaiting_human`. With `jq`:

```bash
while :; do
  RESULT=$(curl -s "https://api.lusor.ai/v1/agent/$TASK_ID" -H "X-Api-Key: $LUSOR_API_KEY")
  case "$(echo "$RESULT" | jq -r .status)" in
    processing|awaiting_human) sleep 3 ;;
    *) break ;;
  esac
done
echo "$RESULT" | jq .
```

In a live run on an iPhone 13 Pro Max, a task like this one answered the iOS version in 7.5 seconds, and the run was recorded.

## What does the result hold?

```json
{
  "success": true,
  "status": "completed",
  "data": { "version": "26.1", "model": "iPhone 13 Pro Max" },
  "expiresAt": "2026-12-24T14:20:00.000Z",
  "recordingUrl": "https://api.lusor.ai/v1/sessions/8b2d4f71-…/recording",
  "error": null
}
```

|  | What it is |
| --- | --- |
| success | false once the task failed or was cancelled. |
| status | Where the task is. See the statuses below. |
| data | The answer, on a completed task: the object your schema describes, or text when you sent no schema. |
| expiresAt | When the answer leaves your plan's history window. null when your plan keeps history without a limit. |
| recordingUrl | The run's recording. Fetch it with the same API key to get signed video segments. |
| liveViewUrl | A watch-only link to the phone while the run is live. |
| error, stopReason | Why the task failed. stopReason is credit_limit_reached when the run stopped at its maxCredits. |
| creditsUsed | What the task has been charged so far. |
| metadata | Present when the task waited for its phone. |

`data` is filled only on a completed task. A task that fails or is stopped returns no partial answer. After `expiresAt`, the answer is no longer kept.

## How do you get the answer in your shape?

Send `schema`, a [JSON Schema](https://json-schema.org/specification), and `data` is the object it describes. Without it, `data` is the agent's answer as text. Describe the task in `prompt` and the result's shape in `schema`. Mark the fields you always need as `required`, and use `description` to say what a field means. The [structured output docs](https://docs.lusor.ai/agents/structured-output) have more on writing one.

An answer that fits the schema can still hold a wrong value. How that happens, and how to check it, is in [JSON from a phone screen you can check](https://lusor.ai/blog/json-from-a-phone-screen).

## What do the statuses mean?

|  | Meaning |
| --- | --- |
| processing | The task is waiting for its phone, working, or writing its result. Keep reading. |
| awaiting_human | The agent stopped to ask a person a question. It resumes when the question is answered. |
| completed | data is in the response. |
| failed | error says why. |
| cancelled | The task was stopped. |

The first read that says `completed` carries `data`, and the first that says `failed` carries `error`. The task id is also the id of its session, so the session endpoints work on it:

- `GET /v1/sessions/{id}/events` shows what the agent is doing. See [follow a session](https://docs.lusor.ai/agents/follow-a-session).
- An `awaiting_human` task is answered like any session. See [answer the agent](https://docs.lusor.ai/agents/answer-the-agent).
- `POST /v1/sessions/{id}/stop` stops it. See [stop a session](https://docs.lusor.ai/agents/stop-a-session).

## How do you cap what a run spends?

Send `maxCredits`, the most credits the run may spend. Without it a default cap applies, and a whole number you send replaces it. Here `MAX_CREDITS` is a shell variable holding your cap.

```bash
curl "https://api.lusor.ai/v1/agent" \
  -H "X-Api-Key: $LUSOR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: about-check-1" \
  -d "{ \"prompt\": \"In Settings, open General, then About, and read the iOS version.\", \"maxCredits\": $MAX_CREDITS }"
```

The run stops once its charge would pass the cap. The task ends `failed` and is charged at most `maxCredits`.

```json
{
  "success": false,
  "status": "failed",
  "error": "Agent reached max credits",
  "stopReason": "credit_limit_reached"
}
```

`creditsUsed` in the result is what the task has been charged so far. Charges are written when a run ends, so a running task reads less than it will cost.

## How do you see what the agent did?

Every run is recorded. Fetch `recordingUrl` with the same API key to get signed video segments.

```bash
curl "https://api.lusor.ai/v1/sessions/$TASK_ID/recording" \
  -H "X-Api-Key: $LUSOR_API_KEY"
```

The [recordings and replay docs](https://docs.lusor.ai/agents/recordings-and-replay) cover the video and the step replay, and [your agent says done: here is how to check](https://lusor.ai/blog/your-agent-says-done-how-to-check) shows how to use them to check a result.

While the task runs, `liveViewUrl` is a watch-only player page for the phone. You can open it or embed it with no Lusor login, taps through it are refused, and it stops working when the task ends. Send `expiresIn` in seconds to make the link expire sooner. To put a phone's screen inside your own app over WebRTC instead, see [put a phone's live screen in your own app](https://lusor.ai/blog/live-phone-screen-in-your-app).

## What happens when the phone is busy?

A phone runs one task at a time. A task sent to a busy phone waits, reading `processing`, and starts when the phone frees. Its result then carries `metadata` with `concurrencyLimited: true` and `concurrencyQueueDurationMs`, the time from your request to the phone taking it. A task that waits too long fails with `queue_expired` without starting, and is not charged. To run tasks side by side, send them to different phones with `device`.

Send an [`Idempotency-Key`](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/) header, as in the capped example above, to retry a start safely. A retry with the same key returns the first request's task id instead of starting a second run. The post on [queued turns and safe retries](https://lusor.ai/blog/phone-tasks-queue-and-retry) covers the same ideas for agent turns and sessions.

## What else is there?

To keep working on the screen a task ended on, send it a turn with interact, covered in [introducing interact for phone apps](https://lusor.ai/blog/introducing-interact-for-phone-apps). The search and crawl calls are not available yet. Every field, status and error code is in the [agent docs](https://docs.lusor.ai/app-data/agent), next to the [scrape docs](https://docs.lusor.ai/app-data/scrape) and the [map docs](https://docs.lusor.ai/app-data/map).

## Frequently asked questions

### When should you use Lusor's agent call instead of scrape?

Use agent when the work needs judgment: signing in, searching, filling a form, or moving through an app to reach the data. Use scrape when you already know the screen and can write its app:// address, because scrape follows the address with fixed rules and no agent.

### How do you get JSON back from a Lusor agent task?

Send a JSON Schema as schema with the prompt. When the task is completed, data is the object the schema describes. Mark the fields you always need as required, and use description to say what a field means. Without a schema, data is the agent's answer as text.

### What does awaiting\_human mean on an agent task?

The agent stopped to ask a person a question, and it resumes when the question is answered. The task id is also the id of its session, so you answer it like any session. Keep reading the task until its status is neither processing nor awaiting\_human.

### How do you limit what an agent run spends?

Send maxCredits, the most credits the run may spend. The run stops once its charge would pass it, ends failed with error Agent reached max credits and stopReason credit\_limit\_reached, and is charged at most maxCredits. Without maxCredits a default cap applies.

### How do you check what the agent did on the phone?

Every run is recorded. recordingUrl in the result points at the recording, and fetching it with the same API key returns signed video segments. While the task runs, liveViewUrl is a watch-only link to the phone, and GET /v1/sessions/{id}/events shows what the agent is doing.

### Can several agent tasks run at the same time?

On different phones, yes. A phone runs one task at a time, so a task sent to a busy phone waits, reading processing, and starts when the phone frees. To run tasks side by side, send them to different phones with device.

## About the author

**Josiah Richards**

- [LinkedIn](https://www.linkedin.com/in/illjosiah/)

## Keep reading

- [The best MCP servers for Android phones](https://lusor.ai/blog/best-mcp-servers-for-android-phones): A shortlist of nine MCP servers for Android phones. What each one shows the agent, its setup, where it runs and its license, from each project's own docs.
- [How to give your AI agent an Android phone: every option](https://lusor.ai/blog/give-your-ai-agent-an-android-phone): Every way to give an AI agent an Android phone: adb, Appium, mobile-mcp, phone-harness and Lusor. Setup, what the agent sees, cost, and when to pick each.
- [Introducing interact: continue a phone app task in plain words](https://lusor.ai/blog/introducing-interact-for-phone-apps): Lusor's POST /v1/interact/{id} continues a scrape or agent task on the screen it ended on: send a turn, read the output, stop, and handle a busy phone.
