fix(codex-proxy): merge multiple system messages into one leading message - #2688
Merged
EKKOLearnAI merged 2 commits intoAug 23, 2026
Merged
Conversation
…sage Codex 0.149 sends both a top-level `instructions` string and `developer` messages inside `input`. The responses->chat_completions adapter converted each into its own system message, leaving the second one mid-conversation. Providers such as vLLM reject this with: 400 BadRequestError: "System message must be at the beginning." consolidateChatSystemMessages() now keeps exactly one leading system message, merging any additional system messages into it in original order. Fixes web-ui coding-agent (codex + custom:qwen) run failures with vLLM-backed OpenAI-compatible providers. Refs: repro via mock capture of codex 0.149 responses payload
…system position The adapter now relocates in-input developer messages to the front as a single leading system message, so the expected message order changes from [user, system] to [system, user].
WenhuaXia
force-pushed
the
pr/codex-merged-system-messages
branch
from
August 23, 2026 04:21
83a0669 to
1d11107
Compare
2 tasks
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.
问题 / Problem
Codex 0.149 发起请求时会同时携带两处 system 级指令:
instructions字段(核心系统提示,实测 ~20KB)input数组中的role: "developer"消息(web-ui 写入的developer_instructions)responsesToOpenAiChat适配器把两者各转成一条system消息,第二条落在对话中间。vLLM 等严格校验的消息顺序,直接拒绝:影响:web-ui 编程工具(Codex / Claude Code)在 scoped 模式 + OpenAI-compatible vLLM provider(如 Qwen via vLLM)下 每次 请求都会失败。
修复 / Fix
新增
consolidateChatSystemMessages():转换完成后将所有system消息按原始顺序合并为一条置顶消息;仅一条 system 时保持原样(含图片 content 不被 stringify),只在其位于对话中间时移到开头。验证 / Verification
roles: [system, user, user]→ 直接请求 vLLM/v1/chat/completions→ HTTP 200,模型正常回复openAiChatToResponses)含 tool_calls 场景验证通过