arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.32648cs.SE
收藏

StateMirror:编码智能体中幻觉工具调用的预执行检测

StateMirror: Pre-Execution Detection of Hallucinated Tool Calls in Coding Agents

School of Software Engineering, Sun Yat-sen University(中山大学软件学院);Singapore Management University(新加坡管理大学)

Shiwen Shan, Yintong Huo, Zhiying Wu, Yuxin Su

AI总结:

StateMirror是一种轻量级预执行检测器,可在编码智能体执行前检测幻觉工具调用,其检测性能优于现有LLM评判器,能减少执行时间和token消耗,纠正多数幻觉。

摘要:

基于大语言模型(LLM)的编码智能体可能会提出在执行环境中不适用的无效操作,例如访问不存在的路径或缺失的包,我们将这种不匹配称为幻觉工具使用。对4398条智能体轨迹的初步研究显示,这类幻觉现象普遍存在且代价高昂,恢复过程平均需要额外3次交互步骤和22.4K token。现有框架依赖反应式的执行后反馈,浪费运行时资源。不过,由于智能体的执行环境基于具体的代码库和 harness 组件,许多操作前提条件可在执行前提取并验证。为此,我们提出轻量级预执行检测器 StateMirror,它在 harness 边界拦截操作,通过AST和命令分析提取状态谓词,并对照实时代码库进行确定性验证。通过在执行前精准定位环境不匹配,StateMirror可预先阻止无效操作及后续恢复循环。对2508个操作的评估显示,StateMirror在检测此类幻觉时达到0.940的精确率和0.817的F1值,其F1值比最强的LLM评判器高出35.3%,同时将中位检测延迟从17.73秒降至1.50毫秒,且无token消耗。在实际缓解方面,StateMirror的预执行反馈使智能体能够纠正超过95%的幻觉工具调用。在79个任务的实时缓解中,StateMirror在保持任务解决能力的同时,将智能体执行时间减少15.8%,token消耗减少11.8%。

英文摘要:

Large language model (LLM)-based coding agents may propose invalid actions that are not applicable in the execution environment, such as accessing non-existent paths or missing packages. We term this mismatch hallucinated tool use. A preliminary study of 4,398 agent trajectories reveals that these hallucinations are pervasive and costly, requiring a median of 3 additional interaction steps and 22.4K tokens to recover. Existing frameworks rely on reactive, post-execution feedback, wasting runtime resources. Nevertheless, since an agent's execution environment is grounded in concrete codebase and harness components, many action prerequisites can be extracted and validated prior to execution. To this end, we introduce StateMirror, a lightweight pre-execution detector. StateMirror intercepts actions at the harness boundary, extracts state predicates via AST and command analysis, and deterministically validates them against the live repository. By pinpointing exact environment mismatches before execution, StateMirror preempts invalid actions and subsequent recovery cycles. Evaluation on 2,508 actions shows StateMirror achieves 0.940 precision and 0.817 F1 in detecting such hallucinations, surpassing the strongest LLM judge by 35.3% in F1 while reducing median detection latency from 17.73 s to 1.50 ms with zero token consumption. For practical mitigation, StateMirror's pre-execution feedback enables agents to rectify over 95% of hallucinated tool calls. During live mitigation on 79 tasks, StateMirror reduces agent execution time by 15.8% and token consumption by 11.8% while maintaining task resolution.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑