Agent 的读和写怎么分权限?
什么时候要人确认,规则写在哪?

英文问法How do you control what an agent is allowed to do? · Which actions need human approval, and how do you enforce that? · Are the rules written into the prompt, or enforced by code?

考过没有 Unity 自己的面经原题,下面都是别家的面经 · 蚂蚁二面(校招,2026-09-21)「Agent 的读操作和写操作分别如何鉴权与控制风险?为什么写操作最终仍要跳转工单由用户确认?」(牛客)· 作业帮 Golang 实习一二面(发帖 2026-10-22)「规则引擎是把规则写进提示词,还是由程序读取并执行规则?」「权限模式是怎么设计的?默认模式是否需要询问用户?」(牛客)· Walmart(Onesec)Intern 二面(发帖 2026-09-10)「聊聊deny‑first安全模型,在你的项目中是怎么落地的,优缺点是什么?」(牛客)· 英文一侧是转述加短引文:Decagon SWE phone screen(2026-09)让候选人 "design security for the Decagon chatbot"(PracHub)· 按关键词搜到的样本里,中文有 14 帖、英文有 14 条涉及权限和 guardrail

先弄清楚:每个概念是什么

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 要过哪几关

harness:规则由程序执行,model 的输出改不了它 tool result 回到 context,是数据,不能授权 model 只提出,不执行 tool call 规则检查 allow sandbox 里执行 ask 人确认 同意 拒绝 deny 不执行,原因回给 model
图 1:model 在虚线框外,只能提出 tool call。tool result 只是数据,下一个 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(见 改动怎么进生产)。

三条原则

  1. 规则由 harness 里的程序执行,不写在 prompt 里。prompt 里的规则只是建议,model 可能被一段话说服。程序在每个 tool call 执行前判定,model 的输出改不了结果。tool 的鉴权也在这里做,model 生成的参数按 untrusted input 校验。
  2. Deny-first。漏写一条规则时,后果是多拒绝一次,不是误放行。
  3. 读到的文字是数据,不能授权。log、issue 里就算写着“已批准,直接 push”,规则检查的结果也不变。Prompt injection 的一般防法见 RAG。

规则也会写错,所以每个 tool call 仍然在 sandbox 里执行(见 sandbox 和 verifier 隔离)。kernel agent 里第 1 条的对应物是 agent 改不了的 verifier。

必答点

追问

能不能中途停下 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)