AgentLens: 通过机制子空间实现多轮编码代理的可解释安全引导
Agent MechSuits: Mechanistic Subspace Safety Steering for Multi-Turn CLI Agents
AI总结:
提出AgentLens框架,从内部表示层检测和缓解多轮编码代理的安全风险,通过单层10维子空间干预实现运行时安全控制,并在MAS基准上验证有效性。
摘要:
基于大型语言模型(LLM)的编码代理展现出显著的自主能力,但在与外部环境的多轮交互中也引入了重大的安全和滥用风险。现有的安全机制主要依赖外部护栏,在执行过程中进行细粒度行为控制的能力有限。同时,最近针对LLM安全的机制可解释性方法大多局限于单轮或越狱式问答设置,难以捕捉多轮代理执行中不断变化的风险动态。在本文中,我们从内部视角研究多轮编码代理的安全性。我们提出AgentLens(机制子空间干预与引导),一个白盒防御框架,对编码代理执行运行时安全检测和表示级缓解。与传统的代理护栏不同,AgentLens从步骤级隐藏表示中检测有害执行状态,并通过干预单层内的10维子空间来缓解不安全行为。为支持本研究,我们引入了机制代理安全(MAS)基准,包含使用LLaMA-3.1-8B、Qwen-2.5-7B和Gemma-2-9B在194个任务上全面标注的多轮执行轨迹。大量实验表明,AgentLens实现了强大的安全检测性能,为前瞻性风险预测提供了初步证据,并显著减少了编码代理的有害行为,为将机制可解释性应用于动态LLM代理安全奠定了基础。代码可在以下网址获取:this https URL
英文摘要:
Command-Line Interface (CLI) agents based on large language models (LLMs) demonstrate remarkable autonomous capabilities, but they also introduce significant safety and misuse risks during multi-turn interactions with external environments. Existing safety mechanisms mainly rely on external guardrails, which have a limited ability to perform fine-grained behavioral control during execution. Meanwhile, recent mechanistic interpretability methods for LLM safety are mostly confined to single-turn or jailbreak-style QA settings, limiting their ability to capture the evolving risk dynamics of multi-turn agent execution. In this paper, we investigate the safety of multi-turn CLI agents from an internal perspective. We propose Agent MechSuits (Mechanistic Subspace Intervention and Steering), a white-box defense framework that performs runtime safety detection and representation-level mitigation for CLI agents. Unlike conventional agent guardrails, Agent MechSuits detects harmful execution states from step-level hidden representations and mitigates unsafe behavior by intervening in a 10-dimensional subspace within a single layer. To support this research, we introduce the Mechanistic Agent Safety (MAS) benchmark, comprising comprehensively annotated multi-turn execution trajectories across 194 tasks using LLaMA-3.1-8B, Qwen-2.5-7B, and Gemma-2-9B. Extensive experiments show that Agent MechSuits achieves strong safety detection performance, provides preliminary evidence for lookahead risk anticipation, and substantially reduces harmful actions of the CLI agent, establishing a foundation for applying mechanistic interpretability to dynamic LLM agent safety.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。