Skip to content

Preserve Gemini thought signatures through streamed tool calls - #206

Merged
fanny-riols merged 2 commits into
mainfrom
pr/gemini-audio-native
Aug 18, 2026
Merged

Preserve Gemini thought signatures through streamed tool calls#206
fanny-riols merged 2 commits into
mainfrom
pr/gemini-audio-native

Conversation

@fanny-riols

Copy link
Copy Markdown
Collaborator

ALMGeminiClient hits Gemini's raw OpenAI-compatible endpoint directly, where multi-turn thought signatures ride under extra_content.google on each tool_call. litellm.stream_chunk_builder's tool-call merge (used by _assemble_stream_chunks when streaming the LLM response) only knows how to carry over id/type/function/provider_specific_fields, so it silently dropped extra_content when reassembling streamed chunks -- causing Gemini 3.x audio-native models to fail on the next turn with "Function call is missing a thought_signature".

Add _merge_streamed_tool_call_extras to alm_base.py: rebuilds tool_calls from the raw stream chunks, preserving any key litellm's merge doesn't recognize, and is a no-op when no such extra keys are present (e.g. for vLLM-hosted models). Also update system.py's thought-signature log check to recognize extra_content alongside CASCADE's provider_specific_fields.

ALMGeminiClient hits Gemini's raw OpenAI-compatible endpoint directly,
where multi-turn thought signatures ride under extra_content.google on
each tool_call. litellm.stream_chunk_builder's tool-call merge (used by
_assemble_stream_chunks for the streaming path) only knows how to carry
over id/type/function/provider_specific_fields, so it silently dropped
extra_content when reassembling streamed chunks -- causing Gemini 3.x
audio-native models to fail on the next turn with "Function call is
missing a thought_signature".

Add _merge_streamed_tool_call_extras to alm_base.py: rebuilds tool_calls
from the raw stream chunks, preserving any key litellm's merge doesn't
recognize, and is a no-op when no such extra keys are present (e.g. for
vLLM-hosted models). Also update system.py's thought-signature log check
to recognize extra_content alongside CASCADE's provider_specific_fields.
@fanny-riols
fanny-riols marked this pull request as ready for review August 13, 2026 14:56
@fanny-riols
fanny-riols added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit e662d07 Aug 18, 2026
2 checks passed
@fanny-riols
fanny-riols deleted the pr/gemini-audio-native branch August 18, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants