googleapis / googleapis/python-genai

temperature=0.0 silently ignored from 2nd turn onward in multi-turn chat (falsy value treated as unset)

Open
#2,169 6 comments 0 reactions 1 assignee Claimed by @Venkaiahbabuneelam View on GitHub
priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

#### Environment details

- Programming language: Python 3.13
- OS: Windows 11
- Language runtime version: Python 3.13
- Package version: google-genai (latest as of March 2026)

#### Summary

In multi-turn chat, `temperature=0.0` works correctly on the first `send_message`
call, but from the 2nd turn onward it appears to be treated as "unset" (falsy),
causing the model to fall back to default temperature (1.0). Setting
`temperature=0.01` works correctly on all turns.

This is a critical issue for applications requiring deterministic output across a
full multi-turn session.

#### Steps to reproduce

1. Create a chat session with `GenerateContentConfig(temperature=0.0, seed=12345)`
2. First `send_message` — works as expected (deterministic output)
3. Second `send_message` with same config (`temperature=0.0`) — output becomes
non-deterministic, as if temperature is unset
4. Change to `temperature=0.01` on the 2nd turn — output becomes near-deterministic
again

#### Expected behavior

`temperature=0.0` should be respected on all turns, not just the first.

#### Actual behavior

`temperature=0.0` works on the 1st turn but is silently ignored from the 2nd turn
onward, likely due to falsy value handling (`0.0 == False` in Python). The model
falls back to default temperature, producing highly variable output.

#### Workaround

None. Even setting `temperature=0.01` as a workaround does not fully resolve the
issue — it still requires finding specific seed values that produce acceptable
results, and complete determinism is never guaranteed. We strongly request a fix for
this bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.