Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: pure passthrough for Claude→Claude when cache_control preserved

tombii892830e1250f
diff --git a/open-sse/handlers/chatCore.ts b/open-sse/handlers/chatCore.ts
index eea24efe4f..ecd3460d80 100644
--- a/open-sse/handlers/chatCore.ts
+++ b/open-sse/handlers/chatCore.ts
@@ -712,6 +712,15 @@ export async function handleChatCore({
if (nativeCodexPassthrough) {
translatedBody = { ...body, _nativeCodexPassthrough: true };
log?.debug?.("FORMAT", "native codex passthrough enabled");
+ } else if (isClaudePassthrough && preserveCacheControl) {
+ // Pure passthrough: when preserveCacheControl is true, forward the body
+ // as-is without any normalization. The OpenAI round-trip would strip
+ // cache_control markers; even prepareClaudeRequest can alter structure.
+ // Claude Code sends well-formed Messages API payloads — trust it.
+ translatedBody = { ...body };
+ translatedBody._disableToolPrefix = true;
+
+ log?.debug?.("FORMAT", "claude passthrough with cache_control preservation");
} else if (isClaudePassthrough) {
// Claude OAuth expects the same Claude Code prompt + structural normalization
// as the OpenAI-compatible chat path. Round-trip through OpenAI to reuse the