File tree Expand file tree Collapse file tree 2 files changed +8
-22
lines changed
Expand file tree Collapse file tree 2 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { loadPrompt } from "../prompts"
66import {
77 extractParameterKey ,
88 buildToolIdList ,
9- createSyntheticAssistantMessageWithToolPart ,
9+ createSyntheticAssistantMessage ,
1010 isIgnoredUserMessage ,
1111} from "./utils"
1212import { getFilePathFromParameters , isProtectedFilePath } from "../protected-file-patterns"
@@ -149,7 +149,5 @@ export const insertPruneToolContext = (
149149
150150 const userInfo = lastUserMessage . info as UserMessage
151151 const variant = state . variant ?? userInfo . variant
152- messages . push (
153- createSyntheticAssistantMessageWithToolPart ( lastUserMessage , prunableToolsContent , variant ) ,
154- )
152+ messages . push ( createSyntheticAssistantMessage ( lastUserMessage , prunableToolsContent , variant ) )
155153}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const isGeminiModel = (modelID: string): boolean => {
1212 return lowerModelID . includes ( "gemini" )
1313}
1414
15- export const createSyntheticAssistantMessageWithToolPart = (
15+ export const createSyntheticAssistantMessage = (
1616 baseMessage : WithParts ,
1717 content : string ,
1818 variant ?: string ,
@@ -39,24 +39,11 @@ export const createSyntheticAssistantMessageWithToolPart = (
3939 ...( variant !== undefined && { variant } ) ,
4040 }
4141
42- // For Gemini models, inject as text to avoid thought signature requirements
43- // Gemini 3+ has strict validation requiring thoughtSignature on functionCall parts
44- if ( isGeminiModel ( userInfo . model . modelID ) ) {
45- return {
46- info : baseInfo ,
47- parts : [
48- {
49- id : SYNTHETIC_PART_ID ,
50- sessionID : userInfo . sessionID ,
51- messageID : SYNTHETIC_MESSAGE_ID ,
52- type : "text" ,
53- text : content ,
54- } ,
55- ] ,
56- }
57- }
42+ // For Gemini models, add thoughtSignature bypass to avoid validation errors
43+ const toolPartMetadata = isGeminiModel ( userInfo . model . modelID )
44+ ? { google : { thoughtSignature : "skip_thought_signature_validator" } }
45+ : undefined
5846
59- // For other models, use tool part for cleaner context
6047 return {
6148 info : baseInfo ,
6249 parts : [
@@ -75,6 +62,7 @@ export const createSyntheticAssistantMessageWithToolPart = (
7562 metadata : { } ,
7663 time : { start : now , end : now } ,
7764 } ,
65+ ...( toolPartMetadata && { metadata : toolPartMetadata } ) ,
7866 } ,
7967 ] ,
8068 }
You can’t perform that action at this time.
0 commit comments