mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 20:32:25 +03:00
* fix(sse): demote mid-conversation system roles to user in claude-to-openai translation Claude Code hook contexts (SessionStart ~25KB, PreToolUse) arrive as role:system messages in the middle of the messages array. HCP-Vision-Latest vLLM (via LiteLLM gateway) rejects any system not at index 0 with 400 "System message must be at the beginning." Demote every system at output index > 0 to user with content preserved byte-identical; the index-0 system (translator-made from the top-level system field, or client-placed first) stays untouched. Other upstreams are unaffected: 135/138 recent mid-system calls to GLM-5.3-Flash / DeepSeek-V4-Flash already returned 200. Supersedes the pass-through assertion of #6954 (its intent — systems never misattributed as assistant — still holds). * test(sse): harden mid-system demotion with env guard and array-path invariant note Quality-review Minor 1: document the array-return-path invariant in claudeToOpenAIRequest (convertClaudeMessage arrays are tool/user only, so no second system element can survive demotion while result.messages is empty). Minor 2: add the same OMNIROUTE_SYSTEM_INSTRUCTION_APPEND env guard to the #6954 test as the new mid-system test for consistency. APPROVED items, no behavior change. --------- Co-authored-by: Jihyun Son <jihyun.son@sk.com>