You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Gemini chat client silently drops all but the first candidate when candidate_count > 1 #9928
candidate_count is not declared anywhere in the client; it reaches the API through the generic option passthrough in _prepare_config (kwargs[_OPTION_TRANSLATIONS.get(key, key)] = value), so options={"candidate_count": 2} is a valid, billable request whose response is then truncated to candidate 0 — with finish reasons and usage also attributed to candidate 0 alone, and no warning or error.
Repro
fromagent_framework_geminiimportGeminiChatClientclient=GeminiChatClient(model="gemini-2.5-flash")
# behind the scenes: config = client._prepare_config({"candidate_count": 2}, None)# -> GenerateContentConfig(candidate_count=2) is sent, but any response is parsed as# response.candidates[0] only; candidates[1:] never surface.
Expected
The client already has a precedent for provider options it cannot honor faithfully: the Ollama chat client rejects unsupported tool_choice modes with ChatClientInvalidRequestException "instead of silently behaving like 'auto'" (python/packages/ollama/agent_framework_ollama/_chat_client.py). Multi-candidate responses deserve the same explicit rejection at request build time (or full multi-candidate support), not silent truncation.
changed the title [-]Gemini chat client silently drops all but the first candidate when candidate_count > 1[/-][+]Python: Gemini chat client silently drops all but the first candidate when candidate_count > 1[/+]on Nov 1, 2026
Thanks for reporting this. Preventing silent loss of requested Gemini output is in scope for MAF, and the team will consider a core change. This is not a commitment to implementation or timing, or approval of a particular multi-candidate API. We will first plan the bounded early-rejection approach proposed in #9929, including compatibility with documented provider-option passthrough and streaming behavior. Please coordinate work through that existing PR rather than starting a parallel implementation.
/plan Plan explicit safe handling of Gemini candidate_count without introducing a multi-candidate response API. Evaluate bounded early rejection of requests the current single-candidate abstraction cannot honor, as proposed in #9929. Verify real google-genai request/response semantics and the compatibility impact on documented generic-option passthrough; distinguish normal omitted/None/one values from unsupported multiple candidates and malformed values, preserving SDK/framework error boundaries. Cover streaming and non-streaming paths, prevention of provider calls on rejected requests, finish/usage semantics, and supported model/backend differences where material. Coordinate the existing #9929 implementation and focused tests; do not create a parallel fix. Keep the issue in triage while this contract is being planned.
Activity
[-]Gemini chat client silently drops all but the first candidate when candidate_count > 1[/-][+]Python: Gemini chat client silently drops all but the first candidate when candidate_count > 1[/+]eavanvalkenburg commentedon Nov 2, 2026
Thanks for reporting this. Preventing silent loss of requested Gemini output is in scope for MAF, and the team will consider a core change. This is not a commitment to implementation or timing, or approval of a particular multi-candidate API. We will first plan the bounded early-rejection approach proposed in #9929, including compatibility with documented provider-option passthrough and streaming behavior. Please coordinate work through that existing PR rather than starting a parallel implementation.
eavanvalkenburg commentedon Nov 2, 2026
/plan Plan explicit safe handling of Gemini candidate_count without introducing a multi-candidate response API. Evaluate bounded early rejection of requests the current single-candidate abstraction cannot honor, as proposed in #9929. Verify real google-genai request/response semantics and the compatibility impact on documented generic-option passthrough; distinguish normal omitted/None/one values from unsupported multiple candidates and malformed values, preserving SDK/framework error boundaries. Cover streaming and non-streaming paths, prevention of provider calls on rejected requests, finish/usage semantics, and supported model/backend differences where material. Coordinate the existing #9929 implementation and focused tests; do not create a parallel fix. Keep the issue in triage while this contract is being planned.
Reject Gemini candidate_count other than 1, including zero (microsoft…