-
Notifications
You must be signed in to change notification settings - Fork 699
Description
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.
If the support paths suggested above still do not result in a resolution, please provide the following details.
Environment details
- Programming language: Python
- OS: macOS
- Language runtime version: Python 3.11
- Package version: Version: 1.36.0
Steps to reproduce
Steps to reproduce
Set up a Vertex AI client using the google-genai SDK pointing to us-central1
Configure a GenerateContentConfig with candidate_count > 1:
from google import genai
from google.genai import types
generate_config = types.GenerateContentConfig(
system_instruction=system_prompt,
temperature=0.2,
top_p=0.5,
top_k=40,
seed=42,
candidate_count=5, # Requesting 5 candidates
max_output_tokens=12000,
response_mime_type="text/plain",
thinking_config=types.ThinkingConfig(thinkingBudget=-1),
)Call generate_content with an image input (PNG document):
response = await client.aio.models.generate_content(
model="gemini-2.5-flash",
contents=[image_part, prompt],
config=generate_config,
)Check len(response.candidates) — intermittently returns fewer candidates than requested
The API returns fewer candidates than specified:
Prompt Type | Model | Requested | Returned
-- | -- | -- | --
one_prompt | gemini-2.5-flash | 5 | 3
twp_prompt | gemini-2.5-flash-lite | 3 | 1
three_prompt | gemini-2.5-flash | 5 | 5 ✓
Expected behavior
len(response.candidates) should equal the candidate_count value specified in the config (5 in this case).
Additional context
- All returned candidates have FinishReason.STOP, indicating successful completion