fix: 修复第三方网关丢失 Codex 子代理任务 - #2382
Closed
geiweiwu-ai wants to merge 1 commit into
Closed
geiweiwu-ai wants to merge 1 commit into
geiweiwu-ai wants to merge 1 commit into
Conversation
在 Responses 转 Chat Completions 前复用现有代理消息转换,仅对已启用优化的 Codex 客户端生效。补充首次派发、后续派发、工具结果、流式和透传边界的 28 项回归测试。
Owner
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.
问题
Codex 通过 Cockpit 的第三方 Provider Gateway 调用 Chat Completions 模型时,子代理的任务消息会在协议转换阶段被丢弃。
Codex 使用
input[].type = "agent_message"传递任务,正文位于该消息的content[]中,内容块类型为encrypted_content。本次复现中的字段值是明文任务。Provider Gateway 在
handleProviderGatewayRequest中直接调用ConvertOpenAIResponsesRequestToOpenAIChatCompletions,绕过了常规 executor 已有的 Codex 多代理输入归一化。因此会出现两种症状:400: Requests ending with a model turn are not supported.。本问题已在 Cockpit Tools 1.3.47 和 Codex CLI 0.153.4 的 Windows 环境中复现。当前 main 中同一网关分支仍缺少此处理。
api-service-compatibility并非此问题的解决开关,该旧选项针对官方 OAuth API Service 的容量恢复与请求头行为。修复
仅在 Provider Gateway 的 Responses → Chat Completions 分支中,调用已有的
RewriteCodexMultiAgentV2Input,随后继续使用原来的通用转换器。optimize-multi-agent-v2开关。测试
新增
TestProviderGatewayCodexAgentMessages,以本地 HTTP 上游检查真正发出的请求。覆盖 7 种场景 × 2 种路由 × 流式/非流式,共 28 个子测试:修复前,前 3 种场景对应的 12 个子测试因任务缺失失败。修复后全部通过。
已执行:
相同补丁已回移至 v1.3.47 并编译为 Windows amd64 辅助程序,在独立端口通过真实 Gemini 上游的首次任务、后续任务及流式请求测试。安装后,通过 Codex 直接创建无继承上下文的 Gemini 子代理,成功读取指定测试文件并审查,随后通过
followup_task完成定点修正,不再出现任务丢失或上述 400。另一次独立子代理测试成功通过工具新建短文测试文件,主代理已核对实际文件内容。上述端到端测试均使用合成材料,没有读取或发布用户的小说资料。
本 PR 不包含账号凭据、第三方服务地址、实际工作区资料或生成的二进制文件。