Gemini: Add config.yaml setting for thought signatures (#5025)
Signed| @@ -287,6 +287,8 @@ claude: | |||
| 287 | gemini: | 287 | gemini: |
| 288 | # API endpoint version ("v1beta" or "v1alpha") | 288 | # API endpoint version ("v1beta" or "v1alpha") |
| 289 | apiVersion: 'v1beta' | 289 | apiVersion: 'v1beta' |
| 290 | # Adds thought signatures to requests (if available). Only for Gemini 3 and above. | ||
| 291 | thoughtSignatures: true | ||
| 290 | # Enables caching of the system prompt (if supported). Only for OpenRouter. | 292 | # Enables caching of the system prompt (if supported). Only for OpenRouter. |
| 291 | # -- IMPORTANT! -- | 293 | # -- IMPORTANT! -- |
| 292 | # Use only when the prompt before the chat history is static and doesn't change between requests | 294 | # Use only when the prompt before the chat history is static and doesn't change between requests |
| @@ -31,6 +31,8 @@ const GEMINI_MEDIA_RESOLUTION = { | |||
| 31 | high: 'media_resolution_high', | 31 | high: 'media_resolution_high', |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | const enableThoughtSignatures = !!getConfigValue('gemini.thoughtSignatures', true, 'boolean'); | ||
| 35 | |||
| 34 | /** | 36 | /** |
| 35 | * @typedef {object} PromptNames | 37 | * @typedef {object} PromptNames |
| 36 | * @property {string} charName Character name | 38 | * @property {string} charName Character name |
| @@ -574,7 +576,7 @@ export function convertGooglePrompt(messages, model, useSysPrompt, names) { | |||
| 574 | const textSignature = message.signature; | 576 | const textSignature = message.signature; |
| 575 | 577 | ||
| 576 | parts.forEach((part) => { | 578 | parts.forEach((part) => { |
| 577 | if (textSignature && typeof part.text === 'string') { | 579 | if (enableThoughtSignatures && textSignature && typeof part.text === 'string') { |
| 578 | part.thoughtSignature = textSignature; | 580 | part.thoughtSignature = textSignature; |
| 579 | } else if (/gemini-3/.test(model)) { | 581 | } else if (/gemini-3/.test(model)) { |
| 580 | // Gemini 3: Fall back to bypass magic for function calls (mandatory) and images | 582 | // Gemini 3: Fall back to bypass magic for function calls (mandatory) and images |