宝玉· @dotey · X·· 3 小时前AI 评分48
AI 导读
在 Claude Code 中运行 /autocompact 300k 可把自动压缩触发阈值从 1M 模型默认的约 967K Token 提前到 300K。自动压缩会把整段长对话替换为简短摘要,而非保留上百万 Token 的完整历史;由于每条消息都携带此前全部对话,等到 967K 才压缩会让后期每次交互重复消耗大量 Token,即使多为廉价的缓存读取也仍计入使用额度。
正文 · 原文
如果你在用 Claude Code 的话,再推荐下记得运行下 /autocompact 300k
(原推是400k,我自己用下来300k就足够了,当然选哪个你可以自己决定)
自动压缩(Auto-compact)的作用是将整段长对话精简为简短的摘要,而不是一直保留上百万的完整历史记录。在 1M 上下文模型中,系统默认要到约 967K Token 时才会触发压缩。
由于你发送的每一条消息都会带上之前的全部对话历史,等到 967K 再压缩,意味着后期的每一次交互都在重复消耗海量 Token。虽然在缓存有效(warm cache)的情况下,大部分历史内容走的都是廉价的缓存读取,且压缩本身也只相当于一次普通请求,但这些庞大的读取量依然会实打实地计入你的使用额度,积少成多。
使用 /autocompact 300k 可以将触发压缩的阈值提前到 300K。这样既能让对话历史始终保持精简,又能避免单次请求的上下文无限膨胀,从而大幅节省长对话的 Token 消耗。
Just to avoid some confusion: auto-compact does summarize. When it runs, your whole conversation is replaced by a short summary. It doesn't keep the last 1M tokens around. The ~967K is only when it runs on 1M models. Compacting itself is just one request that reads about as many tokens as the message you sent right before it, and it's mostly cache reads if your cache is still warm. What @rohit3a found is that waiting until 967K means every message before that point uses a lot of tokens, because each one includes your whole conversation so far. Most of it is read from the cache, which is much cheaper (so this is usually fine as long as your cache is warm), but it still counts toward your usage and adds up as your conversation grows. /autocompact 400k makes it summarize at 400K instead, so your messages never get that big.在 X 查看被引用的帖子
来源:宝玉 · x.com