Skip to content

[upstream-port] Responses/SSE:断连计费与慢客户端写超时(0c2af978 + 7e659672) #943

Closed as not planned

Description

@LIghtJUNction

来源

  • QuantumNous/new-api 0c2af978 — fix(relay): count Responses streams that disconnect after the last useful event as billed completions(upstream PR #7956)
  • QuantumNous/new-api 7e659672 — fix(relay): stop cutting off slow clients during large stream events(按字节预算的写超时,替代固定 30s/次)

为什么要迁

  • 客户端在「最后有用量事件之后、正式收尾之前」断流时,上游已改为记为已计费完成,避免漏记;慢速下载大图/大 SSE 事件时固定写超时会被误判为 disconnect。
  • 与钱包边界兼容:这是计费正确性/流控,不是改汇率或钱包模型;需对照 LMM 的 interrupted-stream / missing-usage 策略(历史上有 billing(responses): reconcile interrupted-stream missing-usage policy with new-api #7427 #373 等)。

映射路径

  • upstream relay/、controller/relay.go、relay/helper/stream_scanner.go、relay/responses_websocket.go → services/core(Rust 主线;勿再往 apps/api-go 塞)
  • 测试:upstream relay/helper/stream_scanner_test.go 中 StreamWriteBudget 行为可参考移植

风险

建议测试

  • 慢客户端读大 SSE(≥数 MB)不中途掐断;停读客户端仍在预算耗尽后断开
  • Responses WS / SSE:断在 usage 之后仍按完成计费;断在无 usage 前行为不变

工作量

中(后端,约 0.5–1.5d);不需要 Opus FE。

备注

本轮 upstream 已审至 33c61a24(自 206e0fa5)。OpenAI 12h cache(e9d4d635 / #7965)已由 owner draft #941 覆盖,本 issue 不重复。

Activity

  1. added
    botOpened by the maintenance bot
    upstream-portQuantumNous/new-api upstream commit port candidate
    on Oct 23, 2026
  2. zailushang2008 commented on Oct 28, 2026

    @zailushang2008

    这玩意瞎搞,搞的现在失败的全部乱计费,new-api谁还搞

  3. LIghtJUNction commented on Nov 14, 2026

    @LIghtJUNction
    MemberAuthor

    本 Issue 已合并到 #986 统一跟踪:#986

    本次关闭仅用于合并去重,不代表问题已修复、已验收或放弃处理。原始正文和讨论仍保留在这里,后续实现与验收请使用新 Issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions