AgentUpdated 7 min read
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.
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 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 explains. To see which screens Lusor already knows in an app, call map, covered in 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.
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.
{
"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:
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?
{
"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, 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 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.
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}/eventsshows what the agent is doing. See follow a session.- An
awaiting_humantask is answered like any session. See answer the agent. POST /v1/sessions/{id}/stopstops it. See 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.
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.
{
"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.
curl "https://api.lusor.ai/v1/sessions/$TASK_ID/recording" \
-H "X-Api-Key: $LUSOR_API_KEY"The recordings and replay docs cover the video and the step replay, and your agent says done: here is 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.
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 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 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. The search and crawl calls are not available yet. Every field, status and error code is in the agent docs, next to the scrape docs and the map docs.
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.