Repository navigation
fix(openai): 保留 Codex OAuth 请求中的 Astra reasoning.mode - #6690
Merged
Merged
Conversation
alfadb
force-pushed
the
fix/astra-pro-mode
branch
from
September 7, 2026 08:33
f057291 to
6e5e633
Compare
alfadb
force-pushed
the
fix/astra-pro-mode
branch
from
September 7, 2026 09:59
6e5e633 to
0aaed39
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
概述
normalizeOpenAIResponsesReasoningMode此前会无条件删除reasoning.mode,并在gpt-6-astra-pro未显式提供 effort 时把reasoning.effort改写为max。对 GPT‑6 Astra 模型而言,reasoning.mode与reasoning.effort是相互独立的参数:用其中一个去改写另一个,会破坏显式设置了reasoning.mode的 Codex OAuth 请求。本变更让
normalizeOpenAIResponsesReasoningMode对 Astra 模型直接原样返回请求体(复用现有的isOpenAIGPT6AstraModel辅助函数),即停止对 Astra 请求做这种不等价改写。所有非 Astra 模型保持与之前完全一致的行为(剥离reasoning.mode,pro 缺 effort 时映射为max)。注意:这是请求语义保真意义上的修复——代理不再擅自改写客户端显式给出的
reasoning.mode/reasoning.effort组合。它不是"Codex 订阅 Pro 已开放/已实现 Pro 调用"的声明,也不推断原请求此前一定成功,更不保证未来无需适配。变更范围
reasoning.mode现在原样透传给 Codex;reasoning.effort不再被覆盖。不新增模型别名,不自动升级模型,不覆盖 effort,也不改动计费或账号选择逻辑。reasoning.mode。reasoning.mode的400时,只发出一次上游请求,并原样保留 Codex 的结构化错误体。gpt-6-astra-pro上发送reasoning.effort: max;当所有账号耗尽且状态码为403时,现有策略仍把结果映射为502(本 PR 不声称原始403完全透传)。测试
新增测试(均为 unit tag,使用 Go 1.27 运行,全部通过):
openai_astra_pro_mode_test.go— 一个 20 子测试矩阵(5 组 mode/effort 参数组合 × 原生 Codex OAuth 与 passthrough × 客户端流式开关 true/false),断言对象是转发给 Codex 的最终 HTTP 请求体;另有响应路径测试,验证 SSE 以及 SSE→JSON 均保留reasoning.mode;还有一个针对非 Astra 模型的旧行为回归测试。openai_astra_pro_retry_test.go—400mode 拒绝透传且仅一次上游请求;reasoning.mode在被拒字段重试中得以保留。openai_responses_astra_pro_failover_test.go— 首账号403后成功、双账号403不降级(映射为 502)、以及跨模式派生请求体保留顶层reasoning.mode。在本分支上通过完整单元测试套件:
针对性测试:
局限: 自动化测试均为 mock——它们证明的是代理对
reasoning.mode的转发/转换/重试行为正确。此后另做过一次真实网关探测:显式发送gpt-6-astra+reasoning.mode=pro+reasoning.effort=max的一次请求,客户端可见的响应为 HTTP 400 结构化错误(error.type=invalid_request_error、error.code=unsupported_value、error.param=reasoning.mode)——没有返回成功响应对象,也没有 mode 回显,探测客户端未重试、也未发送降级对照请求。该错误与既有的确定性上游 400 透传路径一致(Astra 归一化器不做本地 mode 取值校验,因此这不是代理本地校验拒绝),但该请求所选的上游账号类型/上游地址没有独立的运行时证据可确认,因此该探测既不能证明 Codex 订阅 Pro 可用,也不能证明其普遍不可用。参考资料
reasoning.mode)