feat(anthropic): translate output_config/output_format to response_format#1380
Open
idemerge wants to merge 1 commit into
Open
feat(anthropic): translate output_config/output_format to response_format#1380idemerge wants to merge 1 commit into
idemerge wants to merge 1 commit into
Conversation
…rmat Anthropic's Messages API gained structured outputs in GA on 2025-11-14 via output_config.format, with an earlier beta path using output_format (behind anthropic-beta: structured-outputs-2025-11-13). The AnthropicTransformer previously dropped both fields silently, so clients using structured outputs against an OpenAI-compatible backend (GLM, DeepSeek, Groq, vLLM, etc.) would degrade to free-form text. Translate both shapes into the unified response_format field matching OpenAI's structured-outputs schema, so provider transformers can pass it through unchanged. Supports json_schema, json_object, and text types; strict defaults to true to mirror Anthropic's guarantee semantics.
Author
|
Before this PR is merged, you can use the plugin (https://github.com/idemerge/ccr-plugin-structured-outputs) to resolve this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Anthropic's Messages API gained structured outputs in GA on 2025-11-14 via
output_config.format, with an earlier beta path usingoutput_format(behindanthropic-beta: structured-outputs-2025-11-13). TheAnthropicTransformerpreviously dropped both fields silently, so any client using structured outputs against an OpenAI-compatible backend (GLM, DeepSeek, Groq, vLLM, etc.) would degrade to free-form text.This PR translates both shapes into the unified
response_formatfield, matching OpenAI's structured-outputs schema, so existing provider transformers can pass it through unchanged.Changes
packages/core/src/transformer/anthropic.transformer.ts— translaterequest.output_config?.format ?? request.output_formatintoresult.response_format. Supportsjson_schema,json_object, andtexttypes.strictdefaults totrueto mirror Anthropic's guarantee semantics; client can opt out withstrict: false.packages/core/src/types/llm.ts— add optionalresponse_formatunion toUnifiedChatRequest.Test plan
tsc --noEmit) introduces zero new errors over masterpnpm buildpassesExpected:
content[0].textis a JSON string parseable into an object matching the schema.Refs