# 选项 · 模式与权限

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/agents/options/mode/
Language: zh

`mode · onPermission · onQuestion · system`

哪些是允许的,没有问, 会发生什么 当必须问的东西, 和什么你添加到 代理指令。

Status: ask by default · no callback means refused · system adds

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `mode` | string | "ask" | `ask` · `auto` · `plan` · `full`. |
| `onPermission` | function |  | `({ id, tool, category, args, mode }) => "once" \| "always" \| "deny"`. |
| `onQuestion` | function |  | `({ id, question, options }) => string`。没有它,就没有 `ask_user` 工具。 |
| `system` | string | "" | 添加到系统提示中, 它不会替换它 。 |

```javascript
api.agents.create({
  runtime: "local", machine: pc, model,
  mode: "auto",
  system: "This repository is a Next.js app. Never edit anything under generated/.",
  onPermission: async ({ category, args }) => {
    if (category !== "exec") return "deny";
    return /^npm (test|run build)$/.test(args.command) ? "always" : "deny";
  },
  onQuestion: async ({ question, options }) => askThePerson(question, options),
});
```

## 无需在 Ppermission 下, 它只能读取 {#no-callback}

> **要求的一切都被拒**
>
> 拒绝者说 — — “需要用户批准,没有人能批准 ” — —然后回到模式,这个模式可以适应。 一个没有回调的代理商几乎只能读取,不管它的方式如何,包括完全访问。

## 模式改变中跑 {#changing}

```javascript
agent.setMode("auto");     // takes effect on the next tool call, subagents included
```

## 系统,没有替换 {#system-adds}

引擎在发动机本身的指示后附着。 无法选择取代提示, 因为大多数描述的能力是真实存在的—— 去除它会使模型错误,而不是自由。

对于适用于工作空间上每个运行的指令,文件更好: `IAGENIFY.md` 工作空间中的“瞬间”被读取为“即时”,一个人可以看到。

## 子代理商继承了两个回调 {#inherited}

代表的工具与父母的调回方式相联。 降任不是绕过许可的方式,这正是为什么 `task` 自由了 自由了 自由了 自由了 自由了

- [模式](/zh/sdk/agent/modes): 四号
- [权限](/zh/sdk/agent/permissions): 整个回调
- [系统提示词](/zh/sdk/agent/system-prompt): 添加的内容。

```python
import re

def on_permission(request):
    if request["category"] != "exec":
        return "deny"
    return "always" if re.fullmatch(r"npm (test|run build)", request["args"].get("command", "")) else "deny"

api.agents.create(
    runtime="local", machine=pc, model=model,
    mode="auto",
    system="This repository is a Next.js app. Never edit anything under generated/.",
    on_permission=on_permission,
    on_question=lambda request: ask_the_person(request["question"], request["options"]),
)
```

```python
agent.set_mode("auto")   # takes effect on the next tool call
```
