Implicit Context Caching stops working when a thinking budget is set – metadata.cached_token becomes None

Hi

I’m seeing unexpected behavior when combining Gemini’s implicit context caching with the thinking budget parameter and would like to confirm whether this is intentional or a bug.

response = self.client.models.generate_content_stream(
model=self.model,
contents=conv,
config=types.GenerateContentConfig(
# cached_content=cache_info[“cache_id”] if cache_info else None,
temperature=request.temperature or self.temperature,
max_output_tokens=(request.max_tokens) if request.max_tokens else self.max_tokens,
thinking_config=types.ThinkingConfig(include_thoughts=True, thinking_budget=thinking_budget) if thinking_budget else None,
**self.default_params,
)
)

Hi @user2302 ,

Welcome to the Forum.
Could you please let us know which Gemini model you are using?