Skip to content

Restore persisted thought signatures in GoogleGenAiChatModel#6611

Open
ultramancode wants to merge 1 commit into
spring-projects:mainfrom
ultramancode:fix/google-genai-persisted-thought-signatures
Open

Restore persisted thought signatures in GoogleGenAiChatModel#6611
ultramancode wants to merge 1 commit into
spring-projects:mainfrom
ultramancode:fix/google-genai-persisted-thought-signatures

Conversation

@ultramancode

Copy link
Copy Markdown
Contributor

GoogleGenAiChatModel stores Gemini thought signatures in assistant-message metadata as List<byte[]> and reattaches them when constructing subsequent function-call requests.

Gemini requires function-calling thought signatures to be returned exactly as received so that reasoning context is preserved across requests.

When this metadata is serialized to JSON and deserialized as Object, the Java byte[] type is not preserved.

Gson reads JSON arrays as List values with Double elements, and RedisChatMemoryRepository uses this serialization path.

Consequently, a persisted signature has this shape after it is loaded:

List<byte[]>
    -> JSON
    -> List<List<Double>>

The existing request conversion verifies only that the metadata value is a List, not that its elements are byte[].

When the signature is attached to the next function-call part, the inner numeric list is cast to byte[], causing a ClassCastException before the request reaches Gemini.

To reproduce the failure:

  1. Create or receive a Google GenAI AssistantMessage containing a function call and a thoughtSignatures metadata value.
  2. Persist and reload the message with RedisChatMemoryRepository.
  3. Send another Google GenAI request using the conversation history loaded from Redis.
  4. Observe a ClassCastException while GoogleGenAiChatModel constructs the request.

Signed-off-by: Taewoong Kim <ktw2172@gmail.com>
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.

2 participants