Appearance
自定义 Anthropic 兼容 Provider 的 cacheRetention: long 静默回退到 5 分钟缓存
问题
使用第三方 Anthropic 兼容 API 代理(如 ZenMux)配合 api: "anthropic-messages" 时,配置 cacheRetention: "long" 应在 cache_control payload 中注入 ttl: "1h",但实际上静默回退到默认 5 分钟缓存。
根本原因:1 小时缓存 TTL 支持被硬编码仅限于官方 Anthropic provider,使用相同 anthropic-messages API 的自定义兼容 provider 被排除在外。
解决方案
该功能已在后续版本中修复:将 cacheRetention: "long" 的判断从"仅限官方 Anthropic provider"扩展为"所有使用 anthropic-messages API 的 provider"。
临时缓解措施(等待升级时):
方案 A - 改为使用 Anthropic 官方 provider:如果代理支持完全透传,直接将模型路由到官方 Anthropic endpoint 可绕过此限制。
方案 B - 显式指定 TTL 参数:在 agent 配置中通过 cacheTtl: "1h" 强制设置(如 provider 配置支持此字段)。
方案 C - 关闭长缓存,改用短缓存:将 cacheRetention 设为 "short"(5 分钟),至少能获得有效的缓存结果,避免完全不缓存:
json5
{
agents: {
defaults: {
cacheRetention: "short",
},
},
}