Skip to content

fix(provider): 修复 Chat reasoning_effort 值域与 Responses 扩展透传#620

Merged
fawney19 merged 1 commit into
fawney19:mainfrom
zhefox:main
Jun 4, 2026
Merged

fix(provider): 修复 Chat reasoning_effort 值域与 Responses 扩展透传#620
fawney19 merged 1 commit into
fawney19:mainfrom
zhefox:main

Conversation

@zhefox
Copy link
Copy Markdown
Contributor

@zhefox zhefox commented Jun 3, 2026

背景

OpenAI Chat Completions 只接受 reasoning_effortlowmediumhigh。当 Responses、Claude Messages、Gemini 或模型后缀指令产生 xhigh / max 后,再转换到 OpenAI Chat 时会透传非法值,导致上游返回 400。

同时,Responses 请求转换到 Chat 时,部分 Responses-only 字段可能被透传到 Chat 请求体,存在兼容性风险。

变更内容

  • 修复 OpenAI Chat request 输出的 reasoning_effort 值域:

    • low 保持为 low
    • medium 保持为 medium
    • high 保持为 high
    • xhigh / max 转换为 high
    • 未知值不再透传到 Chat 请求体
  • 覆盖所有转 Chat 的来源路径:

    • OpenAI Responses reasoning.effort=xhigh -> Chat reasoning_effort=high
    • Claude Messages output_config.effort=max -> Chat reasoning_effort=high
    • Gemini 高 thinking budget 推导出的 xhigh -> Chat reasoning_effort=high
    • 模型后缀 -xhigh / -max 用于 OpenAI Chat 时收敛为 high
  • 过滤 Responses -> Chat 的扩展字段透传:

    • 保留 Chat 兼容字段:verbosityservice_tierprompt_cache_keysafety_identifieruser
    • 不再透传 Responses-only 字段,例如 includestoretextreasoning
  • 补充回归测试:

    • Responses -> Chat 的 xhigh 收敛和扩展字段过滤
    • Claude Messages -> Chat 的 max 收敛
    • Gemini -> Chat 的 xhigh 收敛
    • 模型后缀指令到 Chat 的 xhigh 收敛

测试

  • cargo test -p aether-ai-formats

@fawney19 fawney19 merged commit 19d1d36 into fawney19:main Jun 4, 2026
14 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.

2 participants