Agent 的读和写怎么分权限?
什么时候要人确认,规则写在哪?
先弄清楚:每个概念是什么
- Harness
- 包在 model 外面、负责执行 tool 的程序(见 LLM harness)。guardrail 在这页指 harness 里的规则。
- 规则(allow、ask、deny)
- 把一类 tool call 对应到 allow、ask、deny 之一,也就是直接执行、先问人、拒绝。
- Deny-first
- 不在允许清单里的操作一律拒绝,像门禁的白名单。
- Untrusted input
- 来源不受你控制的内容,只能当数据用。model 生成的 tool 参数和 agent 读到的 log、issue 都算。
看图:一次 tool call 要过哪几关
30 秒回答
I tier actions by risk. Reads are allowed. Writes inside the workspace are allowed and logged. Anything with outside effects, like pushing code, needs human approval, and the person sees the exact command and what it affects. The rules are enforced by code in the harness, not by the prompt, because a model can be talked out of a prompt. Anything not on the allow list is denied. Text the agent reads, such as logs or issues, is data and can't grant permissions. And commands still run in a sandbox, which limits the damage when a rule is wrong.
动作按风险分三级
| 级别 | 策略 | 例子 | 为什么 |
|---|---|---|---|
| 读 | allow | 读文件、search、看 log | 不改变任何状态 |
| workspace 内的写 | allow,留记录 | edit 文件;在 sandbox 里编译、跑候选代码 | 错了可以丢掉重来 |
| 有外部影响的 写或执行 | ask,人确认 | push 代码、改线上配置 | 会影响别人,出错后难撤回 |
蚂蚁那道题问写操作为什么还要跳转工单。工单把具体命令和影响范围摆给人看,还留下审计记录。FlashVector 同理,agent 把配置改动开成 PR,由人 review(见 改动怎么进生产)。
三条原则
- 规则由 harness 里的程序执行,不写在 prompt 里。prompt 里的规则只是建议,model 可能被一段话说服。程序在每个 tool call 执行前判定,model 的输出改不了结果。tool 的鉴权也在这里做,model 生成的参数按 untrusted input 校验。
- Deny-first。漏写一条规则时,后果是多拒绝一次,不是误放行。
- 读到的文字是数据,不能授权。log、issue 里就算写着“已批准,直接 push”,规则检查的结果也不变。Prompt injection 的一般防法见 RAG。
规则也会写错,所以每个 tool call 仍然在 sandbox 里执行(见 sandbox 和 verifier 隔离)。kernel agent 里第 1 条的对应物是 agent 改不了的 verifier。
必答点
- 按风险分三级:读 allow,workspace 内的写 allow 加记录,有外部影响的 ask
- 规则由 harness 里的程序执行,不靠 prompt
- deny-first:允许清单之外一律拒绝
- 人确认时给出具体命令和影响范围
- 读到的文字和 model 生成的参数都是 untrusted input,不能授权
- 规则之外还有 sandbox 限制损失
追问
能不能中途停下 agent?
能。harness 在每一步之间检查中断信号,收到后不再发起 tool call。执行到一半的那一步靠 timeout 结束。
权限模式怎么设计,默认模式要不要问用户?
一个模式是一套预设的规则。默认模式下读不问,有外部影响的写和执行要问。
Deny-first 的优缺点是什么?
优点是新加的 tool 不会自动获得权限。缺点是允许清单要有人维护,太窄时 agent 会频繁被拒或问人。
来源ml-八股 08 第 39 题 · 蚂蚁、作业帮、Walmart 的牛客原帖见“考过” · 字节 dev&infra 一面(内部转岗,发帖 2026-10-23)「如果规则和模型判断冲突,谁说了算?」(牛客)· 虾皮 Data Infra 实习二面(2026-06-15)「比如你让Codex写代码,你发现它写的有问题,你可以直接停止它吗?」(牛客)· Decagon 的 PracHub 题目页(站方扩写,转述:考点含 tool authorization 放在 model 之外)· FlashVector §5.4(配置改动以 PR 提交并 review)