Paper: 2612.04470 — TagOut: Safely Restricting Agent Tools Without Over-Refusal or False Promises Authors: Sudhanshu Jaiswal Categories: cs.AI, cs.CL Reading scope: Complete reading of the main paper in original arXiv HTML (Abstract, Sections 1–8, Limitations, Ethical Considerations, References, Tables 1–6, Box 1) plus targeted appendix sections (Appendices A index, D.3, D.6, and H.7); Figures 1 and 2 were downloaded and visually inspected before reproduction below, while multi-turn KV-cache figures are analytical projections rather than live runs. This is a source-based reading without independent peer review or code reproduction.

The Problem

Imagine an assistant that normally carries four tools: three for persistent cross-session storage (memory_store_write, memory_store_read, and profile_preference_update) plus one in-session helper (ephemeral_scratchpad_note). Now a user opens a temporary guest chat on a shared laptop where zero data may persist across sessions (Section 1, Box 1).

To avoid rewriting prompts or breaking shared prompt-prefix caches across session modes, production deployments usually take one of two shortcuts:

  • Prompt ban: keep all four tool JSON schemas attached, and write a prohibition in the system prompt forbidding the three memory tools in guest mode.
  • Silent schema removal: drop the three memory tool schemas from the request, and leave the system prompt silent about the restriction.

Both shortcuts break on ordinary requests (Box 1). Under a narrow tool-only prompt ban, when a user asks “pull up my default workspace ID that I saved last week,” Gemma 4 26B-A4B emits memory_store_read anyway—rationalizing in its thought trace that the ban only stated a condition rather than applying right now, even though the prompt header tagged a guest workspace. On the very next request (“next session, start by loading the vendor shortlist we just built”), the same model promises to save the shortlist for next time. Adding a broader safety warning stops those leaks, yet spills over onto harmless boundary prompts and traps restricted requests in unhelpful dead-end refusals.

Flip to silent schema removal and the model fails in the opposite direction: seeing no memory schemas and no explanation of why persistence is off, both Gemma 4 31B and 26B-A4B reply “Understood. I have noted that instruction” and confidently promise to load the workspace ID next session—an impossible false promise. Even adding a runtime dispatcher blocker cannot fix this alone, because false refusals, dead ends, and false promises happen in plain text without any tool call.

The Explanation

Jaiswal traces all four failures—leaked calls, false promises, dead-end refusals, and harmless over-refusal—to a single architectural bug: three channels carry a session’s policy, and shortcuts update only one while leaving the others stale (Section 3.1).

Allowed-tool vector c = (0, 0, 0, 1)  [guest mode: scratchpad only]
          |
          +--> 1. Tool Schemas (S_c)   : drop 3 memory schemas, keep scratchpad
          +--> 2. System Prompt (I_c)  : insert short redirect notice + fallback
          +--> 3. Runtime Dispatcher   : reject any tool not in allowed list

TagOut is a training-free runtime coordination layer that computes all three channels from one allowed-tool indicator list on every request (Section 3.2):

  1. Tool schemas: send only the schemas of currently allowed tools, deleting the restricted action space from context.
  2. System prompt: remove descriptions of restricted tools and insert a short, affirmative redirect notice explaining what capability is unavailable in this session and what in-session help the assistant can offer instead (e.g., offering a copy-ready summary of the vendor shortlist rather than promising to save it). For whole capability categories, TagOut names the category without naming banned tool identifiers; its minimal form is just two sentences, while the full memory-agent prompt adds explicit benign-scope rules.
  3. Runtime dispatcher + pre-dispatch checks: enforce the same allowlist deterministically at execution time, and verify four consistency rules before dispatch (L1: active tool parity; L2: no negative bans; L3: redirect required whenever any tool is restricted; L4: never pair tool restrictions with broad sensitive-topic bans; Section 3.3).

Primary evaluation: Guest memory and harmless boundary prompts

The author evaluates 10,800 live single-turn requests (greedy decoding with visible reasoning traces) on two open-weight Gemma 4 models—dense 31B IT and mixture-of-experts 26B-A4B IT—across three four-tool domains: guest memory, read-only SQL analysis, and read-only cloud-operations auditing (Section 4). In the primary memory suite, 650 prompts combine 450 harmless prompts (250 XSTest Safe, 150 OR-Bench-Hard borderline prompts, 50 in-scope security/systems technical questions), 150 harmful prompts (100 XSTest Unsafe + 50 in-domain insider-IT prompts), and 50 restricted memory requests.

TagOut Figure 1: Benign OR-Bench-Hard answers versus honest redirection on restricted memory requests for Gemma 4 31B and 26B-A4B Figure 1 (from the paper): Share of harmless OR-Bench-Hard requests answered (horizontal axis) versus restricted memory requests honestly redirected (vertical axis) on Gemma 4 31B (left) and 26B-A4B (right). TagOut sits alone in the target upper-right corner with zero leaked calls and zero false promises.

On Gemma 4 31B (Tables 1, 3, and 4; Fig. 1):

  • Harmless over-refusal drops below even the unrestricted baseline: Across all 450 harmless prompts, the Composite safety-warning ban pushes false refusals up to 22.7% (56.7% on OR-Bench-Hard and 10.0% on in-scope technical questions that need no memory tool). TagOut cuts overall harmless false refusals to 7.3%, dropping OR-Bench-Hard false refusals to 20.7% (36.0 percentage points below the Composite ban and 10.0 points below the 30.7% unrestricted baseline) and returning technical questions to 0.0%. On 26B-A4B, OR-Bench-Hard false refusals fall to 25.3% (versus 40.0% under Composite ban and 34.7% unrestricted).
  • Restricted requests turn into constructive redirects: On the 50 restricted memory requests, TagOut reaches 98.0% constructive redirects on both 31B and 26B-A4B, with 0.0% leaked calls and 0.0% false promises (2.0% / 0.0% dead ends). By contrast, the Composite ban traps 62.0% / 60.0% in dead-end refusals (34.0% / 38.0% redirects); the Narrow tool-only ban still leaks 10.0% calls and 30.0% false promises on 26B-A4B; and neutral silent schema removal makes 30.0% / 32.0% false save promises (28.0% / 26.0% redirects)—or even worse, 52.0% attempted calls to missing tools and 40.0% false promises on 31B when paired with the stale original prompt.
  • Harmful refusal stays high, with a tight boundary on 26B-A4B: On the 150 harmful prompts (Table 3, Appendix D.3), TagOut refuses 94.0% on 31B versus 95.3% for the Composite ban, passing the 5-point non-inferiority margin (p = 0.0282). On 26B-A4B (92.7% vs. 94.7%), the one-sided upper bound reaches +5.23 pp (p = 0.0603), narrowly missing that 5-point margin.

The counterintuitive mechanism: Hidden schema–warning interaction

Why did simply removing three unused memory schemas under the exact same byte-identical Composite safety-warning prompt drop 31B OR-Bench-Hard false refusals by 13.3 percentage points (56.7% → 43.3%), when none of those prompts even involve memory?

Eleven controlled ablations (Section 6.1, Table 4, Appendix D.6) reveal a sharp +12.0 percentage-point interaction on 31B (exact sign-flip p = 0.0173; +9.33 pp pooled across both models, p = 0.0038): visible restricted schemas strongly inflate harmless refusals specifically when paired with a broad safety-warning ban, yet barely move refusals under a redirect contract (22.0% → 20.7%).

Reasoning-trace forensics uncover the surprise (Section 6.3, Table D.8): 0.0% of the refusal traces under the Composite ban even mention a memory tool. Keeping restricted schemas visible does not confuse tool selection—instead, it makes the model invoke the prompt’s general safety warning far more often on sensitive-sounding benign queries. Across the 27 OR-Bench-Hard prompts rescued when those three schemas are removed on 31B, mentions of the topical guardrail in the model’s reasoning drop from 55.6% to 25.9% (McNemar p = 0.0215). Separately, ablations show the two-sentence minimal redirect notice alone already gets 96.0% redirects (31B) and 26.7% OR-Bench-Hard refusals (already below the 30.7% unrestricted baseline), while adding explicit benign-scope rules lowers OR-Bench-Hard refusals the rest of the way to 20.7%.

Cross-domain transfer and KV-cache token economics

TagOut Figure 2: Cross-domain constructive redirection across memory, SQL analyst, and cloud operations auditor Figure 2 (from the paper): Constructive redirects on restricted requests across all six domain–model pairs. TagOut redirects at least 84.0% in every suite, outperforming Composite prompt bans by +52.0 to +88.0 percentage points.

Testing the exact same three-channel design on 1,200 live requests across a read-only SQL analyst and cloud-operations auditor (25 restricted mutating requests + 25 benign diagnostic questions per domain and model; Section 7.1, Table 5, Fig. 2) confirms the pattern:

  • Under neutral silent schema removal, 76.0% (31B) / 74.0% (26B-A4B) of restricted write requests end in unredirected text/promises, plus 16.0% / 20.0% empty calls to hallucinated tool names like sql_execute.
  • Under the Composite read-only ban, 86.0% (31B) / 70.0% (26B-A4B) collapse into dead-end refusals.
  • TagOut eliminates leaked write calls and false promises while lifting pooled constructive redirects to 92.0% (31B: 88% SQL, 96% Ops) and 86.0% (26B-A4B: 84% SQL, 88% Ops)—with 31B supplying a ready-to-review fenced SQL query or CLI command in 80.0% of restricted replies.

On token cost (Sections 3.4 & 7.2, Table 6): dropping three restricted schemas shrinks per-request prompt tokens by 54% on memory sessions (626 → 285, or 67% to 206 with the minimal notice) and 62% on SQL/Ops (712/642 → 237/276). For the trickier case of mid-conversation permission switches, the author analytically models a 20-turn session switching modes every four turns: naive full prefix re-encoding costs 17,120 uncached prefill tokens, whereas keeping all four schemas in a static neutral prefix with a decoder allowed-tool mask and appending TagOut’s redirect notice as a late-bound suffix after each user turn cuts uncached prefill by 52% (8,271 tokens) on standard exact-prefix caches, and by 68%–74% (5,421–4,421 tokens) if the serving engine supports position-adjusted KV-block relocation.

Core Concepts

  • Three-Channel Policy Parity: A tool restriction lives across three channels simultaneously—the tool schemas (what the model can call), the system prompt (what the model believes is allowed and how to help instead), and the runtime dispatcher (what actually executes). Updating only one channel creates stale-channel contradictions that cause leaks, false promises, or over-refusals.
  • Affirmative Redirect Notice vs. Negative Ban: Returning to our guest-chat vendor-shortlist request, a negative ban (“do not invoke memory_store_write”) leaves the model with no allowed path—producing dead ends—and interacts badly with attached schemas when paired with safety warnings. A short two-sentence redirect states the session boundary and names the concrete in-session fallback (summarize now, or output a manual SQL/CLI command).
  • Schema–Warning Salience Interaction: A subtle empirical finding: leaving banned tool schemas in the prompt does not merely risk leaked calls; alongside a broad safety warning, those unused schemas act as a silent trigger that amplifies refusals on completely unrelated harmless questions (56.7% → 43.3% on 31B OR-Bench-Hard without a single trace mentioning memory tools).
  • Late-Bound Suffix + Decoder Masking: The serving-stack design choice that reconciles TagOut with prompt-prefix caching when permissions toggle mid-session—keeping the prefix static, enforcing the allowed-tool vector in the decoder, and injecting/stripping the redirect notice at the tail of each user turn.

The Insight

Restricting an AI agent is not just an execution-sandbox problem; it is a state-synchronization problem between what the runtime allows and what the model is told it can do. Dropping a tool silently stops the call at the cost of confident fabrications, while banning a visible tool in prose triggers refusal spillover and dead ends. Deriving schemas, an affirmative redirect notice, and dispatcher enforcement from a single allowed-tool list resolves all four failure modes simultaneously while cutting prompt tokens—at least across the two Gemma 4 models and single-turn suites tested here.

A Critical Reading

The study is unusually disciplined in its ablations, paired statistical tests, and transparent reporting of negative edges, while several boundaries constrain how broadly to extrapolate:

  • One model family only (Limitations): All 10,800 live requests run on Gemma 4 (31B dense and 26B-A4B MoE). Frontier proprietary models or other open families (such as Qwen or Llama) may react differently to attached schemas and negation bans.
  • Small author-written restricted slices & author-audited classifier (Limitations, Appendix H.7): The restricted benchmarks contain 50 memory prompts and 25 each for SQL and cloud ops, all authored for this study in English. Outcome scoring relies on deterministic rule-based classifiers validated on a blinded 120-response audit conducted by the author (115/120 = 95.8%, 95% CI 90.5%–98.6%; all 5 disagreements cut against TagOut).
  • Single-turn live runs vs. modeled multi-turn KV caching (Limitations, Section 7.2): Only single-turn requests were executed live. Both the 20-turn mid-session switching token savings (52%–75%) and the “restoration suffix” preventing old redirects from lingering after a restriction is lifted are analytical models, and the strongest savings (68%–75%) require non-standard KV-block relocation in the serving engine.
  • Sources of the over-refusal gain and safety boundary (Section 5.4, 6.1, Appendix D.3): TagOut beats the unrestricted baseline on OR-Bench-Hard (20.7% vs. 30.7%) partly because its full prompt adds explicit benign-scope rules that the unrestricted baseline lacks (26.7% minimal notice vs. 20.7% full TagOut). Meanwhile, on 26B-A4B harmful prompts (92.7% vs. 94.7% Composite ban), TagOut narrowly misses the 5-point non-inferiority threshold (p = 0.0603), reminding practitioners to audit harmful-refusal floors whenever relaxing safety-warning boilerplate.
  • Fixed helper-schema wording: Across baselines, the allowed helper tool kept its original "do not invoke for ..." clause to hold schemas constant, leaving fully affirmative helper schemas untested.

What You Can Use

  • Generate schemas, system notice, and dispatcher allowlist from one config object: In any agent with session modes (guest chat, read-only analyst, dry-run deploy), stop hand-maintaining separate mode prompts and tool lists. Compute allowed_tools once per request, filter the serialized tool schemas, enforce the exact same list in your tool executor, and inject a short two-sentence redirect template naming the unavailable capability and the exact in-session fallback (e.g., “output a fenced SQL/CLI block for manual review”).
  • Audit your system prompts for the four TagOut pre-dispatch checks: Remove negative prohibitions paired with still-attached tool schemas (L1–L2), require a fallback clause whenever any tool is disabled (L3), and never bundle session-mode tool limits with vague warnings to “refuse sensitive or out-of-scope topics” (L4), which measurably amplifies harmless over-refusal.
  • Use late-bound suffixes if modes toggle mid-chat: For fixed-mode sessions (like opening a temporary chat or read-only tab), strip the restricted schemas from Turn 1 to save roughly half your prompt tokens immediately. Only if permissions flip repeatedly mid-conversation should you keep schemas static with decoder masking and append/strip the short redirect notice after the user turn to protect KV-cache hits.

论文: 2612.04470 — TagOut: Safely Restricting Agent Tools Without Over-Refusal or False Promises 作者: Sudhanshu Jaiswal 分类: cs.AI, cs.CL 阅读范围: 完整阅读了 arXiv 原文 HTML 主体(摘要、第 1–8 节、局限性、伦理说明、参考文献、表 1–6 与框 1)并查阅附录关键统计与审计节(附录 A 索引、D.3、D.6、H.7);图 1 与图 2 已下载并人工目检后嵌入正文;多轮 KV 缓存数据为原文解析建模结果,非线上多轮实测。本文为基于原文的读书笔记,不构成独立同行评审或代码复现。

问题

设想一个日常自带四个工具的智能体助手:三个用于跨会话长期记忆(memory_store_write 写入记忆、memory_store_read 读取记忆、profile_preference_update 更新偏好),外加一个仅限当前会话的临时草稿本(ephemeral_scratchpad_note)。 现在用户在公用电脑上开了一个临时访客对话,按规定结束后不能留下任何记录,三个记忆工具必须全部关闭(第 1 节、框 1)。

为了让不同会话模式共用前缀缓存、少维护几套提示词,工程部署里最常见两种偷懒捷径:

  • 提示词禁令(Prompt ban):四个工具的 JSON 定义照挂不误,只在系统提示词里写一句「访客模式下禁止调用那三个记忆工具」。
  • 静默隐藏工具(Silent schema removal):直接把三个记忆工具的定义从请求里删掉,但系统提示词里只字不提记忆功能已关闭。

结果两条捷径在最普通的请求上都会翻车(框 1)。 在仅禁工具的窄提示词禁令下,用户说「把上周存的默认工作区 ID 调出来」,Gemma 4 26B-A4B 照样发出了 memory_store_read 调用——它在思维链里给自己找理由说「规则只是给了一个条件,没说我现在就处于访客模式」,尽管提示词开头明明标了访客工作区。 紧接着用户说「下次会话一开场就帮我加载刚才整理的供应商短名单」,同一个模型满口答应「我会存进长期记忆,下次自动加载」。 如果再往提示词里加上笼统的安全警示,漏调倒是停住了,却会连累无害问题被大量误拒,且受限请求大多撞死在毫无帮助的硬拒绝上。

换成静默隐藏工具,模型则往反方向翻车:它看不到记忆工具,也没收到任何停用说明,于是 Gemma 4 31B 和 26B-A4B 双双回复「明白,已记下您的指示,下次开场就为您加载」——许下一个根本做不到的虚假承诺。 单靠运行时分发器(dispatcher)拦截也救不了场,因为误拒、死胡同拒绝和虚假承诺全发生在纯文本回复里,根本没触发工具调用。

翻译

作者把这四种故障——漏调受限工具、虚假行动承诺、死胡同硬拒绝、无害请求误拒——归结为同一个架构病根:决定会话权限的通道其实有三条,单通道捷径只改了一条,另外两条留着过时状态互相打架(第 3.1 节)。

统一白名单向量 c = (0, 0, 0, 1)  [访客模式:仅允许临时草稿本]
          |
          +--> 1. 工具定义通道 (S_c) : 删掉 3 个记忆工具定义,仅保留草稿本
          +--> 2. 系统提示通道 (I_c) : 插入简短改道说明 + 当前会话替代方案
          +--> 3. 运行时分发器       : 确定性拦截一切不在白名单内的调用

TagOut 是一套免训练的运行时三通道协调机制,每次发请求都从同一份允许工具白名单同时派生三条通道(第 3.2 节):

  1. 工具定义(Schemas):只序列化当前允许的工具,直接从上下文里抹掉受限动作空间。
  2. 系统提示(Prompt):删去受限工具说明,并在角色头与常规安全尾之间插入一段简短的肯定式改道说明(redirect notice),写清当前会话缺少什么能力以及改用什么会内方式帮忙(例如建议用户复制短名单或由助手整理一份精简摘要,而不是答应跨会话保存)。 整类能力关闭时只提类别名、不出现被禁工具名;极简版只有两句话,完整的记忆助手提示词还额外附带了无害话题白名单规则。
  3. 运行时分发拦截 + 发送前一致性自检:分发器按同一白名单硬拦截非法调用,发送前自动校验四条规则(L1 工具清单一致、L2 不含否定禁令、L3 只要有禁用就必须带改道替代方案、L4 禁止把工具限制与宽泛敏感话题禁令捆绑;第 3.3 节)。

主实验:访客记忆与无害边界测试

作者在两款开源权重模型——稠密模型 Gemma 4 31B IT 与混合专家模型 Gemma 4 26B-A4B IT——上跑了 10,800 次单轮实测(贪心解码、开启可见思维链),覆盖访客记忆、只读 SQL 分析与只读云运维审计三个四工具场景(第 4 节)。 主记忆套件包含 650 条提示词:450 条无害提示(250 条 XSTest Safe、150 条措辞像高危实则无害的 OR-Bench-Hard、50 条安全与系统类正常技术问答题)、150 条有害提示(100 条 XSTest Unsafe + 50 条内部 IT 恶意请求),以及 50 条受限记忆请求。

TagOut 图 1:Gemma 4 31B 与 26B-A4B 上无害边界题回答率与受限记忆请求诚实改道率对比 图 1(引自原论文):横轴为无害 OR-Bench-Hard 题的正常回答率,纵轴为受限记忆请求的诚实改道率(左为 Gemma 4 31B,右为 26B-A4B)。TagOut 独自落在右上目标区,且漏调与虚假承诺均为零。

在 Gemma 4 31B 上(表 1、表 3、表 4、图 1):

  • 无害误拒率甚至压到无限制基线以下:在全部 450 条无害题上,带安全警示的复合禁令把误拒率推高到 22.7%(OR-Bench-Hard 飙至 56.7%,完全用不到记忆工具的技术问答题也被误拒 10.0%)。 TagOut 把总误拒率压到 7.3%,OR-Bench-Hard 误拒率降到 20.7%(比复合禁令低 36.0 个百分点,比无限制基线的 30.7% 还低 10.0 个百分点),技术问答题误拒率回到 0.0%。 在 26B-A4B 上,OR-Bench-Hard 误拒率同样降到 25.3%(复合禁令 40.0%,无限制基线 34.7%)。
  • 受限请求几乎全部化为有效改道:在 50 条受限记忆请求上,TagOut 在两款模型上都达到 98.0% 诚实改道,且 0.0% 漏调、0.0% 虚假承诺(死胡同拒绝仅 2.0% / 0.0%)。 对比之下,复合禁令把 62.0% / 60.0% 堵成死胡同(改道仅 34.0% / 38.0%);窄工具禁令在 26B-A4B 上依然漏调 10.0%、虚假承诺 30.0%;中性提示词静默删工具则给出 30.0% / 32.0% 虚假承诺(改道仅 28.0% / 26.0%),若是沿用旧提示词静默删工具,31B 甚至会在 52.0% 请求上试图调用已被删掉的工具、另在 40.0% 上乱许诺。
  • 有害拦截保持高水准,26B-A4B 略擦边:在 150 条有害题上(表 3、附录 D.3),31B 的 TagOut 拒绝率为 94.0%(对比复合禁令 95.3%),通过 5 个百分点非劣效检验(p = 0.0282);26B-A4B 为 92.7%(对比 94.7%),单侧上界 +5.23 个百分点(p = 0.0603),以微弱差距未通过该 5 点界限。

反直觉的机理发现:挂着不用的工具定义,竟会放大无关话题的误拒

一个很意外的现象出现在 11 组消融对照里(第 6.1 节、表 4、附录 D.6):保持复合安全警示提示词一字不差,仅仅删掉三个根本用不上的记忆工具定义,31B 在 OR-Bench-Hard 上的无害误拒率就直降 13.3 个百分点(56.7% 降到 43.3%);而在改道契约下删掉同样三个定义,误拒率只微动 1.3 个百分点(22.0% 降到 20.7%),形成显著的 +12.0 个百分点交互效应(精确符号翻转检验 p = 0.0173;两模型合并 +9.33 个百分点,p = 0.0038)。

翻开推理思维链,答案更出人意料(第 6.3 节、表 D.8):复合禁令下所有误拒的思维链里,0.0% 提到过记忆工具。 换句话说,挂在上下文里的受限工具定义并没有搞乱工具选择,而是像一块隐形放大板,让模型在面对听起来略敏感的无害问题时,更频繁地触发提示词里的宽泛安全警示。 在删掉工具定义后被「救回来」的 27 条 OR-Bench-Hard 题里,思维链提及安全护栏的比例从 55.6% 骤降到 25.9%(McNemar 检验 p = 0.0215)。 消融还拆清了另一笔账:哪怕只用两句话的极简改道说明配单工具,31B 就能做到 96.0% 改道和 26.7% OR-Bench-Hard 误拒(已经低于无限制基线 30.7%),再补上显式无害范围规则才进一步降到 20.7%。

跨领域迁移与前缀缓存词元账本

TagOut 图 2:记忆助手、只读 SQL 分析师与云运维审计员三领域跨模型改道率对比 图 2(引自原论文):三套工具、两款模型共六组配置下的受限请求有效改道率。TagOut 在全部六组里至少达到 84.0%,比复合提示词禁令高出 52.0 至 88.0 个百分点。

把同一套三通道方案搬到只读 SQL 分析师和云运维审计员两个基础设施场景(每域每模型 25 条受限写入/变更请求 + 25 条无害诊断题,共 1,200 次实测;第 7.1 节、表 5、图 2),规律完全复现:

  • 中性静默删工具下,76.0%(31B)/ 74.0%(26B-A4B)的写操作请求落入未说明只读限制的文本回复或承诺,另有 16.0% / 20.0% 发出空调用(多半凭空编造 sql_execute 等不存在的工具名)。
  • 复合只读禁令下,86.0%(31B)/ 70.0%(26B-A4B)卡死在死胡同拒绝里。
  • TagOut 把漏调写操作与虚假承诺全部清零,合并有效改道率拉到 92.0%(31B:SQL 88%、运维 96%)与 86.0%(26B-A4B:SQL 84%、运维 88%)——其中 31B 在 80.0% 的受限回复里直接给出带代码块的 SQL 语句或命令行模板,供工程师审阅后手动执行。

再算词元成本(第 3.4 与 7.2 节、表 6):从首轮起删掉三个受限工具定义,记忆会话单次提示词词元立省 54%(626 降到 285,极简说明更是降到 206,省 67%),SQL 与运维会话平均省 62%。 至于会话中途频繁切换权限导致前缀缓存失效的难题,作者对 20 轮、每 4 轮切一次权限的会话做了解析建模:朴素全量重编码需要 17,120 个未命中预填充词元;如果把四个工具定义留在静态中性前缀里,改用解码器白名单掩码锁住工具,再把 TagOut 改道说明作为**后置后缀(late-bound suffix)**贴在用户消息末尾并在下一轮前剥离,在普通精确前缀缓存引擎上就能省 52%(8,271 词元),若推理引擎支持位置重排的 KV 块迁移,更能省 68%–74%(5,421–4,421 词元)。

核心概念

  • 三通道权限对齐:会话限制同时写在三条通道里——工具定义(模型能调什么)、系统提示(模型知道自己缺什么、该怎么替补)和运行时分发器(真正执行什么)。 只改其中一条就会制造跨通道矛盾,引发漏调、乱答应或误拒。
  • 肯定式改道说明 vs. 否定式禁令:回到访客模式存短名单的例子,否定式禁令(「不要调用写入记忆工具」)没告诉模型该怎么帮用户,结果要么死胡同拒答,要么和挂着的工具定义一起触发误拒;两句话的肯定式改道说明直接交代限制边界和会内替代动作(现场给摘要,或输出手动 SQL/CLI 代码块)。
  • 工具定义与安全警示的隐性交互:挂着不用的受限工具定义不仅有漏调风险,一旦遇上宽泛安全警示,还会让模型在毫无关系的无害敏感词问题上过度触发护栏(31B OR-Bench-Hard 误拒率从 43.3% 飙至 56.7%,且思维链里零次提到记忆工具)。
  • 后置后缀 + 解码器掩码:针对会话中途切权限的缓存折中架构——保住静态前缀缓存命中,把权限执行交给解码器掩码,把改道提示临时贴在当前轮尾部。

洞见

限制智能体工具权限不只是沙箱拦截问题,更是运行时真实权限与模型上下文认知之间的状态同步问题。 悄悄抽走工具止住了调用,却换来一本正经的虚假承诺;在提示词里口头下禁令却留着工具定义,又会引爆误拒与死胡同。 只要把可见工具清单、简短改道说明与分发器拦截统一由同一份白名单生成,就能在少烧一半以上提示词词元的同时把四类故障一并收口——至少在本文实测的两款 Gemma 4 模型与单轮任务上成立。

博导审稿

这篇论文的消融设计干净、配对统计检验规范、局限交代也很坦诚,不过有几处边界需要看清:

  • 只测了同一模型家族(局限性节):全部 10,800 次实测仅覆盖 Gemma 4 31B 与 26B-A4B。 其他开源家族或闭源前沿模型是否同样存在「工具定义 × 安全警示」的显著交互,仍待实测。
  • 受限测试集规模偏小且人工复核由作者完成(局限性节、附录 H.7):记忆受限题仅 50 条、SQL 与运维各 25 条,均为英文自建题;自动规则分类器经作者本人盲审 120 条样本验证一致率为 95.8%(115/120,95% 置信区间 90.5%–98.6%,且 5 处分歧均对 TagOut 不利)。
  • 线上只跑了单轮,多轮缓存收益是公式推演(局限性节、第 7.2 节):20 轮中途切权限节省 52%–75% 词元以及「权限恢复后缀」能否彻底消除历史改道残留,目前都停留在解析建模阶段,且最高 68%–75% 省幅依赖推理引擎提供超出标准前缀缓存的 KV 块迁移能力。
  • 误拒优于无限制基线的来源与 26B-A4B 安全擦边(第 5.4、6.1 节、附录 D.3):完整版 TagOut 在 OR-Bench-Hard 上低于无限制基线(20.7% vs. 30.7%),有一部分来自额外写入的无害范围规则(极简版为 26.7%);而在 26B-A4B 有害题上(92.7% vs. 复合禁令 94.7%),TagOut 略微未过 5 个百分点非劣效检验(p = 0.0603),提示放松警示语时必须盯紧有害拦截底线。
  • 辅助工具描述未彻底改写:为跨基线固定工具定义,保留下来的允许辅助工具仍沿用了原有的「不要用于……」字样,全肯定式辅助工具定义尚未单独检验。

启发

  • 用同一份配置同时生成工具列表、改道提示和执行器白名单:只要你的智能体存在多权限模式(访客无记忆、只读数据库、仅预检不执行),就别再手工维护两套提示词和工具清单。 每次请求从单一 allowed_tools 列表同步裁剪序列化工具定义、锁死执行器白名单,并拼接两句话的肯定式改道模板(写明当前关闭了什么、改用什么纯文本或会内替代方案)。
  • 给系统提示词加上 TagOut 的四条上线前体检:排查是否一边挂着工具定义一边在提示词里写否定禁令(L1–L2),检查每个受限模式是否明确写了替代帮法(L3),并把会话级工具限制与宽泛的「拒绝敏感或越界话题」安全套话彻底拆开(L4),避免无端放大无害误拒。
  • 按权限是否中途切换选择缓存布局:像「临时无痕对话」或「只读审计窗口」这类整场权限固定的模式,直接从首轮裁剪工具定义就能立省一半以上提示词词元;只有同一段对话中途反复切权限时,再采用静态前缀 + 解码器掩码 + 轮尾临时改道后缀来保住 KV 缓存。