Skip to content

test(cost-map): pin bedrock claude native structured output flag invariants - #48641

Closed
mateo-berri wants to merge 4 commits into
mainfrom
litellm_bedrock_fable5_native_output_catalog_invariant
Closed

mateo-berri wants to merge 4 commits into
mainfrom
litellm_bedrock_fable5_native_output_catalog_invariant

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Locks in the Bedrock Claude native structured output flags so one inference profile row cannot drift away from its siblings. Every Bedrock Claude row of one model now has to agree on both native output flags across the anthropic., global., us., eu., apac., au. and jp. profiles, GovCloud rows may lag their commercial base but never lead it, and the two catalog copies have to match. An earlier version also pinned every claude-fable-5 row to flag off because Bedrock rejected outputConfig for it when #46870 landed. Bedrock accepts it again as of 2026-10-27, so that vendor fact is no longer pinned here. A customer running a patched 1.105.0rc1 asked us to upstream a guard like this

Details

TLDR

Problem this solves:

How it solves it:

  • Unit test: every Bedrock Claude family agrees on both native output flags across its profile rows (194 rows, 27 families)
  • GovCloud rows, including the anthropic.-less ids, may lag the commercial base but never advertise a flag it lacks
  • Main and backup catalogs carry identical Bedrock Claude rows

User Flow

Before: a developer on v1.105.0-rc.1 sends a json_schema request to Fable 5 on Bedrock and gets a 400 from AWS

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "bedrock/us.anthropic.claude-fable-5" and response_format: {"type": "json_schema", ...}
  2. The proxy forwards it with Bedrock's native outputConfig, since the bundled catalog flags the model as supporting it
  3. They got back 400 output_config.format: Extra inputs are not permitted when fix(bedrock): use native structured output on Haiku 5.5 and Sonnet 5.5, and fix Fable 5 and Sonnet 4.6 schema 400s #46870 landed. As of 2026-10-27 the same request returns 200 on us. and global., see the live proxy rows

After: the same request returns 200 with JSON matching the schema, and the catalog can no longer regress

  1. They send the same POST https://litellm-domain/v1/chat/completions with "model": "bedrock/us.anthropic.claude-fable-5" and the same response_format
  2. The proxy sends the schema as a json tool call instead, because every claude-fable-5 row carries supports_native_structured_output: false
  3. They get back 200 with {"city": "...", "country": "..."} matching the schema on us. and global.
  4. A later catalog edit that flips any one of those rows back fails tests/unit/test_model_prices_and_context_window.py before it ships

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

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: a proxy on each side with the two claude-fable-5 profiles our AWS account serves on demand, bedrock/us.anthropic.claude-fable-5 and bedrock/global.anthropic.claude-fable-5 in us-east-1 as fable5-us and fable5-global, Bedrock reached through the box's OIDC AWS profile (aws_profile_name: litellm-dev), drop_params: true, and this request body

{"model": "MODEL", "messages": [{"role": "user", "content": "Give me a city and its country."}],
 "response_format": {"type": "json_schema", "json_schema": {"name": "city", "strict": true, "schema": {"type": "object", "properties": {"city": {"type": "string"}, "country": {"type": "string"}}, "required": ["city", "country"], "additionalProperties": false}}}}
for m in fable5-us fable5-global; do
  sed "s/MODEL/$m/" req.json > req_$m.json
  curl -s -o out_$m.json -w "$m %{http_code}\n" localhost:$PORT/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" -d @req_$m.json
done

Before (2026bd8, v1.105.0-rc.1, the version the customer runs)

catalog rows

  1. python3 -c 'import json; d=json.load(open("model_prices_and_context_window.json")); print({k: d[k]["supports_native_structured_output"] for k in d if k.endswith("anthropic.claude-fable-5")})'
  2. Output: {'anthropic.claude-fable-5': True, 'global.anthropic.claude-fable-5': True, 'us.anthropic.claude-fable-5': True, 'eu.anthropic.claude-fable-5': True, 'apac.anthropic.claude-fable-5': True, 'au.anthropic.claude-fable-5': True}

new test against this catalog

  1. Copy the rc1 main and backup catalogs into the tip checkout, run LITELLM_LOCAL_MODEL_COST_MAP=True uv run pytest tests/unit/test_model_prices_and_context_window.py -k bedrock_claude -q
  2. Output: 3 passed, 79 deselected, since all six rc1 rows agree with each other. The guard is against a row drifting from its siblings, which rc1 does not show

live proxy, PORT=4330

  1. The loop above against the rc1 proxy
  2. Output. fable5-us 200 and fable5-global 200, both {"city":"Paris","country":"France"}, so Bedrock now accepts the native outputConfig rc1 sends and the 400 from fix(bedrock): shape Claude structured-output schemas on Converse and Invoke like the Anthropic path #46376 and fix(bedrock): use native structured output on Haiku 5.5 and Sonnet 5.5, and fix Fable 5 and Sonnet 4.6 schema 400s #46870 no longer reproduces

After (tip)

catalog rows

  1. Same one-liner on the tip
  2. Output: {'anthropic.claude-fable-5': False, 'global.anthropic.claude-fable-5': False, 'us.anthropic.claude-fable-5': False, 'eu.anthropic.claude-fable-5': False, 'apac.anthropic.claude-fable-5': False, 'au.anthropic.claude-fable-5': False}

new test against this catalog

  1. LITELLM_LOCAL_MODEL_COST_MAP=True uv run pytest tests/unit/test_model_prices_and_context_window.py -k bedrock_claude -q
  2. Output: 3 passed, 79 deselected
  3. Mutation: flip us.anthropic.claude-fable-5 to "supports_native_structured_output": true in the main catalog only, rerun
  4. Output: 2 failed, 1 passed (..._agree_on_native_structured_output_flags[main], ..._backup_rows_match_the_main_catalog), and restoring the row gives 3 passed
  5. Mutation: add "supports_bedrock_native_structured_output": true to the same row instead, rerun
  6. Output: the same 2 failed, 1 passed
  7. Mutation: add "supports_bedrock_native_structured_output": true to bedrock/us-gov-west-1/claude-sonnet-4-5-20250929-v1:0, whose commercial base lacks it, rerun
  8. Output: 2 failed, 1 passed (..._agree_on_native_structured_output_flags[main], ..._backup_rows_match_the_main_catalog)

live proxy, PORT=4331

  1. The loop above against the tip proxy
  2. Output. fable5-us 200 and fable5-global 200, both {"city": "Paris", "country": "France"} through the json tool call

Type

✅ Test

Caveats (if any)

Medium

  • Bedrock answered 200 to rc1's native outputConfig on us. and global. claude-fable-5 on the converse route on 2026-10-27, so the claude-fable-5 rows could go back to flag on. That is a separate catalog change and needs its own live proof with thinking on and on the invoke route, so this PR leaves the rows off

Low

  • The live rows cover us-east-1 only. Our AWS account has no on-demand bare, eu., apac. or au. claude-fable-5, and global. from eu-west-1, ap-northeast-1 and ap-southeast-2 returns 400 data retention mode 'default' is not available for this model on both sides, an account setting rather than a litellm path
  • bedrock/claude_platform/claude-fable-5 rows (Claude Platform on AWS, the Anthropic Messages API shape) keep the flag on and are outside the Converse and Invoke invariant
  • The bare claude-sonnet-4-5-20250929-v1:0 row carries no native output flag while its prefixed siblings do; it is the GovCloud id, so the test lets it lag rather than flipping it here

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

…riants

Every Bedrock Claude family agrees on supports_native_structured_output across
its inference-profile rows, GovCloud rows never lead their commercial base, the
main and backup catalogs match, and every claude-fable-5 row keeps the flag off
because Bedrock rejects outputConfig for it (#46870)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with both previous findings addressed

Summary

Adds tests that keep Bedrock Claude native-output flags consistent across commercial profiles, stop GovCloud rows from advertising unsupported flags, and compare the two catalogs

The latest changes remove a repeated docstring and improve the GovCloud failure message. No new actionable issues were found

  • Bedrock Claude profiles stay aligned on native output flags.
  • The Volcengine price comparison is easier to scan.

Reviews (6) · Last reviewed commit: "test(cost-map): move the GovCloud lag ru..." · Reviewed by Greptile

…rock native output flags on fable 5

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

mateo-berri commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Click-through before/after walkthrough of this PR at its tip (catalog rows, Bedrock request shapes, the 2026-10-27 live answers, the new drift guard): https://htmlpreview.github.io/?https://gist.githubusercontent.com/agent-shin/ba7dd171f35619e9288cc37d1a79037d/raw/fable5-bedrock-native-output-walkthrough.html

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment on lines +393 to +395
"""Bedrock Converse and Invoke reject outputConfig for claude-fable-5 with
`output_config.format: Extra inputs are not permitted` (AWS Bedrock, verified live 2026-10-17 in #46870),
so every claude-fable-5 row routes json_schema through the json tool call instead, with or without thinking"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Live success remains unproven

Live e2e not proven at this tip. The PR claims “After: the same request returns 200 with JSON matching the schema”, but all six live requests return 403 because AWS rejects the credentials. The successful results come from earlier PRs

The repository requires live evidence at this tip before merging. Show a running tip proxy accepting POST /v1/chat/completions and returning schema-matching JSON through the affected Bedrock profiles

Rule Used: Apply this rule to every PR, including PRs that change only tests, docs, or catalog data. It does not require new live tests for test-only PRs; it only checks that each runtime claim the PR makes is backed by evidence at this PR's tip A runtime clai... (source)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceded: the 200 at this tip is unproven, every stored AWS key returns 403. Rerun lands here once a fresh credential exists; PR stays unmerged until then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update. The OIDC AWS profile got 200 on us. and global. Fable 5, so f79ad75 drops the fable 5 flag-off test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense: Bedrock’s successful native outputConfig response means the Fable 5 flag-off assertion was pinning a stale vendor limitation, and f79ad7568d appropriately removes it while keeping the profile-consistency and catalog-parity guards.

Live e2e not proven at this tip: The PR still claims, “After: the same request returns 200 with JSON matching the schema,” and says the request uses the JSON-tool path. Your update confirms 200s on us. and global., but doesn’t include the command/output or establish that those requests went through a proxy built from f79ad7568d; the current proof section’s explicit live output is for the rc1 proxy and its native-output path. Please add the live request and response output from a proxy built at this tip for the us. and global. profiles, showing the path this PR describes.

…e outputConfig for it again

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…e assert message

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 1857964. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

Closing per YAGNI, Bedrock now accepts native outputConfig for claude-fable-5, so the original 400 no longer needs a guard

@mateo-berri
mateo-berri deleted the litellm_bedrock_fable5_native_output_catalog_invariant branch October 28, 2026 19:06
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.

1 participant