Agents: sanitize OpenRouter Gemini thoughtSignature

This commit is contained in:
Matthieu Bizien
2026-01-13 12:25:52 +01:00
committed by Peter Steinberger
parent d42b69df74
commit ef36e24522
11 changed files with 4156 additions and 86 deletions

View File

@@ -23,6 +23,7 @@ export { sanitizeGoogleTurnOrdering };
type GeminiToolCallBlock = {
type?: unknown;
thought_signature?: unknown;
thoughtSignature?: unknown;
id?: unknown;
toolCallId?: unknown;
name?: unknown;
@@ -118,7 +119,8 @@ export function downgradeGeminiHistory(messages: AgentMessage[]): AgentMessage[]
const blockRecord = block as GeminiToolCallBlock;
const type = blockRecord.type;
if (type === "toolCall" || type === "functionCall" || type === "toolUse") {
const hasSignature = Boolean(blockRecord.thought_signature);
const signature = blockRecord.thought_signature ?? blockRecord.thoughtSignature;
const hasSignature = Boolean(signature);
if (!hasSignature) {
const id =
typeof blockRecord.id === "string"