# Answer an agent’s input request

When an agent pauses mid-reply on a form in chat, fill it in or approve it. The [run](/docs/concepts/runs.md) waits up to five minutes for your answer.

## Before you start

You need an agent with the `veryfront__form_input` tool. Create Refund desk with the API tab of [Create an agent](/docs/agents/create-agent.md), using this body:

```json
{
  "id": "refunds",
  "name": "Refund desk",
  "system_prompt": "You handle refund requests. Before you answer, ask the customer for their order number and the reason for the refund with the form_input tool: one form with a text field for the order number and a select for the reason (Damaged, Late, Other). Then confirm the refund in one sentence.",
  "tool_ids": ["veryfront__form_input"]
}
```

## Answer the form

**Studio**

1. Open **Chat**.
2. Pick Refund desk under the message box.
3. Write "I want a refund." in the message box.
4. Press Enter. You should now see the agent's form, titled "Refund request details", with **Waiting for input**.
5. Enter `A-1042` as the Order number.
6. Open Reason for refund.
7. Pick Damaged.
8. Click the form's button, here "Submit refund request". You should now see the form close and the agent confirm the refund.
9. Click the form's title, "Refund request details". You should now see your answers, Order number `A-1042` and Reason for refund `Damaged`.

**API**

1. Start a run: follow steps 1 to 5 of the API tab of [Chat with an agent](/docs/agents/chat.md), with `refunds` as `AGENT_ID` and "I want a refund." as the text. They set `PROJECT` and `RUN_ID`.
2. List the waiting runs, again every few seconds until yours is there. You should now see your `RUN_ID`:

```bash
curl "https://api.veryfront.com/projects/$PROJECT/runs?status=waiting" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

3. List its open requests. Each lists its `fields` by `name`; a select or radio field also lists its `options`, each with a `label` and a `value`:

```bash
curl "https://api.veryfront.com/runs/$RUN_ID/input-requests?status=open" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

4. Set `INPUT_REQUEST_ID` to the request's `input_request_id`: `export INPUT_REQUEST_ID=<id>`.
5. Answer it, with a value for each field `name`. A select or radio field takes the option's `value`, not its `label`:

```bash
curl -X POST https://api.veryfront.com/input-requests/$INPUT_REQUEST_ID/responses \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: refund-answer-1" \
  -d '{ "values": { "order_number": "A-1042", "reason": "Damaged" } }'
```

6. Read the run, again every few seconds while it reads `running`. You should now see `completed`, with the agent's confirmation in `output.text`:

```bash
curl https://api.veryfront.com/runs/$RUN_ID \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

## With MCP

1. Start a run of Refund desk with steps 1 and 2 of With MCP on [Chat with an agent](/docs/agents/chat.md), with `refunds` as the agent's ID and "I want a refund." as the message text.
2. Call `veryfront__list_project_runs` with `{ "project_reference": "my-project", "status": ["waiting"] }` until your run is listed. The project reference is its slug or its ID.
3. Call `veryfront__list_run_input_requests` with `{ "run_id": "<the run's id>", "status": "open" }`.
4. Call `veryfront__create_input_response` with the request's `input_request_id`, an `idempotency_key` of your own (any string, the same for a retry) and `input` as `{ "values": { "<field name>": "<value>" } }`. A select or radio field takes one of its options' `value`, not its `label`.
5. Call `veryfront__get_run` with the `run_id` until its `status` is `completed`: it reads `running` for a few seconds after you answer. It worked when it is `completed`.

## Next steps

* [Add approvals](/docs/orchestration/approvals.md)
* [Find a run that failed](/docs/observability/runs.md)
