Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks
作者: Elias Lumer, Faheem Nizar, Akshaya Jangiti, Kevin Frank, Anmol Gulati, Mandar Phadate, Vamse Kumar Subbiah
分类: cs.CL
发布日期: 2026-01-09
备注: 15 pages, 8 figures
💡 一句话要点
针对长程Agent任务,评估Prompt缓存以降低成本并提升效率
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: Prompt缓存 LLM Agent 长程任务 API成本 首个Token生成时间 缓存策略 DeepResearchBench
📋 核心要点
- 现有LLM Agent在长程任务中面临高昂的API成本和延迟,主要由于频繁的工具调用和不断增长的上下文窗口。
- 本文提出通过Prompt缓存来减少冗余计算,并探索不同的缓存策略,以优化成本和延迟。
- 实验结果表明,Prompt缓存能显著降低API成本(45-80%)并提升首个token生成时间(13-31%)。
📝 摘要(中文)
本文针对大型语言模型(LLM)Agent在复杂多轮任务中,因频繁工具调用和庞大上下文窗口导致的高成本和高延迟问题,深入评估了Prompt缓存的有效性。研究对比了OpenAI、Anthropic和Google三大LLM提供商的三种缓存策略:完整上下文缓存、仅系统Prompt缓存以及排除动态工具结果的缓存。在DeepResearchBench基准测试中,通过500多个Agent会话和包含10000 token系统Prompt的实验,评估了API成本和首个token生成时间(TTFT)。结果表明,Prompt缓存可降低45-80%的API成本,并将TTFT提升13-31%。策略性地控制Prompt缓存块,例如将动态内容置于系统Prompt末尾、避免动态函数调用以及排除动态工具结果,比简单的完整上下文缓存更有效,后者甚至可能增加延迟。分析揭示了不同提供商缓存行为的细微差异,并为在生产Agent系统中实施Prompt缓存提供了实用指导。
🔬 方法详解
问题定义:现有LLM Agent在执行长程、多轮任务时,需要频繁调用外部工具,导致上下文长度迅速增长。每次请求都需要重新处理整个上下文,造成了大量的冗余计算,增加了API成本和延迟。现有的Prompt缓存机制在Agent任务中的效果未被充分研究,简单的全上下文缓存可能无法达到最佳效果。
核心思路:本文的核心思路是利用Prompt缓存来避免重复计算,从而降低API成本和延迟。通过分析Agent任务的特点,提出了更精细化的缓存策略,例如仅缓存系统Prompt或排除动态工具结果,以提高缓存命中率和效率。
技术框架:本文采用实验评估的方法,在DeepResearchBench基准测试上,对比了三种缓存策略:完整上下文缓存、仅系统Prompt缓存以及排除动态工具结果的缓存。针对OpenAI、Anthropic和Google三大LLM提供商进行了测试,评估指标包括API成本和首个token生成时间(TTFT)。
关键创新:本文的关键创新在于提出了针对Agent任务的精细化Prompt缓存策略。与简单的全上下文缓存相比,这些策略能够更好地适应Agent任务中动态变化的部分,提高缓存命中率,并避免因缓存过多动态内容而导致的性能下降。
关键设计:本文的关键设计包括:1) 区分系统Prompt和用户输入,并分别进行缓存;2) 识别并排除动态工具结果,避免缓存无效信息;3) 分析不同LLM提供商的缓存行为差异,并提供针对性的优化建议。实验中,使用了包含10000 token的系统Prompt,并进行了超过500个Agent会话的测试。
📊 实验亮点
实验结果表明,Prompt缓存能够显著降低API成本(45-80%)并提升首个token生成时间(13-31%)。与简单的全上下文缓存相比,策略性地控制Prompt缓存块,例如排除动态工具结果,能够获得更稳定的性能提升。研究还揭示了不同LLM提供商在缓存行为上的差异。
🎯 应用场景
该研究成果可广泛应用于各种需要LLM Agent进行长程推理和工具调用的场景,例如智能客服、自动化研究、内容创作等。通过有效利用Prompt缓存,可以显著降低部署和运行LLM Agent的成本,提高响应速度,从而加速LLM Agent在实际应用中的普及。
📄 摘要(原文)
Recent advancements in Large Language Model (LLM) agents have enabled complex multi-turn agentic tasks requiring extensive tool calling, where conversations can span dozens of API calls with increasingly large context windows. However, although major LLM providers offer prompt caching to reduce cost and latency, its benefits for agentic workloads remain underexplored in the research literature. To our knowledge, no prior work quantifies these cost savings or compares caching strategies for multi-turn agentic tasks. We present a comprehensive evaluation of prompt caching across three major LLM providers (OpenAI, Anthropic, and Google) and compare three caching strategies, including full context caching, system prompt only caching, and caching that excludes dynamic tool results. We evaluate on DeepResearchBench, a multi-turn agentic benchmark where agents autonomously execute real-world web search tool calls to answer complex research questions, measuring both API cost and time to first token (TTFT) across over 500 agent sessions with 10,000-token system prompts. Our results demonstrate that prompt caching reduces API costs by 45-80% and improves time to first token by 13-31% across providers. We find that strategic prompt cache block control, such as placing dynamic content at the end of the system prompt, avoiding dynamic traditional function calling, and excluding dynamic tool results, provides more consistent benefits than naive full-context caching, which can paradoxically increase latency. Our analysis reveals nuanced variations in caching behavior across providers, and we provide practical guidance for implementing prompt caching in production agentic systems.