mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-11 22:55:59 +05:45
Gemini 3.x models return the thought signature of a text response on a
trailing empty text part. The executor records this as a signature-only
`.reasoning` transcript entry, which `GeminiTranscriptTranslator` then
round-tripped on the next turn as a stand-alone `Part` containing only
`thought` and `thoughtSignature` and no `data`.
The Gemini Developer API tolerates a part with no data, but the Gemini
Enterprise Agent Platform rejects it nondeterministically with
`400 INVALID_ARGUMENT` ("Request contains an invalid argument."),
making any multi-turn session that follows a completed text response
flaky on that backend (e.g. `sessionRespondSequentialToolCalls`).
Never emit a signature-only reasoning entry as a data-less part:
- A signature preceding a response is attached to the response's text
part.
- A signature following a response is attached to the last part of the
current model turn, mirroring how the server originally sent it.
- If there is no model part to attach to, fall back to a thought part
with empty text so the `data` oneof is always populated.
Replace the unit test that asserted the data-less shape with coverage
for all three cases.