Skip to content

[Feature] #118

@wnfilm

Description

@wnfilm

想要什么功能 / What feature?

想反馈一个 quota / usage 消耗异常的问题,麻烦作者帮忙看一下。

我这边不确定根因在哪里,但从运维观察来看感觉不太正常:我们现在有 10 个 Windsurf Trial 账号,正常理解不应该这么快就接近限流或额度低水位。

目前看到几个现象:

  1. 账号池状态正常

10 个 active Trial 账号
账号 error: 0
blockedModels: 0

Dashboard 里看到的剩余额度大概是:

daily remaining: 57% - 72%
weekly remaining: 77% - 85%

  1. 最近 4 小时请求量和 usage 统计

usage_lines: 1085
fresh_input: 1,039,666
output: 1,112,100
cache_read: 12,651,008
cache_write: 3,534,719
cache_total: 16,185,727
all_total: 18,337,493

可以看到真正的 fresh input 并不是特别夸张,主要消耗集中在 cache_readcache_write

  1. 日志里有很多类似:

in=415 out=251 cache_r=11217 cache_w=683
in=415 out=211 cache_r=63065 cache_w=435
in=415 out=110 cache_r=64425 cache_w=835

这说明缓存应该是生效的,fresh input 只有几百 token,但 cache_read 每次可能有几万 token。

  1. 目前 usage 返回口径似乎是:

promptTotal = inputTokens + cacheReadTokens + cacheWriteTokens

然后返回:

prompt_tokens = promptTotal
input_tokens = promptTotal
total_tokens = promptTotal + outputTokens

这样会导致下游中转或计费系统把 cache_read / cache_write 也按普通 input token 统计,额度显示会消耗很快。

  1. 我们更担心的是上游 Windsurf 官方是否也在类似地统计 cache_read / cache_write

我们知道下游 usage 字段不会反向影响上游扣费,但如果上游本身也把 cache_read / cache_write 按较高权重计入 quota,那长上下文会话即使缓存命中,也会消耗得非常快。

目前我们不专业,不确定到底是哪一层的问题:

  • 是 usage 返回口径问题?
  • 是 Dashboard 展示问题?
  • cache_read / cache_write 本来就会被上游按额度扣?
  • policy_blocked / rate_limited 请求也消耗了额度?
  • 还是 cascade reuse / generatorOffset 仍然存在某些重复统计?

但从现象看,10 个 Trial 账号不应该这么快出现明显限流/额度压力,所以想请作者帮忙确认一下。

建议是否可以增加一些诊断能力:

  1. Dashboard 单独展示:

    • fresh_input
    • cache_read
    • cache_write
    • output
    • policy_blocked count
    • rate_limited count
  2. 增加“请求前后官方 quota 变化”对比:

    • request before: daily/weekly remaining
    • request after: daily/weekly remaining
    • 本次 usage: fresh_input / cache_read / cache_write / output
  3. 明确区分下游 usage 和上游真实 quota:

    • downstream reported usage
    • upstream reported usage
    • upstream quota delta
  4. policy_blocked 请求确认是否会消耗 quota,如果会,Dashboard 里最好单独显示。

  5. usage 返回可以保留 cache 细节,不要只合并成 input_tokens:

    • fresh_input_tokens
    • cache_read_tokens
    • cache_write_tokens
    • output_tokens
  6. 可选增加计费口径配置:

    • standard: cache_read/cache_write 包含在 prompt_tokens
    • fresh_only: input_tokens 只统计 fresh input
    • weighted: cache_read/cache_write 按折扣权重统计

核心问题不是缓存完全没生效,而是目前看起来 cache_read / cache_write 非常大,且可能被合并统计或真实计入 quota,导致长上下文请求消耗异常快。

麻烦作者帮忙确认一下:WindsurfAPI 当前 usage/cache 统计和 upstream quota 消耗之间是否存在口径问题,或者是否有重复统计 / 高估消耗的可能。

替代方案 / Alternatives considered

No response

是否愿意提 PR / Willing to submit a PR?

  • 我想自己实现 / I'd like to implement this myself

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions