# interrogazione

Canonical URL: https://developers.iagenify.com/pt/sdk/agent/events/question/
Language: pt

`{ type: "question", id, question, options }`

L'agente ti chiede qualcosa e ha stet a attendere. Stessa forma come un permis, significant differente: qui vore una risposta, non un'aprobazion.

Status: needs onQuestion · the loop waits · question_result follows

## Campos {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | Generato per esta interrogazione. |
| `question` | string |  | - Cee que si chiede. |
| `options` | array |  | Risposte sugestive, quando offrise. |

## Necessà aQuestion {#requires}

```javascript
const agent = api.agents.create({
  runtime: "local", machine: pc, model,
  onQuestion: async ({ question, options }) => {
    console.log(question, options);
    return await readAnswerFromTheUser();     // a string
  },
  onEvent: (e) => {
    if (e.type === "question")        showQuestion(e.id, e.question, e.options);
    if (e.type === "question_result") closeQuestion(e.id, e.answer);
  },
});
```

> **Senza onQuestion non c'è ask_user**
>
> L'utenda è solo cablada quando la chiamata è là. Un agente senza esso non ha modo di chiedere, ed è instruit a fare un appello di giudizio o explicar ce blocca in lugar — che è un run differente, non un block.

## question_result {#result}

```javascript
{ type: "question_result", id, answer }    // "" when nothing was returned
```

Una risposta vazio è passè al agente come una risposta vazio; non è un erro, e il loop continua.

## Quando il sollevi {#when}

- La richiesta è ambigua e la scelta è del user.
- Due tentazioni di la stessa approccio hanno fallit — si dice a chiedere plutôt que tentar un tercio.

## Un subagente non chiede mai {#subagents}

`ask_user` è uno dei tre strumenti che un subagente non riceve. Si dice che non può parlare con l'usuario e deve informar in cambio — quindi una domanda sempre viene da la run principal, e non porta `parentId`.

- [ask_user](/pt/sdk/agent/tools/ask-user): L'utensiliu.
- [Permiso](/pt/sdk/agent/events/permission): La stessa forma, per le aprovacions.

```python
def on_question(request):
    print(request["question"], request["options"])
    return read_answer_from_the_user()     # a string

agent = api.agents.create(runtime="local", machine=pc, model=model, on_question=on_question)
```

```python
# The ask_user tool returns what on_question answered, or None when no callback is set
{"answer": "the second option"}
```
