Skip to content

fix(bedrock): route Claude 5-family json_schema to native structured outputs - #47806

Closed
kaust1495 wants to merge 2 commits into
BerriAI:mainfrom
kaust1495:fix/bedrock-claude-5-native-structured-output
Closed

kaust1495 wants to merge 2 commits into
BerriAI:mainfrom
kaust1495:fix/bedrock-claude-5-native-structured-output

Conversation

@kaust1495

Copy link
Copy Markdown
Contributor

Fixes #47687

Summary

Every Bedrock Claude 5 cost-map entry (opus-5, sonnet-5, haiku-5-5, opus-5-5, sonnet-5-5 and regional variants) has supports_native_structured_output: false, so response_format json_schema without thinking uses the forced json tool path - which these models reject (Opus/Sonnet 5.5: 400 on forced tool_choice / empty content_filter replies; Opus 5, Sonnet 5: invalid or stringified payloads). Per the issue's direct boto3 measurements the native outputConfig.textFormat path returns valid JSON 30/30 across all five models. This flips the flag to true for the 50 Bedrock Claude 5 entries.

Tests

  • New regression test: json_schema without thinking routes to outputConfig (no tools) for all five Claude 5 families; fails before, passes after.
  • Three opt-in routing tests updated: their premise (5-family native output is opt-in only) is intentionally reversed; opt-in slots moved to Claude 4.8 entries that remain opt-in.
  • pytest tests/unit/llms/bedrock/ - zero net regressions vs clean main (3052 vs 3051 passed; identical 17 pre-existing env failures + 111 collection errors).

Behavioral evidence for AWS-side acceptance is the issue reporter's boto3 matrix (cited in #47687); the routing change itself is fully covered by unit tests.

AI-assisted disclosure: this PR was prepared with AI assistance (implementation and tests), reviewed and tested locally by the contributor.

…outputs

The cost map marks every Bedrock Claude 5 entry (opus-5, sonnet-5,
haiku-5-5, opus-5-5, sonnet-5-5 and all regional variants) with
supports_native_structured_output: false, so response_format json_schema
without thinking falls back to the forced json tool path. For these
models that path is broken: Opus/Sonnet 5.5 reject forced tool_choice
outright (400, or empty content_filter replies on current releases),
and Opus 5 / Sonnet 5 return invalid or stringified payloads. The
issue's direct boto3 measurements show the native outputConfig.textFormat
path returning valid JSON 30/30 across all five models.

Flip supports_native_structured_output to true for the 50 Bedrock Claude 5
entries, and update the opt-in routing tests whose premise (5-family
native output is opt-in only) the flag change intentionally reverses;
the opt-in slots now use Claude 4.8 entries that remain opt-in.

Fixes BerriAI#47687
@codspeed

codspeed Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 35 untouched benchmarks


Comparing kaust1495:fix/bedrock-claude-5-native-structured-output (01ddfca) with main (f2118fc)

Open in CodSpeed

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

… structured-output regression test

Fixes the TQ005 test-quality gate failure on the PR: the regression test
mutated the litellm.model_cost process-wide global with manual
save/restore; monkeypatch.setattr restores it at teardown instead.
@mateo-berri

Copy link
Copy Markdown
Contributor

Heads up, #49696 drops the is_thinking_enabled argument from the Converse response_format helper, so whichever of these merges second needs that test call updated

@mateo-berri

Copy link
Copy Markdown
Contributor

Closing as superseded by #49703, which sends native output only on Opus 5.5, Sonnet 5.5 and Fable 5.1, keeping Opus 5 on the json tool

@mateo-berri mateo-berri closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bedrock Claude 5 json_schema without thinking: the json tool path returns empty content_filtered replies (Opus/Sonnet 5.5)

2 participants