claude-agent with a Claude subscription doesn't set cache.ttl, so warming pings every 4 minutes

未关闭 适合新手
#66,001 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

从 claude-agent provider 中的 priceSource() 开始,它已经会检测登录是否为订阅,并跟踪每个模型的 settings 对象如何组装,以便订阅登录时可以将 cache.ttl 设为 1h。然后检查当 cache.ttl 缺失时会回退到 4 分钟的 warming 间隔逻辑。完成状态是:在订阅登录下,每个 claude-agent 模型上的 GET /api/model 都返回 settings.cache.ttl,且 warming keep-alive 间隔为一小时。

由索引模型根据 Issue 内容生成。

描述

area/providers platform/windows type/feature version/v2
Description

With claude-agent signed in through a Claude subscription, the prompt cache lasts an hour, but none of its models have settings.cache.ttl. So warming's "auto" interval falls back to 4 minutes: about a dozen keep-alive requests an hour instead of one, each sending the full context and using up subscription quota. Background compaction is hit the same way: once a session has been idle for 5 minutes it no longer precomputes the summary, even though the cache is still there.

The workaround is adding "settings": { "cache": { "ttl": "1h" } } to every claude-agent model in the config. priceSource() in the claude-agent provider already knows when the login is a subscription, so it could set cache.ttl there.

Plugins

None

OpenCode version

2.3.2

Steps to reproduce
  1. Sign in to claude-agent with a Claude subscription
  2. Set "warming": true in the config
  3. GET /api/model: none of the claude-agent models have settings.cache.ttl
Screenshot

No response

Operating System

Windows 11

Terminal

OpenChamber desktop app

主要语言
TypeScript
星标
228k
派生
31k
平均合并
3 小时 22 分钟
30 天内合并 PR
476

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。