arXiv:2610.34817cs.SEOct 2026

Manuscript Offprint

arXiv:2610.34817

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

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Ying Zhang ∗^{*}

Wake Forest University

Winston-Salem, USA

ying.zhang@wfu.edu

Ruoqi Guo ∗^{*}

Griffith University

Gold Coast, Australia

rokie.g77@griffith.edu.au

Yi Liu §^{\S}

Griffith University

Gold Coast, Australia

yi.liu@griffith.edu.au

Yuekang Li

University of New South Wales

Sydney, Australia

yuekang.li@unsw.edu.au

Gelei Deng

Nanyang Technological University

Singapore

gelei.deng@ntu.edu.sg

Yepang Liu

Southern University of Science and Technology

Shenzhen, China

liuyp1@sustech.edu.cn

Leo Zhang

Griffith University

Gold Coast, Australia

leo.zhang@griffith.edu.au

Abstract—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.

Index Terms—Large Language Models (LLMs), Prompt Caching, Static Analysis, LLM Agents.

I. INTRODUCTION

Large language model (LLM) services process billions of requests from end users every day, incurring considerable inference costs [1]. Prior work [2] shows that a substantial fraction of prompts are identical, such as system prompts and few-shot examples used in multi-turn conversations. When such prompts are decomposed into multiple requests to LLM services, the same prefix is repeatedly sent across requests. Consequently, LLMs repeatedly reprocess these identical prompt portions, leading to redundant computation and substantial token costs. By mid-2025, enterprise-level LLM API costs were estimated to have reached $8.4 billion [3].

To address this inefficiency, LLM providers have introduced prompt caching [4]–[6], which reduces redundant computation over identical prompt prefixes by reusing previously computed intermediate results. Specifically, user prompts are cached based on their token prefixes; a cache hit occurs when the incoming request shares an exact token-prefix match with a previously cached prompt, starting from the first token (i.e., byte-for-byte equality). In this case, the cached computation is reused instead of recomputing the prefix. Otherwise, a cache miss occurs, and the prompt is processed normally while its prefix may be inserted into the cache for future reuse. Any modification, insertion, or reordering invalidates the match from that point onward [4], [7].

However, correctly integrating prompt caching is non-trivial because provider-specific configuration settings vary and the underlying mechanisms evolve. For example, Anthropic [4] and Amazon Bedrock [8] require applications to explicitly opt into caching and enforce limits on the number of cache entries per request, whereas OpenAI and Gemini apply caching automatically [5], [6]. Different providers adopt different caching enablement settings. Moreover, providers' prompt caching semantics can evolve over time. For instance, Bedrock introduced an opt-in one-hour cache lifetime tied to specific models [9], while Anthropic later reduced the default cache duration from one hour to five minutes, which significantly affected hit rates in unchanged deployments [10].

Existing studies have investigated prompt defects and prompt caching performance, but have overlooked the integration issues of prompt caching from the application side. For instance, several existing studies [11]–[13] investigate software defects that degrade the performance and reliability of LLM-integrated systems, including inference engines or agent orchestration frameworks. They do not consider prompt caching a distinct source of integration defects. Later, Tian et al. [14] identified prompt caching as a literature-derived subtype of performance and efficiency defects in a prompt

  • Equal contribution to this work.

§ Corresponding author.

Figure

Fig. 1. The overview of our work.

defect taxonomy, while Lumer et al. [15] evaluated prompt caching strategies for reducing latency and API cost. Neither of these studies investigates prompt cache misses caused by application-level integration.

In this paper, we conduct the first empirical study of prompt-caching mis-integration in open-source agent frameworks, analyzing application code that violates provider requirements for enabling, configuring, or accounting for prompt caching. As described in Fig. 1, we identify 581 repositories through GitHub search and select the 10 most popular open-source agent applications for analysis. We then collect 148,947 merged pull requests (PRs) from these repositories and analyze their prompt-caching-related code. After inspection, we obtain 120 such defects. Our study explores the following research questions (RQs):

• RQ1 (Defect Type and Root Cause): What are the common types of prompt caching defects in open-source agents, and what are their root causes?

• RQ2 (Defect Symptom): What are the common symptoms of prompt caching integration defects in open-source agents?

• RQ3 (Defect Fix): How do agent developers fix prompt caching integration defects in practice, and what are the common patterns?

Our study uncovers three key findings. First, prompt caching integration defects are concentrated on the request side. Of the 120 defects, 97 corrupt outgoing requests, while the remaining 23 preserve requests but misparse cache-usage metrics. Interestingly, we find that the heterogeneous provider-specific caching mechanisms account for 47 request-side defects, while inconsistent application-side specification of prompt prefixes (e.g., system prompts) is another major cause of cache misses. Second, prompt-caching mis-integration is often silent. In 108 mis-integration cases, defects produce no errors because the model recomputes outputs without using cached tokens. The resulting cache misses manifest only as increased cost and latency in usage metrics. Third, the mis-integration fixes are typically small and localized to request-construction code. These findings suggest that prompt-caching mis-integrations often preserve functional outputs and evade dynamic test oracles, making static analysis a well-suited detection approach.

In this paper, we develop CACHELINT, a static analysis technique for detecting prompt-caching mis-integrations in agent applications. As shown in Fig. 1, CACHELINT pairs each prompt-caching invocation site with its required preconditions, derived from the fixing patterns of our empirical study. Given an agent application codebase, CACHELINT uses CodeQL [16] to identify prompt-caching API invocation sites and extract their surrounding code context. It then checks each associated precondition by either comparing provider-capability preconditions against a dated capability oracle or prompting an LLM (gpt-5.4-mini) with the invocation-site context to assess prefix-stability and accounting preconditions. When a precondition check fails, CACHELINT reports the corresponding invocation site and suggests a fix.

We evaluate CACHELINT on the 10 studied projects, using 120 fixed defects as ground truth. CACHELINT reports 132 warnings, of which 94 are true positives, achieving a precision of 0.71 and a recall of 0.78. To assess its generalizability, we further evaluate CACHELINT on 571 real-world agent repositories, where it achieves a precision of 0.86 and uncovers 32 previously unknown prompt-caching mis-integrations. At the time of reporting, maintainers had confirmed 21 reports and fixed 18 defects. These results demonstrate the practical value of our empirical findings and CACHELINT.

In summary, we make the following contributions:

• We present the first empirical study of prompt-caching mis-integrations, characterizing their causes, symptoms, and fixes. We release our dataset to support future research [17].

• We propose a prompt-caching integration model that captures common mis-integration patterns and generalizes developer practices for automated detection and repair.

• We develop CACHELINT, a static analysis-based detector for identifying prompt-caching mis-integrations. CACHELINT achieves 0.71 precision and 0.78 recall on the 120 labeled mis-integrations. Furthermore, on 571 real-world agent applications, CACHELINT uncovers 32 previously unknown defects at 0.86 precision, resulting in 21 maintainer-confirmed reports and 18 fixes.

References (40)