Skip to content

feat(openai): warm up general quota buckets after reset - #725

Merged
zyycn merged 2 commits into
mainfrom
feat/quota-bucket-warmup
Nov 16, 2026
Merged

zyycn merged 2 commits into
mainfrom
feat/quota-bucket-warmup

Conversation

@zyycn

@zyycn zyycn commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

问题与改动

Closes #714

现有 Cron 按固定时间启动预热,而各账号的通用额度窗口有各自的重置时间。额度桶设置现在可为每个通用窗口配置调度上限和预热模型。开启预热后,窗口重置满 5 分钟才复查额度。有本轮使用证据就跳过,取整为 0% 的请求和成功的 Cron 预热也参与判断。

窗口判断使用 Codex 的 RateLimitWindowSnapshot。上游提供重置时间和用量比例,空闲时的滚动重置时间会保留首次登记的到期边界,本地请求反馈补足用量取整带来的信息缺口。

迁移 0044 将已有调度上限转入 quotaSettings,预热默认关闭。管理 API 使用 quotaSettings 替代 quotaLimits,调用方须同步更新字段和结构。

自审与验证

  • OpenAI Provider 判断通用窗口、复查用量并复用 Cron 的单账号预热请求。PostgreSQL 原子领取本轮预热,核对当前凭据版本、配置、额度观测和账号状态,领取进度跨重启保留。
  • Rust 格式检查、全功能 Clippy、前端格式检查和构建通过。OpenAI Provider 契约回归 325 项、额度回归 87 项通过,覆盖失败流、断流、空输出成功和实际输出后的失败;只有成功完成或已有实际输出才记录本轮使用。数据库回归覆盖并发领取、状态变更、账号导入与额度合并;备份恢复在补齐 psql 后复跑通过。在 PostgreSQL 18 用旧上限和空配置验证了 0044,原上限保留,预热默认关闭。
  • 账号额度入口复用原设置弹窗,模型采用账号模型下拉。用户已确认布局,预热请求使用模拟上游验证,未调用真实账号。

页面截图

账号详情 → 额度桶设置。前后对照截图待补。

AI 使用

Codex(gpt-6.1-sol)参与实现、自审和回归验证;gpt-6-astra 参与审查修复和回归验证。

Co-authored-by: Codex <noreply@openai.com>
@zyycn
zyycn marked this pull request as ready for review November 16, 2026 06:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T06:22:14.632711Z c2c8138 Manual request
🔒 Security Review ✅ Completed 2026-11-16T06:23:07.629011Z c2c8138 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0628a0fb19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +25 to +26
self.synchronize_passive_rate_limits_with_usage(account, rate_limits, true)
.await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 区分失败流的额度观测与真实使用证据

当上游返回额度头或 codex.rate_limits,随后以 response.failed 或流内错误拒绝请求时,这里仍无条件传入 true。provider/execution.rs 的 terminal_failure 和流读取失败分支都会经 synchronize_passive_quota 调用此方法,因此即使请求没有消耗额度,也会写入 _cpr_bucket_last_used_at。WarmupProgress::reconcile 随后将该时间视为重置后的使用证据,跳过整个窗口的预热;后续主动刷新也会保留这一错误证据。应让这些调用方显式传递是否存在实际使用证据,失败路径只合并额度事实,不默认标记已使用。

Useful? React with 👍 / 👎.

Co-authored-by: Codex <noreply@openai.com>
@zyycn

zyycn commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2c813803b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +125 to +126
<ZFormItem v-if="row.warmup" :label="t('accounts.quotaSettings.model')" required>
<ZSelect v-model="row.model" class="w-full" :options="modelOptions" :aria-label="`${row.label} · ${t('accounts.quotaSettings.model')}`" :placeholder="t('accounts.quotaSettings.modelPlaceholder')" :empty-text="t('accounts.connectionTest.noModels')" :disabled="loading || loadingModels" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 补齐额度桶设置弹窗的实际运行截图

这是界面验证缺口,而非已确认的布局缺陷:本次弹窗新增了逐桶预热开关和条件显示的模型选择器,但目标提交说明仍标注“前后对照截图待补”。请补充对应此提交、可供审查者访问的变更前后运行截图,展示弹窗展开及开启预热后的状态,并记录保存和重新打开的交互验证结果;仅有布局确认和构建通过不足以核对这些新增状态。仓库 AGENTS.md 明确要求缺少必需截图时补齐。

AGENTS.md reference: AGENTS.md:L71-L71

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c2c813803b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@zyycn
zyycn merged commit 5b7f307 into main Nov 16, 2026
11 checks passed
@zyycn
zyycn deleted the feat/quota-bucket-warmup branch November 16, 2026 06:24
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.

[功能建议] 每周额度窗口到期后立即自动预热,减少额度周期浪费

1 participant