Skip to content

fix: anthropic 协议下 codex 模型档位直传 reasoning_effort - #317

Merged
robscc merged 1 commit into
mainfrom
fix/anthropic-codex-effort
Nov 23, 2026
Merged

robscc merged 1 commit into
mainfrom
fix/anthropic-codex-effort

Conversation

@robscc

@robscc robscc commented Nov 23, 2026

Copy link
Copy Markdown
Owner

现象

anthropic provider(阿里云 MaaS anthropic 协议端点等 anthropic 壳网关)下使用 codex 系模型(gpt-5.x-codex / gpt-6.2-sol / codex/ 别名),在模型菜单选思考档位后请求报错。

根因

models.py anthropic 分支默认把档位映射成 thinking/budget_tokens(Claude 系原生参数);codex 只吃 reasoning_effort——anthropic 壳网关对 codex 收到 thinking 块直接 400。此前唯一出口是手配 thinking_param_style=reasoning_effort(provider 级开关,混部 Claude 模型的配置不可用)。

修复

anthropic 分支 codex_efforts(model) 命中时自动走 reasoning_effort 直传(与 thinking_param_style 覆写同路径):不发 thinking 块、不动 temperature/max_tokens 约束;off 由 resolve 层归一化为 low(codex 值域无 off,既有 legacy 规则)。

验证

  • 新增回归 test_anthropic_codex_effort_direct_reasoning_effort:high → reasoning_effort=high 且无 thinking 键;off → low
  • test_models_thinking + test_thinking_effort 47 全绿;ruff 干净

现象(2026-11-23 用户报障):anthropic provider 里用 codex 系模型
(gpt-5.x-codex / gpt-6.2-sol),模型菜单选思考档位后请求报错。

根因:models.py 的 anthropic 分支默认走 thinking/budget_tokens(Claude
系原生参数);codex 只吃 reasoning_effort——anthropic 壳网关对 codex
收到 thinking 块直接拒(400)。此前唯一出口是手配
thinking_param_style=reasoning_effort( provider 级,对混部 Claude 的
配置不可用)。

修复:anthropic 分支判定 codex_efforts(model) 命中时自动走
reasoning_effort 直传(与 thinking_param_style 覆写同路径),不发
thinking 块、不改 temperature/max_tokens 约束;off 由 resolve 层
归一化为 low(codex 无 off 档,既有 legacy 规则)。

验证:新增回归用例 test_anthropic_codex_effort_direct_reasoning_effort
(high → reasoning_effort=high、无 thinking 键;off → low);
test_models_thinking + test_thinking_effort 47 全绿;ruff 干净。
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@robscc
robscc merged commit d6e78cb into main Nov 23, 2026
6 checks passed
@robscc
robscc deleted the fix/anthropic-codex-effort branch November 23, 2026 02:32
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.

2 participants