fix(gemini): forward seed on native generateContent requests

Merged
PC
3d ago
+76-0

Description

On Gemini and Vertex in native mode, a request's seed was silently dropped: geminiGenerationConfig never read it, so the call succeeded without the requested reproducibility.

seed is now sent as generationConfig.seed, which both the Gemini API (v1beta) and Vertex AI (v1) schemas define. It is forwarded for all models, including Gemini 3 and later: the sampling parameters dropped for those (temperature, topP, topK, candidateCount) do not include it. openai_compatible mode is unchanged and still drops seed, since that endpoint rejects it.

A table test in native_sampling_test.go covers Gemini 2.5, Gemini 3 and Gemma; it fails without the change. The gemini and vertex package tests and go vet pass. Not run against the live Google APIs.

AI Generated (optional)

This change was prepared with AI assistance.

Summary by CodeRabbit

  • New Features
    • Gemini 2.5 Flash, Gemini 3.8 Flash, and Gemma 4 31B now support integer seeds during generation. Seeds may be provided as numbers or numeric strings, including integral decimal or exponent forms, as long as they fall within the supported range. Missing, malformed, fractional, or out-of-range values are ignored, so they won’t be applied to generation.