diff --git a/open-sse/translator/request/openai-responses.js b/open-sse/translator/request/openai-responses.js index 8067c8fc..3468ac8b 100644 --- a/open-sse/translator/request/openai-responses.js +++ b/open-sse/translator/request/openai-responses.js @@ -8,6 +8,10 @@ import { register } from "../index.js"; import { FORMATS } from "../formats.js"; import { normalizeResponsesInput } from "../helpers/responsesApiHelper.js"; +// Responses API enforces max 64 chars on call_id (#393) +const MAX_CALL_ID_LEN = 64; +const clampCallId = (id) => (typeof id === "string" && id.length > MAX_CALL_ID_LEN ? id.substring(0, MAX_CALL_ID_LEN) : id); + /** * Convert OpenAI Responses API request to OpenAI Chat Completions format */ @@ -221,7 +225,7 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials) for (const tc of msg.tool_calls) { result.input.push({ type: "function_call", - call_id: tc.id, + call_id: clampCallId(tc.id), name: tc.function?.name || "", arguments: tc.function?.arguments || "{}" }); @@ -237,7 +241,7 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials) : JSON.stringify(msg.content); result.input.push({ type: "function_call_output", - call_id: msg.tool_call_id, + call_id: clampCallId(msg.tool_call_id), output }); }