Skip to content

Conversation

@tomc98
Copy link
Contributor

@tomc98 tomc98 commented Dec 18, 2025

Summary

Gemini 3+ models require thought signatures to be preserved and returned when using function calling with thinking mode enabled. Without this fix, the API returns a 400 error:

Function call is missing a thought_signature in functionCall parts. 
This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance.

Changes

  • Add thoughtSignature optional field to FunctionCall class
  • Capture thoughtSignature from Gemini API response in Google plugin's #parsePart method
  • Include thoughtSignature when converting chat context back to Google format
  • Update isEquivalent to compare thoughtSignature for function calls

Models affected

This fix enables compatibility with:

  • gemini-3-flash-preview
  • gemini-3-flash-lite-preview
  • gemini-3-pro-preview

References

Test plan

  • Build passes
  • Existing tests pass (failures are due to missing API keys, not code changes)
  • Lint passes

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 3043ebf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@livekit/agents-plugin-google Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tomc98
Copy link
Contributor Author

tomc98 commented Dec 18, 2025

I also made an issue here #920

@tomc98
Copy link
Contributor Author

tomc98 commented Dec 18, 2025

Wait, I've got a few issues, do not merge

- Add thoughtSignature field to FunctionCall class in chat_context.ts
- Capture thoughtSignature from API response in google plugin llm.ts
- Include thoughtSignature when converting back to Google format
- Preserve thoughtSignature in voice/generation.ts when recreating FunctionCall
- Update @google/genai to v1.34.0 for thoughtSignature support
@tomc98 tomc98 force-pushed the fix/thought-signature-function-calling branch from b99fa73 to 80138a6 Compare December 18, 2025 03:51
@tomc98
Copy link
Contributor Author

tomc98 commented Dec 18, 2025

Ok ready for review :D

@tomc98 tomc98 marked this pull request as draft December 22, 2025 00:17
@tomc98 tomc98 marked this pull request as ready for review December 22, 2025 00:17
@tomc98
Copy link
Contributor Author

tomc98 commented Dec 31, 2025

@toubatbrian Could you please review, not having this is blocking me

@tomc98
Copy link
Contributor Author

tomc98 commented Dec 31, 2025

Also do I need a changeset?

Copy link
Contributor

@toubatbrian toubatbrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG to me!

@toubatbrian
Copy link
Contributor

toubatbrian commented Dec 31, 2025

Hey @tomc98 thanks for the PR! I'm currently OOO and review might be slower. Please add a patch changeset on google plugin, thanks!

Also, could you run the agent with current changes using gemini model and see if the voice interaction works as usual? Just to make sure no regression is introduced.

@tomc98
Copy link
Contributor Author

tomc98 commented Jan 5, 2026

Tested for realtime regressions using examples/src/gemini_realtime_agent.ts - voice interaction works as expected with the current changes.

Note: I had to update the model to models/gemini-2.5-flash-native-audio-preview-12-2025 as the default model (gemini-2.0-flash-live-001) was not working. The default model in the realtime plugin should probably be updated in a separate PR.

@tomc98
Copy link
Contributor Author

tomc98 commented Jan 5, 2026

@toubatbrian It's ready, finished everything you needed 👍

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