Skip to content

Agent API8 min read

How to answer a phone agent's questions from your code

A phone agent sometimes needs a choice only a person can make. Here is how a Lusor run pauses on a question, how your code finds it and answers it, and why a password or a code never goes through the API.

By Josiah Richards

TL;DR

  • When Lusor's agent needs a choice it cannot make on its own, it asks, and the session's status becomes awaiting_human. The question is a hitl_requested event with a correlation_id, the question and, sometimes, suggested options.
  • Your code answers with POST /v1/sessions/{id}/hitl, sending the correlation_id and a response in free text or one of the options. The call returns 202, and the agent continues with that text as its reply.
  • Sending the same answer again is safe. A different answer to an answered question returns 409, and an answer to a question that an ended session or a newer message left behind returns 410.
  • Lusor never accepts a password or a code through the API. When a session started in the Lusor app asks for one, an answer sent with an API key returns 403 secure_ask_dashboard_only and stores nothing.
  • A session started with an API key signs in with Vault secrets named in secrets, and the agent types them without the model seeing the values. When it needs a secret it was not given, it ends at once as failed with error secret_required:<name>.

A phone agent works inside apps that are signed in as a person. Sometimes a task leaves a choice that only that person can make, such as which of two accounts to use. Lusor's agent asks instead of guessing, and the run waits for the answer.

In the Lusor app the question appears in the chat. When your product starts runs through the API, your code has to notice the question, get an answer and send it back. This post goes through that with curl. It also covers the one kind of question the API never answers, a request for a password or a code.

Why does a phone agent need to ask at all?

Because a wrong guess on someone's phone has real effects. If two accounts are signed in to an app and the task does not say which one to use, a guess can send a message from the wrong account. Asking costs one round trip.

The agent asks with a question and a reason. When the plausible answers are few and distinct, it also offers 2 to 4 short labels, each at most 40 characters, which the Lusor app shows as buttons. Questions come in two kinds, and the API treats them differently.

  • A plain question. The agent needs something it can be told in text, such as a choice, a missing detail or a confirmation. Your code can answer it with an API key.
  • A request for a secret. The agent needs a password or a sign-in code. An API key never answers it. The sections below explain why and what happens instead.

How does your code see that a run is waiting?

The session's status changes to awaiting_human. Read it with the status endpoint, which is the cheapest read of a session.

curl https://api.lusor.ai/v1/sessions/$SESSION/status \
  -H "X-Api-Key: $LUSOR_API_KEY"

The response has id, status, deviceId, startedAt, completedAt and error. The final statuses are completed, complete, failed and cancelled. awaiting_human is not one of them, so a loop that polls every few seconds until the session ends has to stop on awaiting_human as well. Otherwise it keeps polling while the agent waits for an answer that never comes. The same loop serves every agent run, including one that returns JSON in a shape you define.

The question itself is in the session's events, as a hitl_requested event. Read the events with GET /v1/sessions/{id}/events, and pass the timestamp of the last event you saw as since to get only newer ones.

curl "https://api.lusor.ai/v1/sessions/$SESSION/events?since=2026-11-02T12:00:05.120Z" \
  -H "X-Api-Key: $LUSOR_API_KEY"
{
  "id": "3b2f6c1e-…",
  "type": "hitl_requested",
  "timestamp": "2026-11-02T12:01:30.000Z",
  "data": {
    "correlation_id": "3b2f6c1e-…",
    "reason": "Two accounts are signed in to the app.",
    "question": "There are two accounts on this phone. Which one should I use?",
    "options": ["Personal", "Work"]
  }
}
  • data.correlation_id identifies the question. You send it back with the answer.
  • data.question is what the agent asks, and data.reason says why it needs to know.
  • data.options holds the suggested answers, when the agent offered some.
  • data.kind appears only on a request for a secret, set to credential or 2fa.

A session can ask more than once. Answer the newest hitl_requested event, because a newer question replaces the one before it. The follow a session docs list every status and the other reads of a session.

How do you answer, in free text or with an offered option?

Send POST /v1/sessions/{id}/hitl with the question's correlation_id and your response.

curl https://api.lusor.ai/v1/sessions/$SESSION/hitl \
  -H "X-Api-Key: $LUSOR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "correlation_id": "3b2f6c1e-…", "response": "Work" }'

The call returns 202, and the agent continues with your text as its reply. The options are suggestions, not a fixed list, so response can be any text. When an option fits, sending its label as offered is the clearest answer. If the phone is busy with another session, data.continuation.queued is true in the response, and the agent continues when the phone is free. Once Lusor accepts the answer, the events include a hitl_resolved event with the same correlation_id.

Retries are safe. Sending the same answer again returns 202 with data.idempotent set to true, and nothing changes. A question stays answerable until the session ends or something newer replaces it. A newer question does, and so does a follow-up message sent to the session instead of an answer.

Errors from the answer endpoint
Meaning
400 bad_requestcorrelation_id or response is missing.
403 secure_ask_dashboard_onlyThe question asks for a password or a code.
404 not_foundThe session, or a question with this correlation_id in it, does not exist.
409 conflictThe question was already answered with different text. The first answer stands.
410 stale_hitl_requestThe session has ended, or a newer question or message replaced this one.
402 credits_exhausted, billing_requiredThe agent cannot continue for billing reasons.

Who answers is up to your product. It can show the question and its options to the person whose phone it is, apply a rule your code already has, or hand the question to a model. An AI app connected through Lusor's MCP server for real phones answers with reply_to_task. The answer the agent docs have the same call in Python and Node.js.

Why can't an API key send a password or a code?

Because an answer becomes part of the agent's conversation. The agent continues with your text as its reply, so a password sent as an answer would be written into the run's transcript and its events, and it would pass through your server and its logs on the way. Lusor never accepts secret values through the API.

On a session started in the Lusor app, a request for a secret looks like any other question, except for kind and secret_name.

{
  "type": "hitl_requested",
  "data": {
    "correlation_id": "9d41a0b2-…",
    "reason": "The app asks for the account password.",
    "question": "What is the Gmail password?",
    "kind": "credential",
    "secret_name": "gmail_password"
  }
}

What happens next depends on where the session started.

  • A session started with an API key never pauses for a secret. It uses the secrets saved in the workspace's Vault, by name, and ends at once when it needs one it was not given. The next two sections cover both.
  • A session started in the Lusor app pauses and waits, and only the Lusor app can answer. An answer sent with an API key returns 403 with error: "secure_ask_dashboard_only", nothing is stored, and the session stays paused.

Lusor decides whether a question asks for a secret from the event the agent recorded, never from anything in the answer request. Only a person signed in to the Lusor app can answer one. Every other kind of caller is refused, and an AI app connected through the MCP server is refused as well. In the app, the value is stored outside the agent's context, and the run resumes with a reference to it rather than the value.

How do saved Vault secrets let a run sign in without pausing?

The secret is saved once, in the Lusor app, and each run names the secrets it may use. Secrets are added, changed and deleted only in the app's Vault, never with an API key. Your code can list their names.

curl https://api.lusor.ai/v1/workspaces/$WS/vault \
  -H "X-Api-Key: $LUSOR_API_KEY"

Each item has a slug and fields. A secret's name is <slug>.<field>, so an item titled Gmail with the fields username and password gives gmail.username and gmail.password. Values are never returned. The Vault list reference has the full response.

Name the secrets in secrets when you create a session on a phone with POST /v1/workspaces/{workspaceId}/devices/{deviceId}/sessions.

curl https://api.lusor.ai/v1/workspaces/$WS/devices/$DEVICE/sessions \
  -H "X-Api-Key: $LUSOR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Sign in to Gmail and read the subject of the newest email",
    "secrets": ["gmail.username", "gmail.password"]
  }'
  • With secrets, the run can use only the secrets you named, and [] allows none.
  • Without secrets, the run can use every secret saved in the workspace. A turn sent to an agent with POST /v1/agents/{id}/turns takes no secrets list, so it can too.
  • A name that is not saved returns 422 with error: "unknown_secret" and the names in missing, and no session is created.
  • Reusing an Idempotency-Key with a different secrets list returns 409 idempotency_conflict.

The agent types a saved secret on the phone without the model ever seeing the value. Lusor also redacts every value typed this way from the run's transcript, its events and its logs, including when the app echoes the value back in the screen's element tree. That redaction covers text. It does not change the screen, and a live view always shows the phone as it is. Screenshots and recordings are pictures of the screen, and Lusor does not promise to hide a typed value in them. What else an agent can see on a phone you own is the subject of whether it is safe to let an agent use your phone.

Signing in is often the first step of a longer job. The post on copying app data into a Sheet shows one that ends in a table.

What happens when a secret is missing?

The run ends at once. When an API run needs a password or a code it was not given, it does not pause, because no API key could answer. The session ends with status failed and error set to secret_required:<name>.

{
  "id": "…",
  "status": "failed",
  "deviceId": "…",
  "startedAt": "2026-11-02T12:00:01.000Z",
  "completedAt": "2026-11-02T12:00:48.000Z",
  "error": "secret_required:gmail_password"
}

<name> is the agent's own name for the value it needed, made of lowercase letters, digits, _ and -. It is not a Vault name, because Vault names have a dot, so treat it as a hint. In this example, gmail_password points at the gmail.password field of a saved item. There are three ways to finish the task.

  • Save the secret in the Vault, then start a new session that names it in secrets. The saved secrets docs walk through it.
  • Sign in to the app on the phone yourself first, so the agent finds it already signed in.
  • Give the task to the agent from the Lusor app, where it can ask you for the secret and you answer in the app.

error is a fixed code, so your code can branch on it instead of parsing the agent's summary. For a run that finishes but may still be wrong, checking an agent that says it is done covers what to read. And a job whose steps your code already knows needs no agent and never stops to ask. Driving a phone from your own code covers that path. The API reference for the answer endpoint has the full schema.

Frequently asked questions

How does your code know a Lusor session is waiting for an answer?

GET /v1/sessions/{id}/status returns the status awaiting_human, and the session's events include a hitl_requested event. Its data holds correlation_id, question and, when the agent offered some, options. awaiting_human is not a final status, so a loop that waits for the end of a session should stop on it too.

Do you have to answer with one of the offered options?

No. The options are suggestions. POST /v1/sessions/{id}/hitl takes any text as response, and the agent continues with that text as its reply. Sending an option's label exactly as offered is the clearest answer when one fits.

What happens if you send the same answer twice?

Nothing changes. The call returns 202 with idempotent: true. A different answer to a question that was already answered returns 409 conflict, and the first answer stands. An answer to a question whose session has ended, or that a newer question or message replaced, returns 410 stale_hitl_request.

Can you send a password or a 2FA code through the Lusor API?

No. A question that asks for a secret has data.kind set to credential or 2fa. A session started with an API key never pauses on one, and a session started in the Lusor app accepts the answer only from the app. An answer sent with an API key returns 403 secure_ask_dashboard_only, nothing is stored and the session stays paused.

How does a run started with an API key sign in to an app?

Save the login in the Vault in the Lusor app, list the names with GET /v1/workspaces/{workspaceId}/vault, and name the ones the run may use in secrets when you create the session, for example gmail.password. The agent types them on the phone without the model seeing the values.

What does secret_required mean on a failed Lusor session?

The agent needed a password or a code that the run was not given, so the session ended at once as failed. The part after the colon is the agent's own name for the value, such as gmail_password. Save the secret in the Vault and start a new session that names it in secrets, sign in to the app on the phone yourself first, or give the task to the agent from the Lusor app.