llmbuffer 是 Python conversation history buffer,核心是把消息顺序调整为可稳定命中 provider prompt cache 的结构:static system prompt、long-lived history、dynamic context、recent messages。RAG 结果、时间戳和当前工具调用等易变内容被放在末尾,避免破坏前缀缓存;long-lived history 超预算时可用 compaction hook 处理。README 的 15 turn Anthropic 定价模拟里,llmbuffer cache hit ratio 为 85.3%,naive 为 66.1%,输入成本从 0.028 美元降到 0.016 美元,约低 43%。它把“上下文管理”从截断策略扩展成缓存经济学问题。
–浏览
评论 · Comments