让智能体学会何时行动、何时拒绝,提升多步工具调用的安全性。
Learning When to Act or Refuse: Guarding Agentic Reasoning Models for Safe Multi-Step Tool Use
- 设计可学习的拒绝对话机制,将安全决策融入计划-检查-执行流程
- 零样本测试中减少50%有害行为,对注入攻击的拒绝率提升超20%
- 适用于各类大模型和复杂场景,兼顾安全与正常任务性能
代理型语言模型在安全机制上与聊天模型有本质差异:它们需规划、调用工具并执行长程任务,单次错误(如访问文件或输入凭据)可能导致不可逆损害。现有对齐方法主要针对静态生成和任务完成,难以应对序列化决策、对抗性工具反馈及过度自信的中间推理。我们提出MOSAIC,一种后训练框架,通过显式化安全决策过程,实现代理在多步工具使用中的安全对齐。MOSAIC将推理结构化为‘计划-检查-执行或拒绝’循环,引入显式的安全推理与拒绝作为第一类动作。为避免轨迹级标签,采用基于偏好强化学习的成对轨迹比较,捕捉标量奖励常忽略的安全差异。我们在Qwen2.5-7B、Qwen3-4B-Thinking和Phi-4三个模型家族上进行零样本评估,涵盖有害任务、提示注入、良性工具使用及跨领域隐私泄露等分布外基准。结果表明,MOSAIC将有害行为减少最高50%,对注入攻击的拒绝率提升超过20%,显著降低隐私泄露,并保持或提升良性任务表现,展现出跨模型、跨领域与代理场景的鲁棒泛化能力。
原文摘要 · Abstract (English)
Agentic language models operate in a fundamentally different safety regime than chat models: they must plan, call tools, and execute long-horizon actions where a single misstep, such as accessing files or entering credentials, can cause irreversible harm. Existing alignment methods, largely optimized for static generation and task completion, break down in these settings due to sequential decision-making, adversarial tool feedback, and overconfident intermediate reasoning. We introduce MOSAIC, a post-training framework that aligns agents for safe multi-step tool use by making safety decisions explicit and learnable. MOSAIC structures inference as a plan, check, then act or refuse loop, with explicit safety reasoning and refusal as first-class actions. To train without trajectory-level labels, we use preference-based reinforcement learning with pairwise trajectory comparisons, which captures safety distinctions often missed by scalar rewards. We evaluate MOSAIC zero-shot across three model families, Qwen2.5-7B, Qwen3-4B-Thinking, and Phi-4, and across out-of-distribution benchmarks spanning harmful tasks, prompt injection, benign tool use, and cross-domain privacy leakage. MOSAIC reduces harmful behavior by up to 50%, increases harmful-task refusal by over 20% on injection attacks, cuts privacy leakage, and preserves or improves benign task performance, demonstrating robust generalization across models, domains, and agentic settings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。