mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
9d35709805
MiniMax's OpenAI-compatible chat endpoint strict-rejects any non-leading role=system message with "invalid params, chat content has invalid message role: system (2013)". The Codex client uses role=developer (and occasionally role=system) to inject collaboration_mode / permissions / skills blocks mid-conversation, and responses_role_to_chat_role maps both to chat's system role. The converted messages array therefore frequently contained system entries past index 0, which DeepSeek and OpenAI tolerate but MiniMax flags as 2013. Collapse all system messages into a single leading system message before returning the chat request. The rewrite preserves every system fragment (joined by "\n\n" in original order) and leaves non-system messages untouched, so it is lossless for permissive backends as well. - Add collapse_system_messages_to_head in transform_codex_chat.rs. - Run it on the messages vector at the end of responses_to_chat_completions before serializing. - Cover the new path with two unit tests: one repros the MiniMax-shaped input (developer items between users) and asserts no system role past index 0; the other verifies non-system order is preserved and content is joined with "\n\n".