fix(usage): 修正 OpenAI 5h 用量窗口 used%/remaining% 颠倒#2918
Open
wucm667 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
OpenAI Codex 5h 用量窗口的上游百分比是 remaining% 语义,但 7d 窗口是 used% 语义。现有归一化逻辑把 5h 原始值直接写入
codex_5h_used_percent,导致 issue 中的 “5h 剩余 6%” 被前端按 used 6% 展示,而 7d 的 used 93% 展示保持正确。预检已确认当前没有同类修复 PR;#2873 在 v0.1.133 中引入的 5h/7d auto-pause 会读取同一组规范字段,因此这次修复也会让调度阈值继续使用统一的 used% 语义。
改动
OpenAICodexUsageSnapshot.Normalize()中把 5h 上游 remaining% 归一为 canonical used%,即codex_5h_used_percent = 100 - remaining。codex_primary_*/codex_secondary_*原始字段,方便继续排查上游 header;7d 现有 used% 行为不变。测试
cd backend && go test -tags=unit ./...cd backend && golangci-lint run ./...Fixes #2904