Gemini: Add config.yaml setting for thought signatures (#5025)

06691e8b9d933d11a779707d5fa42fa999ca1864

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
2 files changed, +5 -1Showing whitespace changes
default/config.yaml+2 -0
@@ -287,6 +287,8 @@ claude:
287gemini:287gemini:
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 requests294 # Use only when the prompt before the chat history is static and doesn't change between requests
src/prompt-converters.js+3 -1
@@ -31,6 +31,8 @@ const GEMINI_MEDIA_RESOLUTION = {
31 high: 'media_resolution_high',31 high: 'media_resolution_high',
32};32};
3333
34const enableThoughtSignatures = !!getConfigValue('gemini.thoughtSignatures', true, 'boolean');
35
34/**36/**
35 * @typedef {object} PromptNames37 * @typedef {object} PromptNames
36 * @property {string} charName Character name38 * @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;
575577
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 images582 // Gemini 3: Fall back to bypass magic for function calls (mandatory) and images