怎么设计 Agent 的工具权限边界How to Set Tool Permissions for an Agent
微型指南 · 约 8 分钟Guide · about 8 min · 引用核验 2026-11-17(仅引用链接与日期) · refs checked 2026-11-17 (reference links and dates only)
Agent 的风险不在「会不会说错」,而在「能不能替你按下不可撤销的按钮」。权限要先分级,再收窄。The risk of an agent is not a wrong sentence; it is pressing an irreversible button on your behalf. Classify permissions first, then narrow them.
先列工具清单,按只读、写入、对外发送、花钱、删改五级分类。
默认最小权限:能读一个目录就不要给整个盘;能查就不要给改。
写操作要二次确认:把参数和影响范围展示给人,确认后才执行。
对外发送与支付单列:这类动作不可撤销,必须人工在场。
用白名单而不是黑名单:URL、命令、路径都列允许集合。
记录每次调用:谁、什么参数、结果、耗时;日志要能回放到具体任务。
把工具返回内容当不可信输入,不执行其中的指令;定期做越权演练验证拦截。
List every tool and classify it into five levels: read-only, write, external send, spend and delete.
Default to least privilege: one directory, not the whole disk; query access, not write access.
Require confirmation for writes: show the parameters and blast radius, then execute only after a human approves.
Treat external send and payment separately: these are irreversible and need a human in the loop.
Use allowlists, not blocklists: enumerate permitted URLs, commands and paths.
Log every call: who, which parameters, result and latency; logs must replay to a specific task.
Treat tool output as untrusted input, never execute instructions inside it, and run periodic privilege-escalation drills.
例子与判断Example and interpretation
以下是教学情境,不是本站运行或实测记录。A teaching scenario, not a measured or executed site test.
画一张权限矩阵:每个工具 × 读 / 写 / 发送 / 付费四种动作,标出「允许 / 需确认 / 禁止」。这张表就是上线前的审查清单。Draw a permission matrix: every tool against read, write, send and pay actions, marked allow, confirm or deny. That table is the pre-launch review checklist.
做完例子后怎么检查How to check your practice
先用自己的话解释上面的判断,再检查输入条件,最后回原文验证。说不清原因时回概念;缺日期、字段或权限时补输入;结论无出处时先撤回结论。Explain the example in your own words, inspect input constraints, then verify against the source. Revisit concepts if you cannot explain why; supply missing dates, fields or permissions; withdraw unsupported conclusions.
按这篇主题,先从“输入缺信息”练习查起For this topic, start with missing input · 查看全部六个情境与理由See all six scenarios and their reasoning
智能体 / AgentAgent 工具调用Tool Calling / Function Calling 权限Permission