From 868eabffc03feed0d7cbc7483d06acdc0faf2228 Mon Sep 17 00:00:00 2001 From: Anurag Saxena Date: Thu, 26 Mar 2026 23:37:31 -0400 Subject: [PATCH] fix: clamp Responses API call_id to 64 chars (closes #393) (#396) --- open-sse/translator/request/openai-responses.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 }); }