fix(anthropic): fix response_format for claude-fable-5-1 on Vertex AI and Bedrock - #39184
Conversation
…Vertex AI and Bedrock Invoke Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…-fable-5-1 structured output Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
PR #39184 (BerriAI/litellm, author devin-ai-integration[bot]) has no |
Greptile SummaryThis PR corrects structured-output capability handling for Claude Fable 5.1 across Anthropic, Bedrock, and Vertex AI
Confidence Score: 5/5The PR appears safe to merge, with the remaining unforced-tool limitation explicitly documented The changed provider transformations consistently use capability metadata to avoid request parameters rejected by Fable 5.1, and no unacknowledged blocking failure remains
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/chat/transformation.py | Skips generated forced tool selection when model metadata explicitly marks forced tool use unsupported |
| litellm/llms/anthropic/common_utils.py | Adds a shared capability helper and reuses it in forced-tool downgrade handling |
| litellm/llms/bedrock/chat/converse_transformation.py | Prevents unsupported forced tool choice on Bedrock Converse structured-output fallbacks |
| litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py | Selects native output from provider metadata and removes only the synthetic response-format tool choice when unsupported |
| litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py | Preserves the original model for Vertex models explicitly advertising native structured output |
| model_prices_and_context_window.json | Aligns Bedrock and Vertex Fable 5.1 structured-output capabilities with provider behavior |
| litellm/model_prices_and_context_window_backup.json | Mirrors the primary model catalog capability updates |
Reviews (1): Last reviewed commit: "fix(bedrock): use tool fallback without ..." | Re-trigger Greptile
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d568bbe. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer asking for JSON output from claude-fable-5-1 through Bedrock gets a 400
fable-bedrock-converseand aresponse_formatjson_schemaoutput_config.format: Extra inputs are not permittedfable-bedrock-invokeand the same bodytool_choice: type "tool" and "any" are not supported for this model.After: the same requests return schema-conforming JSON
fable-bedrock-converseand aresponse_formatjson_schema{"city": "Lisbon", "country": "Portugal"}fable-bedrock-invokeand the same bodyRelevant issues
Follow-up to #39148 (see the Bugbot thread at #39148 (comment))
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: proxy on localhost:4000 with
model_listentriesfable-anthropic(anthropic/claude-fable-5-1),fable-bedrock-converse(bedrock/us.anthropic.claude-fable-5-1) andfable-bedrock-invoke(bedrock/invoke/us.anthropic.claude-fable-5-1), all hitting real provider APIs. Every request is the same curl:Before (a3e115f)
bedrock converse
"model":"fable-bedrock-converse"BedrockException - {"message":"The model returned the following errors: output_config.format: Extra inputs are not permitted"}bedrock invoke
"model":"fable-bedrock-invoke"BedrockException - {"message":"tool_choice: type \"tool\" and \"any\" are not supported for this model."}After (d568bbe)
bedrock converse
"model":"fable-bedrock-converse"{"city": "Lisbon", "country": "Portugal"}(real Bedrock call, non-zero spend)bedrock invoke
"model":"fable-bedrock-invoke"{"city": "Lisbon", "country": "Portugal"}(real Bedrock call, non-zero spend)anthropic direct (regression control)
"model":"fable-anthropic"{"city":"Porto","country":"Portugal"}, still on the native structured output pathType
🐛 Bug Fix
Caveats (if any)
Medium
Link to Devin session: https://app.devin.ai/sessions/91161c53a340462b8b5ca0d9ad54359b
Open in Devin Desktop: https://app.devin.ai/desktop/session/91161c53a340462b8b5ca0d9ad54359b?variant=devin
Requested by: @mateo-berri
Note
Medium Risk
Changes how
response_formatis translated across Anthropic, Bedrock, and Vertex based on model-map flags; wrong flags could break structured output or reintroduce provider 400s, but scope is limited to capability checks and tests.Overview
Fixes HTTP 400 when
response_formatis used with claude-fable-5-1 (and similar models withsupports_forced_tool_use: false) on Bedrock and Vertex.Capability-driven routing: Adds
AnthropicModelInfo.forced_tool_use_unsupported()and uses it so the JSON-schema tool fallback no longer sets a forcedtool_choiceon models that reject it (same idea as the existing thinking-enabled path). Bedrock Converse and direct Anthropic mapping get this guard; Bedrock Invoke also strips a response-formattool_choiceleft over from the parent stub-model path.Provider overrides: Vertex only forces the tool-based stub when native structured output is not advertised for that model. Bedrock Invoke skips the stub when
supports_native_structured_outputis true for bedrock. Model map updates set Bedrock Fable entries tosupports_native_structured_output: falseso Converse stops sending nativeoutputConfigthat Bedrock rejects, while Vertex can still useoutput_formatwhere the map says native SO is supported.Regression tests cover Anthropic, Bedrock Converse/Invoke, and Vertex paths.
Reviewed by Cursor Bugbot for commit d568bbe. Bugbot is set up for automated code reviews on this repo. Configure here.