Claude Code 团队总结 AI 智能体提示词缓存的优化经验
Claude Code 团队总结了构建长时运行 AI 智能体时优化提示词缓存的实践,核心是保持请求前缀稳定,以降低延迟和成本。具体做法包括静态内容前置、通过消息传递更新、不在会话中途更换工具或模型,以及用 defer_loading 延迟加载工具。执行上下文压缩时,应沿用父会话的系统提示词、上下文和工具定义,使已有缓存前缀能够复用。

to most effectively structure your prompt, use tools, and layer on compaction. It is often said in engineering that "cache rules everything around me", and the same rule holds for agents. Long running agentic products like Claude Code are made feasible by prompt caching which allows us to reuse computation from previous roundtrips and significantly decrease latency and cost. At Claude Code, we build our entire harness around prompt caching. A high prompt cache hit rate decreases costs and helps
匹配字段正文



