From 6ff7b6570c45d6d77b0812b1506fd618c9c8fb9b Mon Sep 17 00:00:00 2001 From: Prakersh Maheshwari Date: Tue, 17 Mar 2026 02:03:45 +0530 Subject: [PATCH 1/2] fix(sse): add Claude-to-Claude passthrough for anthropic-compatible providers When both source and target formats are Claude, skip all request modification and forward the body untouched. This prevents prepareClaudeRequest from corrupting valid Claude-native requests destined for anthropic-compatible provider nodes. --- open-sse/handlers/chatCore.ts | 7 +++++++ open-sse/translator/index.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.ts index 1919add060..666ba975b0 100644 --- a/open-sse/handlers/chatCore.ts +++ b/open-sse/handlers/chatCore.ts @@ -182,10 +182,17 @@ export async function handleChatCore({ // Translate request (pass reqLogger for intermediate logging) let translatedBody = body; + const isClaudePassthrough = sourceFormat === FORMATS.CLAUDE && targetFormat === FORMATS.CLAUDE; try { if (nativeCodexPassthrough) { translatedBody = { ...body, _nativeCodexPassthrough: true }; log?.debug?.("FORMAT", "native codex passthrough enabled"); + } else if (isClaudePassthrough) { + // Claude-to-Claude passthrough: forward body completely untouched. + // No translation, no field stripping, no thinking normalization. + // We are just a gateway -- do not interfere with the request in any way. + translatedBody = body; + log?.debug?.("FORMAT", "claude->claude passthrough -- forwarding untouched"); } else { translatedBody = { ...body }; diff --git a/open-sse/translator/index.ts b/open-sse/translator/index.ts index ce3f353f60..5b75f54685 100644 --- a/open-sse/translator/index.ts +++ b/open-sse/translator/index.ts @@ -131,7 +131,7 @@ export function translateRequest( } // Final step: prepare request for Claude format endpoints - if (targetFormat === FORMATS.CLAUDE) { + if (targetFormat === FORMATS.CLAUDE && sourceFormat !== FORMATS.CLAUDE) { result = prepareClaudeRequest(result, provider); } From 1bdabf43db9e6aac726ead252ae87d63cf8f6ad1 Mon Sep 17 00:00:00 2001 From: Prakersh Maheshwari Date: Tue, 17 Mar 2026 02:45:21 +0530 Subject: [PATCH 2/2] fix: prevent mutation of original request body in Claude passthrough Use shallow copy ({ ...body }) instead of direct reference assignment so that later translatedBody.model = model does not mutate the caller's original body object. --- open-sse/handlers/chatCore.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.ts index 666ba975b0..671c773a06 100644 --- a/open-sse/handlers/chatCore.ts +++ b/open-sse/handlers/chatCore.ts @@ -53,7 +53,9 @@ export function shouldUseNativeCodexPassthrough({ }): boolean { if (provider !== "codex") return false; if (sourceFormat !== FORMATS.OPENAI_RESPONSES) return false; - return String(endpointPath || "").toLowerCase().endsWith("/responses"); + return String(endpointPath || "") + .toLowerCase() + .endsWith("/responses"); } /** @@ -191,7 +193,7 @@ export async function handleChatCore({ // Claude-to-Claude passthrough: forward body completely untouched. // No translation, no field stripping, no thinking normalization. // We are just a gateway -- do not interfere with the request in any way. - translatedBody = body; + translatedBody = { ...body }; log?.debug?.("FORMAT", "claude->claude passthrough -- forwarding untouched"); } else { translatedBody = { ...body };