CACHELINT:检测 LLM Agent 中提示词缓存集成错误的静态分析工具
Silent and Costly: Characterizing and Detecting Prompt-Caching Mis-Integration in LLM Agents
研究者分析了 120 个缓存相关的 PR,发现缓存接错大多静默失败,还开源了检测工具 CACHELINT,写 Agent 项目的可以跑一下自查。
一项针对 10 个热门开源 Agent 系统中 120 个提示词缓存相关 Pull Request 的实证研究发现,缓存集成错误分为请求侧配置错误和读取侧使用计数错误两类,且大多静默失败、不产生运行时报错。研究团队据此开发了 CACHELINT,用 CodeQL 定位缓存调用点,并结合带日期的供应商能力库或 LLM 检查来验证前提条件。该工具在 120 个已标注错误上达到 0.71 精确率和 0.78 召回率,在 571 个真实 Agent 项目中发现了 32 个集成错误,精确率 0.86。相关发现获得 21 位开发者确认,促成 18 个上游修复,其中包括 Anthropic 官方 SDK 的一处修复。
Silent and Costly: Characterizing and Detecting Prompt-Caching Mis-Integration in LLM Agents
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.