fix: clamp Responses API call_id to 64 chars (closes #393) (#396)

This commit is contained in:
Anurag Saxena
2026-03-26 23:37:31 -04:00
committed by GitHub
parent 8759545260
commit 868eabffc0

View File

@@ -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
});
}