Skip to content

fix(gateway): 429 同 key 只再试一次,换 key 前拉长退避 - #818

Merged
johnnyzhang-eng merged 2 commits into
1024XEngineer:mainfrom
xiaocheny214:fix/gateway-429-exponential-backoff
Aug 27, 2026
Merged

fix(gateway): 429 同 key 只再试一次,换 key 前拉长退避#818
johnnyzhang-eng merged 2 commits into
1024XEngineer:mainfrom
xiaocheny214:fix/gateway-429-exponential-backoff

Conversation

@xiaocheny214

@xiaocheny214 xiaocheny214 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 同一把 key 遇到 429 只再试一次(共 2 次),不再连打三次。
  • 仍 429 则等 16s(同 key 再试 8s;指数退避上限 60s;Retry-After 作下限)再切下一把 key;新 key 同样只再试一次。
  • 本入口 key 用尽则熔断该 base_url,切备用入口;没有备用入口则熔断 aggregator。
  • 图 / 视频 / chat 三条 Gateway 共用同一套策略。52x、空响应不变。

Closes #817

Test plan

  • uv run pytest tests/test_gateway_policy.py tests/test_gateway_image.py tests/test_gateway_video.py tests/test_gateway_chat.py -q
  • 单 key:2 次后失败并打开 aggregator 熔断
  • 多 key:key-a 两次后等 8s+16s 切 key-b
  • 本入口 key 用尽后切 backup,并熔断 primary
  • 52x UNREACHED 仍只同 key 再试一次,不走这条退避

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
windup Ignored Ignored Preview Aug 27, 2026 8:42am

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ges/framework/src/windup_framework/gateway/chat.py 66.66% 3 Missing ⚠️
...es/framework/src/windup_framework/gateway/video.py 78.57% 3 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #818      +/-   ##
==========================================
- Coverage   87.09%   86.51%   -0.59%     
==========================================
  Files         288      293       +5     
  Lines       21559    21918     +359     
  Branches     3299     3329      +30     
==========================================
+ Hits        18777    18962     +185     
- Misses       1852     2026     +174     
  Partials      930      930              
Flag Coverage Δ
backend 91.51% <85.00%> (-0.24%) ⬇️
frontend 80.54% <ø> (-1.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...es/framework/src/windup_framework/gateway/image.py 91.62% <100.00%> (+0.13%) ⬆️
...s/framework/src/windup_framework/gateway/policy.py 100.00% <100.00%> (ø)
...ges/framework/src/windup_framework/gateway/chat.py 89.41% <66.66%> (-0.93%) ⬇️
...es/framework/src/windup_framework/gateway/video.py 82.52% <78.57%> (-1.02%) ⬇️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审阅了共享退避策略以及 chat、image、video 三条 Gateway 的 429 重试、换 key 和非 429 重试路径。改动符合 #817 的契约:同一 key 仍执行三次调用,等待为 2s/4s,Retry-After 作为下限并保留 30s 封顶;UNREACHED 等其他策略未被改动。

未发现达到报告阈值的 correctness、可靠性或兼容性问题。验证方面,compileallgit diff --check 通过;PR 描述中的 pytest 命令未能执行,因为当前环境没有 uvpytest

@xiaocheny214 xiaocheny214 changed the title fix(gateway): 429 同 key 仍重试三次,间隔改为指数退避 fix(gateway): 429 同 key 只再试一次,换 key 前拉长退避 Aug 27, 2026
@johnnyzhang-eng

Copy link
Copy Markdown
Contributor

LGTM

@johnnyzhang-eng
johnnyzhang-eng merged commit 45750f0 into 1024XEngineer:main Aug 27, 2026
28 checks passed
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.

fix(gateway): 429 同 key 只再试一次,换 key 前拉长退避

2 participants