claude-thermos 是一个轻量级代理,能在子 Agent 长时间运行时自动保持 Claude Code 的提示缓存活跃,避免因缓存过期导致的高昂重写成本——这通常占总费用的约 20%。

Stars

155

7 天增长

暂无数据

Fork 数

7

开放 Issue

1

开源协议

MIT

最近更新

2026-07-24

为什么值得关注

它精准解决了 Claude Code 中一个昂贵但鲜有文档的问题:当主 Agent 被子 Agent 阻塞时提示缓存过期。经测量可节省约 22% 的输入费用,且设置极为简单。

适合谁使用

  • 频繁使用子 Agent 的 Claude Code 高级用户
  • 运行长时间自动化多工具流程的工程师
  • 希望降低 Agent 工作流中 Anthropic API 支出的团队
  • 已使用 `claude` CLI 并熟悉 `uvx` 的开发者

典型使用场景

  • 当主 Agent 等待子 Agent 超过 5 分钟时防止缓存重写
  • 降低长时间、多步骤编码会话的月度 API 账单
  • 在涉及多个子 Agent 的复杂任务中保持快速响应
  • 无需手动管理缓存即可无人值守运行 Claude Code 工作流

项目优势

  • 即插即用:仅需将 `claude` 替换为 `uvx claude-thermos`
  • 在 185 次会话中实测节省约 22% 的缓存重写费用
  • 自动后台保温,基本使用无需任何配置
  • 提供透明的事件日志和每次会话的节约摘要以验证效果

使用前须知

  • 需要 Python 3.11+ 以及 `claude` CLI 在 PATH 中
  • 仅适用于官方 Claude Code CLI(不支持通用 Anthropic API 调用)
  • 保温操作引入少量代理开销并消耗缓存读取 token(但节约远大于此)

README 快速开始

claude-thermos

Stop paying to rebuild your Claude Code cache. When your main agent waits on a subagent for more than 5 minutes, its prompt cache silently expires, and the next turn re-encodes your entire conversation at the write rate instead of reading it back cheap. On long sessions with many subagents that's roughly 20% of your bill. claude-thermos keeps the cache warm so you never pay that tax.

Use

Run Claude Code exactly as you normally would, but through claude-thermos with uvx:

uvx claude-thermos                     # instead of: claude
uvx claude-thermos -p "fix the bug"    # any claude args pass straight through

Requires Python 3.11+ and the claude CLI on your PATH.

That's it. Warming runs automatically in the background. To disable it for a run without changing the command, set CLAUDE_WARMER_DISABLE=1.

Tuning (all optional):

FlagDefaultMeaning
--idle270Seconds the main agent must be idle before warming kicks in
--interval270Seconds between warming cycles
--max-cycles4Max warms per idle episode (auto for unlimited)
--subagent-window540Seconds a subagent counts as "still active"

Why your cache keeps expiring

Claude Code's prompt cache uses a 5-minute TTL. Every turn, your whole conversation history is served from cache at 0.1x the input price instead of being re-sent at full price, as long as the cache stays alive.

The cache expires if more than 5 minutes pass between requests on the same prefix. The dominant trigger for that gap is not you thinking. It's the main agent blocked on a subagent that runs longer than 5 minutes. A subagent has a different system prompt and tool set, so its requests have a different cache prefix and never refresh the main agent's. While the subagent works, the main agent's cached history ages untouched; past 5 minutes it's gone. When the subagent returns, the main agent resumes with a byte-identical, append-only history, and finds its cache missing, forcing a full re-encode at the 1.25x write rate.

By then the history is large, so the re-encode

项目描述

Keeps your Claude session warm for you

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

mereyabdenbekuly-ctrl
精选
mereyabdenbekuly-ctrl GitHub avatar

clodex-ide

Clodex is an open-source, local-first agentic IDE that combines persistent AI tasks, code, terminal, browser, Git, models, memory, and governed execution in one Electron workspace, currently in technical preview.

AI 与机器学习AI 智能体
833
lopopolo
精选
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI 与机器学习AI 智能体
2,320
NousResearch
精选
NousResearch GitHub avatar

hermes-agent

Hermes Agent is an open-source, self-improving AI agent with a built-in learning loop that creates skills from experience, runs across platforms, and supports any LLM provider.

AI 与机器学习
215,644