fix: extract system messages from Responses API input into instructions#53
Open
Yinhan-Lu wants to merge 1 commit intoCaddyGlow:mainfrom
Open
fix: extract system messages from Responses API input into instructions#53Yinhan-Lu wants to merge 1 commit intoCaddyGlow:mainfrom
Yinhan-Lu wants to merge 1 commit intoCaddyGlow:mainfrom
Conversation
The upstream Codex Responses API rejects `role: "system"` messages in the input array. This causes a 400 error when clients (e.g., langchain-openai with use_responses_api=True) include SystemMessage in the input. Modify `_normalize_input_messages` to extract system and developer messages from the input array and merge them into the `instructions` field before forwarding upstream. This matches the behavior already implemented in the Chat Completions → Responses API converter. Fixes CaddyGlow#52 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
_normalize_input_messagesin the Codex adapter to extractrole: "system"androle: "developer"messages from theinputarray and merge them into theinstructionsfieldProblem
Clients like langchain-openai (with
use_responses_api=True) includeSystemMessageas a message in theinputarray. The upstream Codex Responses API rejects these with:This forces downstream projects (e.g., EvoScientist) to fall back from Responses API to Chat Completions API when using ccproxy, which means the
reasoningparameter cannot be used — OAuth users get degraded model capabilities compared to direct API key users.Fix
The Chat Completions → Responses API converter (
openai_to_openai/requests.py) already handles this correctly by extracting system messages intoinstructions. This PR applies the same logic to_normalize_input_messagesin the Codex adapter, which handles the direct Responses API path (/v1/responses).Test plan
Fixes #52
🤖 Generated with Claude Code