From 1a2c403dce8d5951340fb62099884367b046aa7a Mon Sep 17 00:00:00 2001 From: Adilson Date: Fri, 14 Aug 2026 12:07:47 -0300 Subject: [PATCH] fix(anthropic): drop invalid `name` field from output_config.format Anthropic's Messages API structured-output field, output_config.format, only accepts { type, schema }. Sending the extra `name` field (carried over from OpenAI's json_schema.name / text.format.name conventions) causes the live API to reject every structured-output request from the anthropic provider with: 400 output_config.format.name: Extra inputs are not permitted Reproduced against the real API via a Karakeep auto-tagging request routed through the anthropic provider (claude-haiku-4-5, /v1/chat/completions with response_format.json_schema). Confirmed the fix resolves it end-to-end against the live API, then updated the stale unit test that had asserted the buggy behavior. Affects both translator paths that build Anthropic requests: - openaiToAnthropic (Chat Completions -> Anthropic) - responsesToAnthropic (Responses API -> Anthropic) The equivalent OpenAI-Responses-shaped output (chatToResponsesRequest, text.format.name) is untouched -- that field is valid for OpenAI's own Responses API and unrelated to this bug. --- src/upstream/translator.ts | 2 -- tests/unit.test.ts | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/upstream/translator.ts b/src/upstream/translator.ts index 6410787..d4b14d2 100644 --- a/src/upstream/translator.ts +++ b/src/upstream/translator.ts @@ -201,7 +201,6 @@ export function openaiToAnthropic(body: any): any { format: { type: "json_schema", schema: fmt.json_schema.schema, - name: fmt.json_schema.name, }, }; } else if (fmt.type === "json_object") { @@ -580,7 +579,6 @@ export function responsesToAnthropic(body: any): any { format: { type: "json_schema", schema: fmt.schema, - name: fmt.name, }, }; } else if (fmt.type === "json_object") { diff --git a/tests/unit.test.ts b/tests/unit.test.ts index 6f235d6..703b3da 100644 --- a/tests/unit.test.ts +++ b/tests/unit.test.ts @@ -568,7 +568,11 @@ test("openaiToAnthropic translates response_format json_schema", () => { }, }); assert.equal(result.output_config.format.type, "json_schema"); - assert.equal(result.output_config.format.name, "test"); + // Anthropic's Messages API rejects an extra `name` field here with + // "Extra inputs are not permitted" (verified against the live API) -- + // unlike OpenAI's json_schema format, Anthropic's output_config.format + // only accepts { type, schema }. + assert.equal(result.output_config.format.name, undefined); }); test("openaiToAnthropic translates tool role messages", () => {