# 问题

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

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

代理商在问你一些事情, 并且停止等待。 和许可一样, 不同的含义: 它想要答案, 而不是批准 。

Status: needs onQuestion · the loop waits · question_result follows

## 字段 {#fields}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | 是为这个问题而生成的。 |
| `question` | string |  | 问什么? |
| `options` | array |  | 提出答案时,建议给予答案。 |

## 需要就问题 {#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);
  },
});
```

> **问题没有没有 ask_user**
>
> 工具只有在回调出现时才有电线。 一名没有回调的特工无法问话,他奉命要打个判断电话或解释什么是阻碍,这是另一场不同的跑,而不是卡住的跑。

## question_result {#result}

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

空答案作为空答案传递给代理商; 它不是一个错误, 循环会继续 。

## 当它问它问 {#when}

- 请求含糊不清,用户的选择。
- 两次试图采取同样办法的努力都失败了——有人说,它要问的是非要试第三个。

## 子试剂从不问 {#subagents}

`ask_user` 是一个子试剂得不到的三种工具之一。 被告知它不能与用户交谈, 并且必须报告, 反之必须汇报, 所以问题总是来自主运行, 永远不携带 `parentId`.

- [ask_user](/zh/sdk/agent/tools/ask-user): 工具。
- [许可权限](/zh/sdk/agent/events/permission): 同样的形状, 批准。

```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"}
```
