Skip to content

Conversation

@markpollack
Copy link
Member

Summary

  • Add thought signature support required by Gemini 3 Pro when using function calling with includeThoughts enabled
  • Attach thought signatures to functionCall parts per Google specification (not to text parts)
  • Clarify in documentation that validation applies only to the current turn's function calling loop, not historical messages
  • Add integration tests validating sequential function calls with signatures for both Gemini 2.5 and Gemini 3 Pro

Key Behaviors

  • Signatures are extracted from model responses and stored in message metadata
  • During internal tool execution, signatures are correctly attached to functionCall parts
  • Handles both parallel and sequential function calls correctly
  • Previous turn signatures in conversation history are not validated by the API

Documentation

  • Added "Thought Signatures" section explaining when signatures matter
  • Added "Manual Tool Execution Mode" section for users who set internalToolExecutionEnabled=false

Test Plan

  • Integration tests pass for Gemini 2.5 Flash and Gemini 3 Pro

See: https://ai.google.dev/gemini-api/docs/thought-signatures

Signed-off-by: Dan Dobrin [email protected]
Signed-off-by: Mark Pollack [email protected]

…ion calling

Add thought signature support required by Gemini 3 Pro when using function
calling with includeThoughts enabled. Thought signatures preserve reasoning
context during the internal tool execution loop.

Changes from original implementation:
- Attach thought signatures to functionCall parts per Google specification
  (not to text parts or separate empty parts)
- Clarify in documentation that validation applies only to the current turn's
  function calling loop, not to historical conversation messages
- Add integration tests validating function calls with signatures

Key behaviors:
- Signatures are extracted from model responses and stored in message metadata
- During internal tool execution, signatures are correctly attached to
  functionCall parts when sending back function responses
- Handles both parallel and sequential function calls correctly:
  - Parallel: only first functionCall gets the signature (per API spec)
  - Sequential: each step's first functionCall gets its signature
- Previous turn signatures in conversation history are not validated by the API

See: https://ai.google.dev/gemini-api/docs/thought-signatures

Signed-off-by: Dan Dobrin <[email protected]>
Signed-off-by: Mark Pollack <[email protected]>
@markpollack
Copy link
Member Author

@ddobrin please review.

@ddobrin
Copy link
Contributor

ddobrin commented Nov 26, 2025

Looks good @markpollack

Copy link

@ayushHardeniya ayushHardeniya left a comment

Choose a reason for hiding this comment

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

Seems good. @markpollack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants