fix(gemini): cap stop sequences at five entries

Merged
PC
12d ago
+78-3

The native Gemini path copied a client stop list into generationConfig.stopSequences without a limit. Gemini accepts at most five entries and rejects longer lists with HTTP 400, while other providers (OpenAI, Azure, Groq) already truncate through CapStopSequences.

copyStopSequences now truncates the list to five entries (new maxStopSequences constant in the gemini package). A bare string and lists within the limit are unchanged.

Test: TestGeminiGenerationConfig_CapsStopSequences (fails on main with a 7-entry list, passes with the fix).

Summary by CodeRabbit

  • Bug Fixes
    • Gemini native generation and OpenAI-compatible chat requests now limit stop sequences to five entries. Longer lists are truncated to their first five entries, while lists of five or fewer and single-string stop values retain their existing behavior.