Skip to content

fix: extract system messages from Responses API input into instructions#53

Open
Yinhan-Lu wants to merge 1 commit intoCaddyGlow:mainfrom
Yinhan-Lu:fix/responses-api-system-messages
Open

fix: extract system messages from Responses API input into instructions#53
Yinhan-Lu wants to merge 1 commit intoCaddyGlow:mainfrom
Yinhan-Lu:fix/responses-api-system-messages

Conversation

@Yinhan-Lu
Copy link
Copy Markdown

Summary

  • Fix _normalize_input_messages in the Codex adapter to extract role: "system" and role: "developer" messages from the input array and merge them into the instructions field
  • This prevents 400 errors when clients send system messages via the Responses API endpoint

Problem

Clients like langchain-openai (with use_responses_api=True) include SystemMessage as a message in the input array. The upstream Codex Responses API rejects these with:

400 - {'detail': 'System messages are not allowed'}

This forces downstream projects (e.g., EvoScientist) to fall back from Responses API to Chat Completions API when using ccproxy, which means the reasoning parameter 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 into instructions. This PR applies the same logic to _normalize_input_messages in the Codex adapter, which handles the direct Responses API path (/v1/responses).

Test plan

  • New test: system messages extracted from input to instructions
  • New test: system messages merged with existing instructions
  • New test: developer role messages also extracted
  • All 19 existing + new adapter unit tests pass

Fixes #52

🤖 Generated with Claude Code

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>
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.

Responses API endpoint rejects system messages in input array

1 participant