fix(codex): route Claude system prompts to Responses API instructions - #820
Open
Shanlans wants to merge 1 commit into
Open
fix(codex): route Claude system prompts to Responses API instructions#820Shanlans wants to merge 1 commit into
Shanlans wants to merge 1 commit into
Conversation
Shanlans
force-pushed
the
fix/codex-system-to-instructions
branch
from
July 30, 2026 09:35
afb101e to
09f7204
Compare
The Codex ChatGPT OAuth upstream rejects system/developer role messages
inside the Responses API `input` array ("System messages are not
allowed"). The translator previously emitted the top-level Claude
`system` prompt as a `role:"developer"` input message and left
`instructions` empty, and it also passed through any `role:"system"`
messages injected into the conversation (e.g. by Claude Code Agent
Teams) verbatim into `input`.
Fold both the top-level `system` field and any in-conversation
system/developer messages into the top-level `instructions` string, and
never emit system/developer roles into `input`. Add tests covering both
paths.
Shanlans
force-pushed
the
fix/codex-system-to-instructions
branch
from
August 12, 2026 02:40
09f7204 to
3777057
Compare
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
When translating Claude requests to the Codex Responses API, the ChatGPT OAuth upstream rejects
system/developerrole messages inside theinputarray with:Two sources produced such messages:
systemprompt was emitted as arole:"developer"message insideinput, while the top-levelinstructionsfield was hard-coded to"".role:"system"message injected into the conversation (e.g. by Claude Code Agent Teams,CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, which adds an "Available agent types…" system message) was passed through verbatim intoinput.Both caused upstream
400 System messages are not allowed.Fix
internal/translator/codex/claude/codex_claude_request.go:systemfield (array or string) into the top-levelinstructionsstring.system/developerrole message's text intoinstructionsas well, instead of emitting it intoinput.system/developerroles intoinput.Result envelope now looks like:
{ "model": "...", "instructions": "<system prompt>", "input": [ { "role": "user", ... } ] }Tests
Added to
codex_claude_request_test.go:TestConvertClaudeRequestToCodex_SystemBecomesInstructions— top-level system → instructions, no system/developer in input.TestConvertClaudeRequestToCodex_InConversationSystemMessageFolded— in-conversationrole:"system"message folded into instructions, absent from input.go test ./internal/translator/codex/claudepasses.Verified end-to-end against a live Codex (
gpt-5.6-sol) route with Agent Teams enabled: previously400 System messages are not allowed, now200.🤖 Generated with Claude Code