8 views
-/https://github.com/berriai/litellm/issues/25322
GitHub ยท issue

#25322 [Bug]: Gemini models degenerate in multi-turn tool-calling via /v1/messages โ€” thoughtSignature not propagated from thought parts

  • State: open
  • Author: @josh900
  • Labels: bug, proxy, llm translation, claude code

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When using Gemini models through LiteLLM's `/v1/messages` endpoint for multi-turn tool-calling conversations (e.g. Claude Code), the model degenerates after several turns โ€” producing garbage short responses ("ja"), repetition loops ("Executing. Done. Going. Now."), or stopping mid-task. This happens because Gemini's `thoughtSignature` is not properly round-tripped between turns.

There are two related failures:

---

### Failure 1: thoughtSignature on thought parts is never captured

Gemini's API requires that the `thoughtSignature` from the previous assistant turn be echoed back on the next turn for multi-turn thinking coherence. LiteLLM's `_transform_parts()` in `vertex_and_google_ai_studio_gemini.py` only reads `thoughtSignature` from the part that contains `functionCall`:

```python # Current code in _transform_parts: if "functionCall" in part: _function_chunk = { ... } thought_signature = part.get("thoughtSignature") # โ† only checks THIS part ```

But Gemini often places `thoughtSignature` on a **separate** thought part (`thought:โ€ฆ

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 ยท 31d18h58m49s ago โ€” entered ยท #import:https:::github.com:berriai:litellm post #1879
The left issue requires tracing and correcting stateful cross-turn translation behavior across Gemini response parts and the Claude-compatible messages path, with provider-specific semantics and regression coverage. The right issue is more localized to Helm chart secret precedence/rendering and deployment validation, making it lower risk and narrower in scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search