test: add Gemini thoughtSignature metadata preservation tests#6368
Open
peterkc wants to merge 1 commit intoKilo-Org:mainfrom
Open
test: add Gemini thoughtSignature metadata preservation tests#6368peterkc wants to merge 1 commit intoKilo-Org:mainfrom
peterkc wants to merge 1 commit intoKilo-Org:mainfrom
Conversation
Add regression tests verifying that providerMetadata containing thoughtSignature is preserved through toModelMessages() for same-model Gemini sessions. Covers tool-call and reasoning parts. Includes Gemini 3.1 Pro model fixture and thoughtSignature metadata constant for future test use. Refs: Kilo-Org#6018 AI-assisted: intent and review human-driven Co-Authored-By: Claude <noreply@anthropic.com>
d1c7bfe to
c72a8ac
Compare
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
|
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.
Context
While investigating #6018 (Gemini 3.1 Pro
thought_signatureerrors on v5.8.0), I traced the full message pipeline to understand wherethoughtSignaturemetadata could be lost. The pipeline works correctly on currentmain— the v5.9.0 fix ("preserve extra_content for Gemini 3 thought_signature support") resolves the issue.However, the
differentModelguard inmessage-v2.ts(line 600) — which strips provider-specific metadata when models differ — had zero test coverage for the positive case (same-model metadata preservation). These tests fill that gap to prevent regression.Refs: #6018, diagnostic analysis
Implementation
No production code changes. Test-only PR adding regression coverage to
message-v2.test.ts:geminiModel): AProvider.Modelmatching the existing test mock pattern, withproviderID: "google",id: "gemini-3.1-pro-preview",npm: "@ai-sdk/google"geminiThoughtSignature):{ google: { thoughtSignature: "opaque-test-sig==" } }— the shape@ai-sdk/googleemits viaproviderMetadatacallProviderMetadatawiththoughtSignatureis preserved on tool-call parts whendifferentModelevaluatesfalseproviderMetadatawiththoughtSignatureis preserved on reasoning partsBoth tests use the existing
assistantInfo()helper with itsmetaparameter to set matchingproviderID/modelID, ensuring thedifferentModelguard evaluates correctly.Data Flow Under Test
The
differentModelguard atmessage-v2.ts:600controls metadata flow:Test Matrix
differentModelcallProviderMetadatapreservedproviderMetadatapreservedproviderMetadatapreservedcallProviderMetadatapreservedRows 1-3 are covered by this PR. Rows 4-6 are natural follow-ups if the team wants broader coverage.
How to Test
differentModelregression test (line 358) continues to passAdditionally verified via E2E test against live
gemini-3.1-pro-previewAPI —thoughtSignatureflows through all streaming events (tool-input-start,tool-call,tool-result) and appears in response messageproviderOptions.Get in Touch
Happy to iterate on these tests or expand coverage (rows 4-6 in the matrix). Available here on GitHub.