Skip to content

fix(provider): stream Codex connection probes - #1508

Open
yoruuuchan wants to merge 1 commit into
AAswordman:devfrom
yoruuuchan:fix/codex-connection-test-stream
Open

yoruuuchan wants to merge 1 commit into
AAswordman:devfrom
yoruuuchan:fix/codex-connection-test-stream

Conversation

@yoruuuchan

Copy link
Copy Markdown
Contributor

变更说明 / Description

背景与动机 / Context and motivation

Codex(OPENAI_CODEX)模型配置的「测试连接」始终失败,返回 HTTP 400 {"detail":"Stream must be set to true"},而同一配置正常聊天可用。原因是 ModelConfigConnectionTester的两处探测都固定传入 stream = false,Codex后端只接受流式请求。

改动范围 / Changes

  • ModelConfigConnectionTester在探测前根据 configForTest.apiProviderType计算 probeStream:OPENAI_CODEX为 true,其他 provider保持 false。
  • chat与 tool_call两个探测都使用 probeStream;复用 collectResponse的媒体探测也随之使用同一取值。
  • 不包含:聊天主链路、CodexProvider、其他 provider的探测方式。

兼容性与风险 / Compatibility and risks

  • 仅 Codex连接测试的请求由非流式改为流式;其他 provider行为不变,聊天请求不受影响。
  • 无数据格式、API、配置、性能或安全影响。

关联 Issue / Related issue

Fixes #1490

验证方式 / Verification

检查或命令:git diff --check
python -B ci/script/check_repo_hygiene.py --base upstream/dev --candidate HEAD
环境与变体:Windows,本地源码检查;未运行 Gradle构建与 JVM测试
结果:git diff --check无输出;hygiene errors=0 warnings=0

未运行 Gradle构建、单元测试与真机验证:仓库 AGENTS.md约定默认不执行编译/测试命令,且本机没有 Codex OAuth账号和 Android运行环境,无法端到端确认400消失。需要设备侧复测:Codex配置下 chat与 tool_call两项连接测试通过,其他 provider的探测保持原行为。PR的 Candidate checks会随本 PR运行。

证据 / Evidence

N/A(无 UI改动;改动内容见 diff)

检查清单 / Checklist

  • 我已记录可复现验证和未运行项原因 / Reproducible verification and reasons for unrun checks are recorded
  • 日常开发 PR的目标分支为 dev;如目标为 main,我已说明这是维护者发布同步 / The target branch is dev for regular work; if it is main, I explained why this is a maintainer-led release sync
  • 我已确认 Candidate checks覆盖改动范围,并会处理技术失败项 / Candidate checks covers the change scope and technical failures will be addressed
  • 最终 diff无无关、临时、生成、二进制或敏感内容 / Final diff has no unrelated, temporary, generated, binary, or secret content
  • 已提供对应的回归、UI、文档/字符串或兼容性证据 / Relevant regression, UI, docs/strings, or compatibility evidence is provided

ModelConfigConnectionTester ran both probes with stream = false, but the
Codex backend only accepts streaming requests ("Stream must be set to true").
Probe Codex with streaming; every other provider keeps the non-streaming
probe. The chat pipeline is untouched.

Fixes AAswordman#1490

@CATMIAOZHI CATMIAOZHI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

审计结论:✅ 批准合并

改动(1 个文件,+7/−2):ModelConfigConnectionTester 在探测前按 apiProviderType 计算 probeStream,OPENAI_CODEX 为 true,其他 provider 保持 false;chat、tool_call、图片/音频(复用 collectResponse)三类探测都使用该取值。

通过的检查:

  • 目标分支为 dev,非草稿 PR,改动范围与 PR 描述一致,无关内容没有混入。
  • 三处探测已全部覆盖:collectResponse(chat 与图片/音频探测共用)与 runToolCallTest 均改用 probeStream;文件内已无残留的 stream = false。
  • probeStream 取自 configForTest.apiProviderType(config.copy(modelName = …) 保留了 provider 类型),ApiProviderType.OPENAI_CODEX 真实存在;其他 provider 的行为完全不变,聊天主链路未动。
  • 链路已核对:stream 参数经 OpenAIResponsesProvider.createRequestBody → createRequestBodyInternal 写入 Responses API 请求体;聊天主链路默认 stream = true(AIService.kt:65、OpenAIProvider.kt:582),与 PR 所述「同一配置正常聊天可用」一致。设置页「测试连接」入口正是 ModelConfigConnectionTester.run(ModelConfigScreen.kt:580),修的正是报 400 的路径。
  • 无安全、权限、token 存储、UI 字符串方面的影响;CancellationException 仍原样 rethrow。
  • 作者如实说明了验证边界:只跑了 git diff --check 与仓库 hygiene 检查,未做 Gradle 构建、单元测试与真机验证(无 Codex OAuth 账号),需设备侧复测。

问题:

  1. [P3] 合并前请确认本 PR 的 Candidate checks 通过;设备侧复测(Codex 配置下 chat 与 tool_call 两项连接测试通过、其他 provider 探测行为不变)仍待验证,作者已在 PR 中说明,建议合并后由有 Codex 账号的维护者复测确认。
  2. [question] 本 PR 范围外的同类硬编码是否后续统一处理:EnhancedAIService.callFunctionModel(EnhancedAIService.kt:722,标题/摘要等函数模型固定 stream = false)与 OpenAIProvider.testConnection(密钥池可用性探测固定 stream = false)——Codex 配置若走到这些路径会遇到同样的 400。另,#1490 报告称正常聊天也会 400,但按当前代码聊天主链路默认流式、应可正常工作;若合并后 #1490 自动关闭前发现聊天仍有 400,请在 #1490 中补充复现信息另案处理。

后续可跟进(不阻塞):上述 [question] 的两处 stream = false 调用点可作为后续 issue 跟进,不影响本 PR 合并。

由 水晴喵的muse 审计

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