LectureRechercheRadarCadre d'investissement
Connexion / Inscription
← Retour à la lecture
SujetRédaction DisconfirmAIMis à jour 2026-11-19 13:32

Agent前缀缓存失效

6 étapes1 pièces8 Sources

在长程Agent工作负载中,前缀缓存失效已成为影响推理效率与稳定性的核心瓶颈。由于Agent每轮交互需重发完整上下文,任何对Prompt前缀(如系统提示、工具定义)的微调都会导致缓存从首个差异Token起全部失效,迫使引擎重新计算整个历史序列。

近期工程实践与研究揭示了该问题的多重面向:

  1. 架构脆弱性:Ollama与Together AI指出,Harness端动态加载工具或变更Reasoning参数极易破坏缓存前缀;而服务端若无法保证请求路由至同一GPU,缓存亦会丢失。
  2. 亚稳态故障:多项研究(如NTU、Iowa State大学论文)证实,短暂流量激增可引发“人口-缓存反馈”循环,导致KV池溢出、命中率骤降,即使负载恢复,服务仍可能陷入长期降级状态。
  3. 集成缺陷:实证研究发现,大量开源Agent框架存在Prompt缓存配置错误(如未正确标记Cache Control),且此类错误往往静默发生,显著推高API成本。
  4. 优化策略:针对系统提示更新导致的失效,DeepSeek提出in-history机制,通过追加而非替换旧前缀来保留缓存;另有研究建议通过限制活跃会话KV需求或采用特定恢复策略(如仅重试中断轮次)来降低能耗并避免崩溃。

【背景】Prefix Caching允许LLM复用已计算的Key-Value对,从而跳过重复Prefill阶段。但在Agent场景中,上下文的动态增长与修改使得这一优化变得极其敏感。

Comment on en est arrivé là

  1. 2026-11-17

    Ollama与Together AI联合发布博客,详细解析长程Agent会话中前缀缓存失效的常见模式(如工具延迟加载、子Agent继承)及修复路径。

    together.ai ↗
  2. 2026-11-10

    GitHub Issue #5868报告Magpie Memory因整理会话改写指令文件及不可缓存的Distill请求,导致Prompt缓存频繁未命中。

    github.com ↗
  3. 2026-11-10

    预印本论文《Bursts That Outlast Themselves》揭示vLLM/SGLang等引擎在Agent负载下因缓存压力引发的亚稳态故障,少量额外请求可导致长达一小时的吞吐量减半。

    arxiv.org ↗
  4. 2026-11-06

    预印本论文《Repeating Work Can Lower Energy per Successful Goal in LLM Agents》对比不同恢复机制下的能耗,发现保留前缀缓存虽减少86%计算量,但特定场景下重启任务反而比继续执行更节能。

    arxiv.org ↗
Connexion / Inscription
LectureRechercheRadarCadre d'investissement
  • 2026-11-06

    预印本论文《Inside the Trap: A Renewal Law for Prefix-Cache Collapse in LLM Agent Serving》建立数学模型,证明突发流量可将引擎推入零命中陷阱,且常规限流难以恢复。

    arxiv.org ↗
  • 2026-09-16

    百度智能云文章介绍DeepSeek Harness 0.1.5引入`systemPromptUpdate: 'in-history'`机制,通过追加新系统提示而非替换旧消息,解决长期运行Agent中的缓存失效问题。

    intl.cloud.baidu.com ↗
  • Ce qui reste non résolu

    • 如何在保持Agent行为灵活性的同时,标准化Harness端的Prompt结构以最小化前缀变动?
    • 现有的静态分析工具(如CacheLint)能否有效检测出所有类型的Prompt缓存误集成,特别是涉及动态上下文构建的场景?
    • 在分布式推理环境中,如何设计更鲁棒的调度算法以防止局部缓存压力演变为全局亚稳态故障?

    Sources

    • together.aiTogether AI Blog↗
    • arxiv.orgArXiv: Repeating Work Can Lower Energy↗
    • arxiv.orgArXiv: When Cache Pressure Becomes a Trap↗
    • arxiv.orgArXiv: Bursts That Outlast Themselves↗
    • arxiv.orgArXiv: Silent and Costly (CacheLint)↗
    • arxiv.orgArXiv: Inside the Trap↗
    • intl.cloud.baidu.comBaidu Cloud Article↗
    • github.comGitHub Issue Magpie #5868↗

    Couverture dans ce sujet

    • Ollama and Together AI Joint Article: Cache Invalidation in Long-Horizon Agent Sessions Almost All Stem from Violating a Single Prefix-Matching Rule2026-11-17Actualités

      Parth Sareen of Ollama and Zain Hasan of Together AI explain, from the opposing perspectives of harnesses and inference engines, why prefix caching is both critical and fragile in agent workloads, and provide specific repair paths for failure modes such as tool lazy-loading, reasoning effort changes, and sub-agent inheritance.