Skip to content

fix(devin-connect,chat): honor the 429 reset window on the streaming path — propagate resetMs + cool account-wide#224

Merged
dwgx merged 1 commit into
dwgx:masterfrom
warelik:fix/reset-window
Jul 25, 2026
Merged

fix(devin-connect,chat): honor the 429 reset window on the streaming path — propagate resetMs + cool account-wide#224
dwgx merged 1 commit into
dwgx:masterfrom
warelik:fix/reset-window

Conversation

@warelik

@warelik warelik commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

中文 TL;DR

流式 DEVIN_CONNECT 路径丢了 429 的 reset window,并且把 cooldown 写到账号池读不到的
model 维度上,导致刚被限流的账号被立刻重选、反复打 upstream limiter。本 PR 让 resetMs
一路透传,并按 account-wide 冷却(池选择用 modelKey=null,只认 rateLimitedUntil)。

Summary

Closes #221. Two links of one chain — a 429 reset window is dropped in transport,
then written to a cooldown dimension the pool never reads. Both must be fixed
together for any observable effect.

Root cause

  • classifyUpstreamError() parses resetMs, but streamChat's two error paths
    kept only { code, message } → cooldown fell back to the short burst default.
  • acquireConnectAccountgetApiKey(triedKeys, null, ...) selects with
    modelKey = null; isRateLimitedForModel only reads _modelRateLimits when
    modelKey is truthy, so a model-scoped cooldown can never gate DEVIN_CONNECT
    selection. rateLimitedUntil (account-wide) is the only dimension it honors.

Fix

  • src/devin-connect.js (2 points): forward resetMs onto streamError.
  • src/handlers/chat.js: markRateLimited(apiKey, resetMs, null, 'r').

Test plan

  • test/devin-connect.test.js +2: resetMs on non-200 (2h30m) & JSON-trailer (1h15m) paths
  • test/devin-connect-pool.test.js: F2 now asserts account-wide rateLimitedUntil honors the 3h window
  • Full suite: npm test2763 pass / 0 fail

Branch is rebased on current master (v3.5.0), applies cleanly.

…DEVIN_CONNECT path

The streaming path dropped the upstream rate-limit reset window and then cooled
the account on a dimension the pool never reads, so a rate-limited account was
re-selected within seconds and kept hammering the upstream velocity limiter.

- src/devin-connect.js: both streamChat error paths (non-200 + JSON trailer) now
  forward classified.resetMs onto streamError (audit F3) instead of destructuring
  only {code, message}
- src/handlers/chat.js: finalizeConnectAccount RATE_LIMITED cools account-wide
  (markRateLimited(apiKey, resetMs, null, 'r')) — acquireConnectAccount selects
  with modelKey=null, so a model-scoped cooldown is invisible to selection;
  rateLimitedUntil is the only dimension getApiKey honors there
- test/devin-connect.test.js: +2 — resetMs propagation on non-200 and trailer paths
- test/devin-connect-pool.test.js: F2 updated to assert account-wide cooldown
@dwgx
dwgx merged commit 014ead1 into dwgx:master Jul 25, 2026
5 checks passed
dwgx added a commit that referenced this pull request Jul 25, 2026
- contributors.json: 新增 6 条(#224 S / #225 A+ / #226 S / #227 A / #228 B+ / #229 A)
- README 中英: warelik 段落补本轮六个 PR 的技术叙述
dwgx added a commit that referenced this pull request Jul 25, 2026
@dwgx

dwgx commented Jul 25, 2026

Copy link
Copy Markdown
Owner

已合并,谢谢 🙏 这个 PR 最有价值的地方是把"两条链只修一条毫无可观测效果"这件事讲清楚了 —— 这正是它此前一直没被发现的原因:光看 classifyUpstreamError 会觉得 resetMs 解析得好好的,光看 finalizeConnectAccount 会觉得冷却也写了,只有把 getApiKey(triedKeys, null, ...)modelKey=nullisRateLimitedForModel 的 truthy 判断连起来,才看得出 model-scoped 那一维在这条路径上结构性地永远关不住。

account-wide 这个取舍我认同并已采纳:DEVIN_CONNECT 选池就是不带 modelKey 的,rateLimitedUntil 是唯一被认的维度,把 3h 窗口落在一个读不到的维度上等于没冷却。代价是同账号其他模型也一起被禁 —— 但比起把账号撞到硬封 3h,这个代价明显更小。

传输层那两条回归测试(非 200 与 JSON trailer 双路径都断言 resetMs)补得很到位,以后谁再动 streamChat 的错误解构都会被这两条拦住。

已加入致谢名单(dashboard credits 面板 + README 中英),评级 S。

dwgx added a commit that referenced this pull request Jul 25, 2026
合入 warelik 六连(#224-#229):429 reset window 双链根因(resetMs 传输层透传 +
冷却落到 account-wide,原先 model-scoped 对 modelKey=null 的池选择结构性不可见)、
客户端断连不再罚账号(abort 统一识别,流式/非流式全路径不 failover 不烧配额,499)、
Grok/xAI self-ID 中和(a6-grok)、thinking signature 空串改省略、Responses usage
补 input/output_tokens_details、pair-chain 会话连续性新模块(600 行零依赖,默认关)。

合入 forrinzhao #219 的 codex content-policy 发现:落地为规则 (a7),并修根因 ——
工具描述 preamble 原本注入在 neutralizeClientIdentity 之后,导致 native 路径上
任何经由工具描述进来的触发词都绕过 a1-a6 整条防线。identity-neutralize 现覆盖
Claude Code / Cline / Grok / codex 四个客户端。

DEVIN_CONNECT cache_read_tokens=5 付费校准并改为默认解码(#220):缓存命中不再被
当作新鲜输入计费,与 #229 合起来端到端可见;'off' 可全关。setup.sh 在无 LS 二进制
的主机(macOS 典型)默认写 DEVIN_CONNECT=1 + 回环绑定。

2778/0 绿。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DEVIN_CONNECT 流式路径丢失 429 reset window + model-scoped cooldown 对账号池不可见

2 participants