When should DeepSeek Flash compact?DeepSeek Flash 该在什么时候压缩?

Codex compacts on its own once a conversation reaches the token limit you choose. Here is what that choice costs, based on 26 real sessions.对话达到你设定的 token 上限时,Codex 会自动压缩。这个选择要花多少钱,下面用 26 个真实会话来回答。

Pick a threshold选一个阈值

Each card is the cheapest trigger that keeps compaction within a share of your working time. They change when you move the speed slider under the chart.每张卡片是在压缩时间不超过你工作时间某个比例的前提下,最省钱的触发点。拖动图表下方的速度滑块,它们会跟着变。

Cost and waiting at every trigger每个触发点的费用和等待

Blue is what one million billed tokens of your usage costs at each trigger. Orange is the share of working time spent compacting. Hover or tap the chart to read any trigger. The shaded bands show the likely range.蓝线是在各个触发点下,用量里每一百万个计费 token 的花费。橙线是用在压缩上的工作时间占比。把鼠标移到图上或点一下,就能读出任意触发点的数值。浅色带是可能的范围。

Compaction time is mostly the model writing its summary. If your server is faster or slower than the measured 168 tokens per second, move the slider. Cost does not change.压缩耗时主要花在模型写摘要上。如果你的服务比实测的每秒 168 个 token 更快或更慢,就拖动滑块。费用不会变。

Costs use DeepSeek Flash prices per million tokens: input $0.15, cache hit $0.003, output $0.60.费用按 DeepSeek Flash 的价格计算(每百万 token:输入 $0.15,缓存命中 $0.003,输出 $0.60)。

Cost is per 1M tokens billed with the mix seen in these sessions: 98.5% cache reads, 0.0% cache writes (1 hour), 0.0% cache writes (5 minutes), 1.2% plain input, 0.3% output.费用按每 100 万个计费 token 计算,构成与这些会话一致:缓存读取 98.5%、缓存写入(1 小时)0.0%、缓存写入(5 分钟)0.0%、普通输入 1.2%、输出 0.3%。

How to read it怎么看这张图

Where this can mislead you哪些地方可能误导你

How the numbers were made这些数字是怎么算出来的

In short: we replayed real sessions at every trigger and added up what they would have cost and how long compaction would have taken.简单说:我们用真实使用记录在每个触发点上重放一遍,把费用和压缩耗时加起来。

  1. Real requests真实请求Request by request, from real DeepSeek Flash sessions in Codex: the context size, the cached share and the output of each one.逐个请求分析 Codex 里真实的 DeepSeek Flash 会话:每个请求的上下文大小、缓存命中比例和输出量。
  2. Measured compactions实测压缩Compaction is timed on real runs: the input size, the cached prefix, the summary written and the seconds taken. Part of the runs trim a real session's context down to a smaller size first.压缩耗时来自真实运行:输入大小、缓存前缀、写出的摘要和花掉的秒数。其中一部分运行是先把真实会话的上下文裁剪到较小的规模。
  3. More workloads扩充工作负载Each session's request-to-request changes are cut into blocks of 8 requests and reshuffled with a fixed random seed. That gives 100 extra workloads that behave like the real one.把每个会话里相邻请求的变化切成每 8 个请求一块,用固定的随机种子重新洗牌,得到 100 组行为和真实记录相似的工作负载。
  4. Replay and average重放并取平均Every workload is replayed at every trigger. We average the cost and the compaction time over all 100 workloads. The final curves are not smoothed.每组工作负载在每个触发点上各重放一遍,再对 100 组的费用和压缩耗时取平均。最终曲线没有做平滑。

Data volume数据量

26 independent work sessions, plus the latest stretch of the analysis session after its last compaction, 2,933 deduplicated requests and about 7.0 hours of work. 9 measured compactions calibrate the model. Smoke tests, test sessions and the sessions used to time compaction are left out. Where Codex compacted a session for real, the compaction request is dropped and the stretches before and after are joined into one uncompacted stream, so the replay decides where compactions happen.26 个独立工作会话,外加分析会话最后一次压缩之后的那一段,共 2,933 个去重请求,约 7.0 小时的工作。9 次实测压缩用来校准模型。冒烟测试、测试会话和用来测压缩耗时的会话都没有计入。会话里 Codex 真实压缩过的地方,压缩请求本身被去掉,前后两段接成一条没有压缩的请求流,由重放来决定在哪里压缩。

Cost per 1M tokens每 100 万 token 的费用

The chart does not show the total bill of the sessions, because that would grow with the amount of history. Every cost is the replay cost at that trigger divided by the billed tokens of the real history (620 million), times one million. The divisor is one fixed number per model, not the token count of each replay. The reference million therefore has the real billing mix: 98.5% cache reads, 0.0% cache writes (1 hour), 0.0% cache writes (5 minutes), 1.2% plain input and 0.3% output. Costs are comparable between models and between amounts of history.图上不是这些会话的总账单,因为总账单会随历史数据的多少而变。每个费用都是该触发点下重放得到的总费用,除以真实历史的计费 token 数(620 百万),再乘以一百万。除数是每个模型固定的一个数,不是每次重放的 token 数。所以这一百万 token 的构成与真实计费一致:缓存读取 98.5%、缓存写入(1 小时)0.0%、缓存写入(5 分钟)0.0%、普通输入 1.2%、输出 0.3%。这样不同模型、不同数据量之间的费用可以直接比较。

Formula and symbols公式和符号

The cost of one request comes first. Then ordinary requests and compactions are added up over the whole workload.先算一次请求的费用,再把普通请求和压缩在整个工作负载上加起来。

Cost of one request Q(x, c, y) = p_m · [(1-c) + αc] · x + p_o · y Price ratios α = p_c / p_m ρ = p_o / p_m B = (1-β) + αβ Total cost J(T) = Σ Q(ordinary requests) + Σ Q(compaction input and summary output) Time of one compaction t_c = a · (C - K) + G / v Time share N_c(T) · t_c(T) / [W + N_c(T) · t_c(T)] Steady-state approximation T* ≈ R + √( 2Δ · (BR + ρG) / α )单次请求费用 Q(x, c, y) = p_m · [(1-c) + αc] · x + p_o · y 价格比例 α = p_c / p_m ρ = p_o / p_m B = (1-β) + αβ 总费用 J(T) = Σ Q(普通请求) + Σ Q(压缩输入与摘要输出) 单次压缩耗时 t_c = a · (C - K) + G / v 时间占比 N_c(T) · t_c(T) / [W + N_c(T) · t_c(T)] 稳态近似 T* ≈ R + √( 2Δ · (BR + ρG) / α )
xContext tokens in one request.一次请求里的上下文 token 数。
yOutput tokens of that request, billed at the output price.这次请求输出的 token 数,按输出价格计费。
cShare of a request's input that hits the prompt cache.请求输入中命中提示缓存的比例。
p_m / p_c / p_oPrice per token of uncached input, cached input and output.未缓存输入、缓存输入和输出的每 token 价格。
αCached input price divided by uncached input price; DeepSeek Flash: 0.02.缓存输入价格除以未缓存输入价格;DeepSeek Flash 为 0.02。
ρOutput price divided by uncached input price; DeepSeek Flash: 4.输出价格除以未缓存输入价格;DeepSeek Flash 为 4。
BEffective price of one ordinary context token, after the cache hit rate.考虑缓存命中率后,一个普通上下文 token 的有效价格。
C / KC is the compaction input in tokens. K is the part of it that comes from the cache.C 是压缩输入的 token 数,K 是其中来自缓存的部分。
T / RT is the compaction trigger; R is the context right after a compaction.T 是压缩触发点;R 是刚压缩完时的上下文大小。
ΔHow many tokens the context grows after each ordinary request, on average.每个普通请求之后,上下文平均增长多少 token。
GSummary tokens actually written, and billed, in one compaction.一次压缩实际写出并计费的摘要 token 数。
βShare of the compaction input that hits the cache.压缩输入中命中缓存的比例。
aSeconds per uncached input token, fitted on the measured compactions.每个未缓存输入 token 的处理时间,单位是秒,由实测压缩拟合。
vHow fast the summary is written, in tokens per second. The slider changes this one.摘要的生成速度,单位是 token 每秒。滑块调的就是它。
N_c / t_c / WNumber of compactions, time of one compaction, and working time without compaction.压缩次数、单次压缩耗时,以及不含压缩的工作时间。

What moves the best trigger哪些因素会挪动最佳触发点

The time model is fitted to 9 compactions: R² = 0.98. Summary size alone gives 0.95, input size alone gives 0.20. The closed-form formula explains the direction of each effect. The chart itself comes from the replay, which keeps the real order of requests, the real growth and the real moments of compaction.时间模型用 9 次压缩拟合,R² = 0.98;只用摘要大小是 0.95,只用输入大小是 0.20。闭式公式用来解释每个因素的影响方向,图上的曲线来自重放,保留了真实的请求顺序、上下文增长和压缩时点。