@@ -25,10 +25,6 @@ const outputFile = getArg('--output')
2525const preset = getArg ( '--preset' )
2626const instructions = getArg ( '--instructions' )
2727
28- // List of models to try in order.
29- // The first model in the list is the primary model, and the rest are fallbacks.
30-
31- // UPDATED: Aligned with latest model recommendations (Q1 2026+)
3228const defaultFallbacks = [
3329 'gemini-3.1-flash-lite-preview' ,
3430 'gemini-2.5-flash' ,
@@ -314,6 +310,8 @@ async function main() {
314310 }
315311}
316312
313+ type ExtendedGenerateContentRequest = GenerateContentRequest & { thought_signature ?: string } ;
314+
317315export async function generateContentWithFallback ( {
318316 genAI,
319317 prompt,
@@ -330,14 +328,10 @@ export async function generateContentWithFallback({
330328 for ( const modelName of MODEL_FALLBACKS ) {
331329 try {
332330 const model = genAI . getGenerativeModel ( { model : modelName } )
333- const request : any = {
331+ const request : ExtendedGenerateContentRequest = {
334332 contents : [ { role : 'user' , parts : [ { text : prompt } ] } ] ,
335333 ...config ,
336- }
337-
338- // Implement thought signature circulation if provided
339- if ( thoughtSignature ) {
340- request . thought_signature = thoughtSignature
334+ ...( thoughtSignature && { thought_signature : thoughtSignature } )
341335 }
342336
343337 const result = await model . generateContent ( request )
@@ -346,11 +340,7 @@ export async function generateContentWithFallback({
346340 const text = result . response . text ( )
347341
348342 // Capture thought signature from the response if present
349- const candidate = result . response . candidates ?. [ 0 ]
350- const capturedSignature =
351- candidate && 'thought_signature' in candidate
352- ? ( candidate as any ) . thought_signature
353- : undefined
343+ const capturedSignature = ( result . response . candidates ?. [ 0 ] as any ) ?. thought_signature
354344
355345 return { text, thoughtSignature : capturedSignature }
356346 } catch ( error : unknown ) {
0 commit comments