[Chat] Preserve a ToolCall's signature across the MessageNormalizer round trip - #2533
Merged
wachterjohannes merged 1 commit intoSep 23, 2026
Conversation
wachterjohannes
approved these changes
Sep 23, 2026
wachterjohannes
left a comment
Member
There was a problem hiding this comment.
Confirms signature now round-trips through both the ToolCallMessage and parts-based AssistantMessage denormalize paths, matching the existing normalize side. Verified locally, all green.
Member
|
Thank you @RomainLvr. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MessageNormalizerloses aToolCall's signature on the round trip: it is neither written on normalization nor restored on denormalization. The same class already round-tripsThinking::getSignature(), so tool calls were simply missed.This is not cosmetic for Gemini. It attaches a
thoughtSignatureto everyfunctionCallit emits and rejects the whole request with HTTP 400 when a stored conversation is replayed without it:The signature survives everywhere else along the path —
Bridge/Gemini'sResultConverterreads it into theToolCall, and itsAssistantMessageNormalizerwrites it back out asthoughtSignature— so anyMessageStoreInterfacebuilt on this normalizer breaks tool calling with Gemini as soon as a conversation is persisted and resumed.The fix mirrors what the class already does for
Thinking, in the two places aToolCallis stored:AssistantMessageparts, which already carry aMessageNormalizer-owned envelope around the normalized tool call, so the signature goes next to it;ToolCallMessage, where the signature is added as a sibling key on the normalized payload, and only when there is one.It deliberately does not touch
Platform\Contract\Normalizer\Result\ToolCallNormalizer:Contractregistersit by default for outgoing request payloads, so a new key there would leak into OpenAI- and Mistral-style request bodies.
MessageNormalizeris persistence-only, which makes it the right place.The legacy
content + toolsCallsdenormalization fallback is left alone: data stored in that format predates signatures, so there is never one to restore.Existing round-trip tests are unaffected, and one of them now also asserts that an unsigned tool call stays unsigned.