Fix: File ID Format Mismatch When Switching from Gemini to OpenAI #3702
This commit addresses an issue where file IDs (or tool call IDs) originating from Gemini sessions were causing validation errors when switching to OpenAI models. OpenAI's API is stricter with ID formats (alphanumeric only) compared to Gemini. Changes: - Enable 'sanitizeToolCallIds' for OpenAI in src/agents/transcript-policy.ts. - Decouple tool call ID sanitization from the full sanitization mode check in src/agents/pi-embedded-helpers/images.ts to allow ID sanitization in 'images-only' mode. Fixes #3702 https://github.com/moltbot/moltbot/issues/3702
This commit is contained in:
parent
699784dbee
commit
77c38626d9
@ -45,7 +45,7 @@ export async function sanitizeSessionMessagesImages(
|
||||
// We sanitize historical session messages because Anthropic can reject a request
|
||||
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
||||
const sanitizedIds =
|
||||
allowNonImageSanitization && options?.sanitizeToolCallIds
|
||||
options?.sanitizeToolCallIds
|
||||
? sanitizeToolCallIdsForCloudCodeAssist(messages, options.toolCallIdMode)
|
||||
: messages;
|
||||
const out: AgentMessage[] = [];
|
||||
|
||||
@ -85,7 +85,7 @@ export function resolveTranscriptPolicy(params: {
|
||||
|
||||
const needsNonImageSanitize = isGoogle || isAnthropic || isMistral || isOpenRouterGemini;
|
||||
|
||||
const sanitizeToolCallIds = isGoogle || isMistral;
|
||||
const sanitizeToolCallIds = isGoogle || isMistral || isOpenAi;
|
||||
const toolCallIdMode: ToolCallIdMode | undefined = isMistral
|
||||
? "strict9"
|
||||
: sanitizeToolCallIds
|
||||
@ -99,7 +99,7 @@ export function resolveTranscriptPolicy(params: {
|
||||
|
||||
return {
|
||||
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
||||
sanitizeToolCallIds: !isOpenAi && sanitizeToolCallIds,
|
||||
sanitizeToolCallIds,
|
||||
toolCallIdMode,
|
||||
repairToolUseResultPairing: !isOpenAi && repairToolUseResultPairing,
|
||||
preserveSignatures: isAntigravityClaudeModel,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user