Gemini 3's trailing thought-signature chunk becomes a Part with no data field when the history is sent back; Vertex intermittently rejects it with 400 INVALID_ARGUMENT
Describe the bug
When a Gemini 3 model streams a text answer, the last chunk carries only the thought signature:
chunk 5: finishReason=STOP parts=[{"text": "", "thoughtSignature": "AY89a1/ouPO6D7hq…"}]streamingResponseAggregator keeps that chunk as its own Part (internal/llminternal/stream_aggregator.go:119-124), so the stored model content is [{text: "…"}, {text: "", thoughtSignature: …}]. In memory that matches what the Vertex docs ask for: the signature stays "inside its original Part".
The loss happens one layer down. genai.Part.Text is json:"text,omitempty", so when the history goes out on the next request the second Part is serialised as {"thoughtSignature": …} with no data field at all. Vertex rejects that intermittently:
Error 400, Message: Request contains an invalid argument., Status: INVALID_ARGUMENT, Details: []Same bytes, sent repeatedly: accepted most of the time, rejected 10–40 % of the time depending on the hour. Every request after a completed text answer carries the history, so mid-turn tool rounds fail too.
To reproduce
llmagentwith a Gemini 3 model (observed ongemini-3.8-flash, Vertex AI backend, locationeu),StreamingModeSSE, thinking enabled at any level.- Turn 1: any prompt answered with text. The persisted model content has a text Part and a second Part holding only
ThoughtSignature. - Turn 2: any follow-up, repeated on the same session. Some requests fail with the 400 above before any content is streamed.
Evidence (39 real multi-turn sessions replayed against Vertex via REST, identical bytes per variant)
| history as sent | requests | 400 |
|---|---|---|
| as ADK sends it (Part with signature only) | 585 | 86 |
| same, signature-only Part removed | 390 | 0 |
same, Part sent as {"text": "", "thoughtSignature": …} |
55 | 0 |
The third row is what adk-python sends: its aggregator behaves the same way, but Pydantic serialises text: "", so Python users never see the 400.
Expected behavior
The root cause is that genai.Part cannot represent "text present but empty", filed as googleapis/go-genai#931. Until that is fixed, ADK Go is the layer that knows the Part will not survive serialisation. Options: carry the trailing signature into the text Part the aggregator is already assembling, or give the empty Part some representable content. Either would stop the SDK from sending a Part with no data.
Versions
adk-go v1.3.0; aggregator unchanged in v1.7.0, v2.2.0 and v2.4.0. genai v1.57.0, omitempty unchanged in v1.66.0. Go 1.26. Related: #758, #656.
Workaround
A BeforeModelCallback that removes any Part carrying only ThoughtSignature from req.Contents. 0 rejections in 431 requests, at the cost of the text answer's reasoning context, which the docs describe as optional.
Source: google/adk-go