Silent and Costly: Characterizing and Detecting Prompt-Caching Mis-Integration in LLM Agents
作者: Ying Zhang, Ruoqi Guo, Yi Liu, Gelei Deng, Yuekang Li, Yepang Liu, Leo Zhang
分类: cs.SE, cs.AI
发布日期: 2026-10-26
备注: Accepted at ICSE 2027
💡 一句话要点
提出CACHELINT以解决LLM代理中的提示缓存误集成问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 提示缓存 大型语言模型 误集成检测 CodeQL LLM 软件工程 开源系统
📋 核心要点
- 现有的提示缓存集成方法面临异构API和不断变化的缓存语义,导致误集成现象普遍且难以察觉。
- 本文提出CACHELINT,通过建模提示缓存误集成并验证其前提条件,提供了一种有效的检测方法。
- 实验结果显示CACHELINT在多个代理系统中识别误集成的精度和召回率均表现良好,具有实际应用价值。
📝 摘要(中文)
大型语言模型(LLM)服务处理大量用户请求,导致显著的推理成本。为了降低成本和延迟,提供商引入了提示缓存。然而,由于异构的提供商特定API和不断演变的缓存语义,正确集成提示缓存并非易事。本文首次对10个流行开源代理系统中的120个与提示缓存相关的拉取请求进行了实证研究,发现提示缓存误集成主要源于请求端配置错误和读取端使用计数错误。更重要的是,大多数误集成在运行时未引发可观察的失败。基于这些发现,本文设计了CACHELINT,将提示缓存误集成建模为调用站点及其正确集成所需的前提条件。CACHELINT通过CodeQL定位缓存调用站点,并通过过时的提供商能力oracle或LLM保护检查来验证每个前提条件。CACHELINT在识别120个标记的误集成方面实现了0.71的精度和0.78的召回率,并在571个代理项目中识别出32个误集成,精度达到0.86。这些发现得到了21位开发者的确认,并促成了18个上游修复,包括Anthropic官方SDK中的一个修复。
🔬 方法详解
问题定义:本文旨在解决大型语言模型代理中的提示缓存误集成问题。现有方法在处理异构API和动态缓存语义时,容易导致配置错误和使用计数错误,且这些错误往往不会引发明显的运行时失败。
核心思路:CACHELINT通过将提示缓存误集成视为调用站点及其正确集成的前提条件,提供了一种系统化的检测方式。通过这种建模,能够有效识别和定位潜在的误集成问题。
技术框架:CACHELINT的整体架构包括三个主要模块:首先,使用CodeQL定位缓存调用站点;其次,针对每个调用站点验证其前提条件;最后,利用过时的提供商能力oracle或LLM保护检查来确保集成的正确性。
关键创新:CACHELINT的主要创新在于其将提示缓存误集成建模为调用站点的方式,这一方法与传统的静态分析方法有本质区别,能够更准确地捕捉到动态环境中的错误。
关键设计:在设计上,CACHELINT采用了CodeQL进行代码分析,并结合了LLM的能力进行前提条件的验证,确保了高效性和准确性。
🖼️ 关键图片
📊 实验亮点
CACHELINT在识别120个标记的提示缓存误集成中实现了0.71的精度和0.78的召回率,进一步在571个代理项目中识别出32个误集成,精度达到0.86。这些结果表明CACHELINT在实际应用中具有较高的有效性,得到了21位开发者的确认,并促成了18个上游修复。
🎯 应用场景
该研究的潜在应用领域包括大型语言模型服务的开发和维护,尤其是在需要高效处理用户请求的场景。通过有效检测和修复提示缓存误集成问题,能够显著降低推理成本和提高系统的稳定性,具有重要的实际价值和广泛的应用前景。
📄 摘要(原文)
Large language model (LLM) services process massive volumes of user requests, resulting in substantial inference costs. To reduce both cost and latency, providers have introduced prompt caching. However, correctly integrating prompt caching is non-trivial due to heterogeneous provider-specific APIs and continuously evolving caching semantics. To understand prompt-caching mis-integration in downstream applications, we conduct the first empirical study of 120 prompt-caching-related pull requests from 10 popular open-source agent systems. Our findings show that prompt-caching mis-integrations arise in both request-side misconfiguration and read-side usage miscount. More importantly, most mis-integrations fail silently without causing observable runtime failures. Motivated by these findings, we design CACHELINT, which models a prompt-caching mis-integration as an invocation site together with the preconditions required for correct cache integration. CACHELINT locates caching invocation sites with CodeQL and discharges each precondition either against a dated provider capability oracle or with an LLM guard check. CACHELINT achieves 0.71 precision and 0.78 recall in identifying the 120 labeled mis-integrations across the 10 studied agent systems. Our evaluation further demonstrates the effectiveness of CACHELINT in real-world settings, identifying 32 mis-integrations across 571 agent projects with 0.86 precision. These findings have received 21 developer confirmations and led to 18 upstream fixes, including one in Anthropic's official SDK.