mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
The OpenAI->Gemini request translator built result.contents without a consecutive-same-role merge pass (unlike the Kiro and Claude request paths). Client history with adjacent user turns — or a tool-result turn (mapped to role:"user") immediately followed by a plain user turn — produced two adjacent role:"user" entries, which Gemini-family endpoints (incl. Antigravity / Vertex) reject with 400 INVALID_ARGUMENT "Request contains consecutive messages with the same role". The empty-parts half was already guarded (if parts.length > 0). Collapse adjacent same-role entries by concatenating their parts right after the message-conversion loop. Regression guard reproduces both the two-user and the tool-result-then-user cases and asserts a normal alternating conversation is unchanged. Reported-by: warelik (https://github.com/decolua/9router/issues/2191)