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(sse): remove dead-code flag leak in claudeCodeToolRemapper

Mrinal Joshifa1d1fe7eb4b
diff --git a/open-sse/services/claudeCodeToolRemapper.ts b/open-sse/services/claudeCodeToolRemapper.ts
index 034cba4f7e..8e8b457be5 100644
--- a/open-sse/services/claudeCodeToolRemapper.ts
+++ b/open-sse/services/claudeCodeToolRemapper.ts
@@ -88,9 +88,12 @@ export function remapToolNamesInRequest(body: Record<string, unknown>): boolean
}
}
- if (hasLowercase && !hasTitleCase) {
- body._claudeCodeRequiresLowercaseToolNames = true;
- }
+ // NOTE: previously set body._claudeCodeRequiresLowercaseToolNames = true here.
+ // Removed: the flag had no readers in the codebase and leaked into the
+ // outgoing Anthropic request body, causing HTTP 400
+ // "_claudeCodeRequiresLowercaseToolNames: Extra inputs are not permitted".
+ // The response-side lowercase remap is unconditional anyway via
+ // remapToolNamesInResponse(text, forceLowercase=true).
return hasLowercase && !hasTitleCase;
}
diff --git a/tests/unit/claude-code-tool-remapper-flag-leak.test.ts b/tests/unit/claude-code-tool-remapper-flag-leak.test.ts
new file mode 100644
index 0000000000..e5deb21b0b
--- /dev/null
+++ b/tests/unit/claude-code-tool-remapper-flag-leak.test.ts
@@ -0,0 +1,59 @@
+/**
+ * Regression test for the _claudeCodeRequiresLowercaseToolNames flag leak
+ * that caused HTTP 400 "Extra inputs are not permitted" from Anthropic.
+ *
+ * The flag had no readers in the codebase but was assigned to the outgoing
+ * request body. Anthropic's strict schema validation rejected the unknown
+ * field. This test guards against re-introduction.
+ */
+import { describe, it } from "node:test";
+import assert from "node:assert/strict";
+import { remapToolNamesInRequest } from "../../open-sse/services/claudeCodeToolRemapper.ts";
+
+describe("remapToolNamesInRequest — flag-leak regression", () => {
+ it("does NOT add _claudeCodeRequiresLowercaseToolNames when all tools are lowercase", () => {
+ const body: Record<string, unknown> = {
+ tools: [{ name: "bash" }, { name: "read" }, { name: "edit" }],
+ };
+ remapToolNamesInRequest(body);
+ assert.equal(
+ "_claudeCodeRequiresLowercaseToolNames" in body,
+ false,
+ "Flag must not leak into outgoing request body"
+ );
+ });
+
+ it("returns true when only lowercase tools are present", () => {
+ const body: Record<string, unknown> = { tools: [{ name: "bash" }] };
+ assert.equal(remapToolNamesInRequest(body), true);
+ });
+
+ it("returns false when only TitleCase tools are present", () => {
+ const body: Record<string, unknown> = { tools: [{ name: "Bash" }] };
+ assert.equal(remapToolNamesInRequest(body), false);
+ });
+
+ it("returns false when mixed-case tools are present", () => {
+ const body: Record<string, unknown> = {
+ tools: [{ name: "bash" }, { name: "Read" }],
+ };
+ assert.equal(remapToolNamesInRequest(body), false);
+ });
+
+ it("does NOT add flag in any of the above cases", () => {
+ for (const tools of [
+ [{ name: "bash" }],
+ [{ name: "Bash" }],
+ [{ name: "bash" }, { name: "Read" }],
+ [],
+ ]) {
+ const body: Record<string, unknown> = { tools };
+ remapToolNamesInRequest(body);
+ assert.equal(
+ "_claudeCodeRequiresLowercaseToolNames" in body,
+ false,
+ `Flag leaked for tools=${JSON.stringify(tools)}`
+ );
+ }
+ });
+});