-
-
Notifications
You must be signed in to change notification settings - Fork 108
fix(gemini): preserve thought signatures for Gemini 3.0 compatibility #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -271,6 +271,12 @@ export class GeminiTextAdapter< | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Capture thought signature for Gemini 3.0 compatibility | ||||||||||
| const metadata = | ||||||||||
| 'thoughtSignature' in part && part.thoughtSignature | ||||||||||
| ? { thoughtSignature: part.thoughtSignature } | ||||||||||
| : undefined | ||||||||||
|
Comment on lines
+274
to
+278
|
||||||||||
|
|
||||||||||
| yield { | ||||||||||
| type: 'tool_call', | ||||||||||
| id: generateId(this.name), | ||||||||||
|
|
@@ -283,6 +289,7 @@ export class GeminiTextAdapter< | |||||||||
| name: toolCallData.name, | ||||||||||
| arguments: toolCallData.args, | ||||||||||
| }, | ||||||||||
| metadata, | ||||||||||
| }, | ||||||||||
| index: toolCallData.index, | ||||||||||
| } | ||||||||||
|
|
@@ -323,6 +330,12 @@ export class GeminiTextAdapter< | |||||||||
| index: nextToolIndex++, | ||||||||||
| }) | ||||||||||
|
|
||||||||||
| // Capture thought signature for Gemini 3.0 compatibility | ||||||||||
| const metadata = | ||||||||||
| 'thoughtSignature' in part && part.thoughtSignature | ||||||||||
| ? { thoughtSignature: part.thoughtSignature } | ||||||||||
|
Comment on lines
+335
to
+336
|
||||||||||
| 'thoughtSignature' in part && part.thoughtSignature | |
| ? { thoughtSignature: part.thoughtSignature } | |
| 'thoughtSignature' in part && (part as any).thoughtSignature | |
| ? { thoughtSignature: (part as any).thoughtSignature } |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a type assertion to any to bypass TypeScript's type checking when assigning thoughtSignature. This makes the code less type-safe and harder to maintain. Consider defining a more specific type or interface that includes the thoughtSignature property, or use a type-safe approach to add the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code accesses
part.thoughtSignaturewithout a type assertion, which will cause a TypeScript compilation error ifthoughtSignatureis not a property of theParttype from@google/genai. While the runtime check using theinoperator is correct, TypeScript doesn't narrow the type based on this check. Consider using a type assertion like(part as any).thoughtSignatureconsistently, or define a type guard function that properly narrows the type.