fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) - #31923
Conversation
Bedrock Converse routes Claude Opus 4.7/4.8 through an Anthropic-compatible
validator that maps toolSpec to the native tool shape and rejects the extra
`strict` key with `tools.N.custom.strict: Extra inputs are not permitted`,
even though Anthropic's native API accepts `strict` as a top-level tool field
for the same models. Sonnet 4.5/4.6 and Opus <=4.6 accept `toolSpec.strict`
unchanged.
The existing gate `get_bedrock_base_model(model).startswith("anthropic")`
(introduced in #29814 to forward `strict` for Claude on Bedrock Converse) is
too broad and regressed Opus 4.7/4.8 callers — see #31582.
Replace the inline check with a small `bedrock_converse_supports_strict_tools`
helper that excludes the Opus 4.7/4.8 family from strict forwarding. All
other Anthropic models on Bedrock keep the existing behavior.
Closes #31582.
The original regression test was added to test_litellm_core_utils_prompt_templates_factory.py, which has pre-existing ruff-format violations throughout (multi-line asserts that fit on one line). The lint workflow runs `ruff format --check` on changed files only, so touching that file surfaces those pre-existing violations and fails CI for unrelated reasons. Move the #31582 regression coverage into a new dedicated test file so the format check stays green. Also collapses the helper's `not any(...)` onto a single line to satisfy ruff format. Covers: #31582
|
|
|
Generated by Claude Code |
Greptile SummaryThis PR fixes a 400 error on Bedrock Converse when calling Claude Opus 4.7/4.8 with
Confidence Score: 5/5Safe to merge — the change is narrowly scoped, follows an established pattern in the codebase, and is backed by a purpose-built regression test suite. The fix correctly replaces a too-broad provider check with a JSON-driven capability flag, using the same two-phase lookup (model_info dict → local cost map via key) already in production for bedrock_output_config_effort_ceiling. All affected Opus 4.7/4.8 regional entries in both JSON files carry the new flag, and the new helper defaults to true for models not explicitly listed — preserving existing behavior for every other Anthropic model on Bedrock. Tests cover the exclusion, inclusion, and non-Anthropic paths without any network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock/common_utils.py | Adds bedrock_converse_supports_strict_tools and its private helper; implementation mirrors the existing _get_bedrock_output_config_effort_ceiling pattern and is JSON-driven. |
| litellm/litellm_core_utils/prompt_templates/factory.py | Replaces the get_bedrock_base_model(model).startswith("anthropic") gate with the new bedrock_converse_supports_strict_tools helper; call site is clean. |
| model_prices_and_context_window.json | Adds bedrock_converse_supports_strict_tools: false to all Opus 4.7/4.8 regional entries; correct coverage across anthropic, global, us, eu, au, jp prefixes. |
| litellm/model_prices_and_context_window_backup.json | Mirror of the main JSON changes; backup kept in sync. |
| litellm/types/utils.py | Adds bedrock_converse_supports_strict_tools: Optional[bool] to ProviderSpecificModelInfo TypedDict; correct typing. |
| litellm/utils.py | Plumbs bedrock_converse_supports_strict_tools from the JSON cost map into the _get_model_info_helper return dict; follows the same pattern as other capability flags. |
| tests/test_litellm/litellm_core_utils/prompt_templates/test_bedrock_converse_strict_tools_opus_47_48.py | New regression suite; covers Opus 4.7/4.8 exclusion, other-Anthropic inclusion, and non-Anthropic exclusion; all tests use local data without network calls. |
| tests/test_litellm/test_utils.py | Adds bedrock_converse_supports_strict_tools to the JSON schema validator; no change to existing assertions. |
Reviews (4): Last reviewed commit: "chore: revert unrelated credential_migra..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
is the greptile comment legit? |
Replace the hardcoded Opus 4.7/4.8 pattern list with a bedrock_converse_supports_strict_tools flag on the affected entries in model_prices_and_context_window.json, resolved via get_model_info with a local cost map fallback, so future models with the same restriction only need a JSON update
|
@yucheng-berri yes, the P1 is legit. The repo already stores this kind of Bedrock capability info in Generated by Claude Code |
|
Generated by Claude Code |
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
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 6bd1f9a. Configure here.
…1.91.0) litellm 1.90.x forwards the OpenAI `strict` tool field into the Bedrock Converse toolSpec for Anthropic models (PR BerriAI/litellm#29814, gated on get_bedrock_base_model(model).startswith("anthropic")). Converse rejects it for Opus 4.7/4.8: `tools.0.custom.strict: Extra inputs are not permitted` -> every tool-calling scan 400s at warm-up. The openai-agents SDK stamps strict on every FunctionTool (ensure_strict_json_schema), so it fires universally. UPSTREAM ALREADY FIXED THIS: BerriAI/litellm#31923 + #31943 (merged 2026-07-02, closing litellm#31582 which is this exact symptom) replace the broad startswith("anthropic") gate with bedrock_converse_supports_strict_tools. The fix ships in litellm 1.91.0. We pin 1.90.2 today, which predates it, so this monkeypatch (AmazonConverseConfig._transform_request_helper strips `strict`) bridges until we bump litellm. REMOVE THIS FILE + its apply() call in models.py once litellm>=1.91.0 is the floor. Idempotent, fail-open. Not an upstream candidate (upstream fixed it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…1.91.0) litellm 1.90.x forwards the OpenAI `strict` tool field into the Bedrock Converse toolSpec for Anthropic models (PR BerriAI/litellm#29814, gated on get_bedrock_base_model(model).startswith("anthropic")). Converse rejects it for Opus 4.7/4.8: `tools.0.custom.strict: Extra inputs are not permitted` -> every tool-calling scan 400s at warm-up. The openai-agents SDK stamps strict on every FunctionTool (ensure_strict_json_schema), so it fires universally. UPSTREAM ALREADY FIXED THIS: BerriAI/litellm#31923 + #31943 (merged 2026-07-02, closing litellm#31582 which is this exact symptom) replace the broad startswith("anthropic") gate with bedrock_converse_supports_strict_tools. The fix ships in litellm 1.91.0. We pin 1.90.2 today, which predates it, so this monkeypatch (AmazonConverseConfig._transform_request_helper strips `strict`) bridges until we bump litellm. REMOVE THIS FILE + its apply() call in models.py once litellm>=1.91.0 is the floor. Idempotent, fail-open. Not an upstream candidate (upstream fixed it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…#31582) (BerriAI#31923) * fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 Bedrock Converse routes Claude Opus 4.7/4.8 through an Anthropic-compatible validator that maps toolSpec to the native tool shape and rejects the extra `strict` key with `tools.N.custom.strict: Extra inputs are not permitted`, even though Anthropic's native API accepts `strict` as a top-level tool field for the same models. Sonnet 4.5/4.6 and Opus <=4.6 accept `toolSpec.strict` unchanged. The existing gate `get_bedrock_base_model(model).startswith("anthropic")` (introduced in BerriAI#29814 to forward `strict` for Claude on Bedrock Converse) is too broad and regressed Opus 4.7/4.8 callers — see BerriAI#31582. Replace the inline check with a small `bedrock_converse_supports_strict_tools` helper that excludes the Opus 4.7/4.8 family from strict forwarding. All other Anthropic models on Bedrock keep the existing behavior. Closes BerriAI#31582. * fix(bedrock/converse): move strict-tools regression to a clean test file The original regression test was added to test_litellm_core_utils_prompt_templates_factory.py, which has pre-existing ruff-format violations throughout (multi-line asserts that fit on one line). The lint workflow runs `ruff format --check` on changed files only, so touching that file surfaces those pre-existing violations and fails CI for unrelated reasons. Move the BerriAI#31582 regression coverage into a new dedicated test file so the format check stays green. Also collapses the helper's `not any(...)` onto a single line to satisfy ruff format. Covers: BerriAI#31582 * refactor(bedrock/converse): drive strict-tools gate from model cost map Replace the hardcoded Opus 4.7/4.8 pattern list with a bedrock_converse_supports_strict_tools flag on the affected entries in model_prices_and_context_window.json, resolved via get_model_info with a local cost map fallback, so future models with the same restriction only need a JSON update * chore: revert unrelated credential_migration.py reformat --------- Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
….3) (#1400) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | patch | `v1.90.2` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.3...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1400
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | final | patch | `v1.90.2` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.3...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDkuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: Renovate Bot <renovate@bhamm-lab.com> Reviewed-on: https://codeberg.org/blake-hamm/bhamm-lab/pulls/258
…to v1.90.3 (#257) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [https://github.com/BerriAI/litellm.git](https://github.com/BerriAI/litellm) | patch | `v1.90.0` → `v1.90.3` | --- ### Release Notes <details> <summary>BerriAI/litellm (https://github.com/BerriAI/litellm.git)</summary> ### [`v1.90.3`](https://github.com/BerriAI/litellm/releases/tag/v1.90.3) [Compare Source](BerriAI/litellm@v1.90.2...v1.90.3) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.3/cosign.pub \ ghcr.io/berriai/litellm:v1.90.3 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31923](BerriAI/litellm#31923), [#​31929](BerriAI/litellm#31929), [#​31393](BerriAI/litellm#31393) to stable/1.90.x and cut 1.90.3 by [@​mateo-berri](https://github.com/mateo-berri) in [#​32025](BerriAI/litellm#32025) **Full Changelog**: <BerriAI/litellm@v1.90.2...v1.90.3> ### [`v1.90.2`](https://github.com/BerriAI/litellm/releases/tag/v1.90.2) [Compare Source](BerriAI/litellm@v1.90.1...v1.90.2) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.2 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.2/cosign.pub \ ghcr.io/berriai/litellm:v1.90.2 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31519](BerriAI/litellm#31519), [#​31733](BerriAI/litellm#31733) to stable/1.90.x and cut 1.90.2 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​31782](BerriAI/litellm#31782) **Full Changelog**: <BerriAI/litellm@v1.90.1...v1.90.2> ### [`v1.90.1`](https://github.com/BerriAI/litellm/releases/tag/v1.90.1) [Compare Source](BerriAI/litellm@v1.90.0-rc.1...v1.90.1) #### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.90.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.90.1/cosign.pub \ ghcr.io/berriai/litellm:v1.90.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** #### What's Changed - chore(release): backport [#​31036](BerriAI/litellm#31036), [#​31342](BerriAI/litellm#31342), [#​31653](BerriAI/litellm#31653) to stable/1.90.x and cut 1.90.1 (litellm-enterprise 0.1.43.post1) by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​31667](BerriAI/litellm#31667) **Full Changelog**: <BerriAI/litellm@v1.90.0...v1.90.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDkuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: Renovate Bot <renovate@bhamm-lab.com> Reviewed-on: https://codeberg.org/blake-hamm/bhamm-lab/pulls/257
…#31582) (BerriAI#31923) * fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 Bedrock Converse routes Claude Opus 4.7/4.8 through an Anthropic-compatible validator that maps toolSpec to the native tool shape and rejects the extra `strict` key with `tools.N.custom.strict: Extra inputs are not permitted`, even though Anthropic's native API accepts `strict` as a top-level tool field for the same models. Sonnet 4.5/4.6 and Opus <=4.6 accept `toolSpec.strict` unchanged. The existing gate `get_bedrock_base_model(model).startswith("anthropic")` (introduced in BerriAI#29814 to forward `strict` for Claude on Bedrock Converse) is too broad and regressed Opus 4.7/4.8 callers — see BerriAI#31582. Replace the inline check with a small `bedrock_converse_supports_strict_tools` helper that excludes the Opus 4.7/4.8 family from strict forwarding. All other Anthropic models on Bedrock keep the existing behavior. Closes BerriAI#31582. * fix(bedrock/converse): move strict-tools regression to a clean test file The original regression test was added to test_litellm_core_utils_prompt_templates_factory.py, which has pre-existing ruff-format violations throughout (multi-line asserts that fit on one line). The lint workflow runs `ruff format --check` on changed files only, so touching that file surfaces those pre-existing violations and fails CI for unrelated reasons. Move the BerriAI#31582 regression coverage into a new dedicated test file so the format check stays green. Also collapses the helper's `not any(...)` onto a single line to satisfy ruff format. Covers: BerriAI#31582 * refactor(bedrock/converse): drive strict-tools gate from model cost map Replace the hardcoded Opus 4.7/4.8 pattern list with a bedrock_converse_supports_strict_tools flag on the affected entries in model_prices_and_context_window.json, resolved via get_model_info with a local cost map fallback, so future models with the same restriction only need a JSON update * chore: revert unrelated credential_migration.py reformat --------- Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com> (cherry picked from commit 85f9241)
…et 4.6 and Haiku 4.5 Bedrock Converse rejects toolSpec.strict for Claude Sonnet 4.6 and Claude Haiku 4.5, causing a grammar-size error (>300MB compiled grammar) that results in a 504 Gateway Timeout for callers. The same fix was already applied for Opus 4.7/4.8 (BerriAI#31923) and Sonnet 4 (BerriAI#31943). This extends it to the missing model variants by setting bedrock_converse_supports_strict_tools: false on all regional Bedrock Converse entries for these two models. Fixes BerriAI#34388 Co-authored-by: Hermes Agent <hermes-agent@nousresearch.com>
…et 4.6 and Haiku 4.5 Bedrock Converse rejects toolSpec.strict for Claude Sonnet 4.6 and Claude Haiku 4.5, causing a grammar-size error (>300MB compiled grammar) that results in a 504 Gateway Timeout for callers. The same fix was already applied for Opus 4.7/4.8 (BerriAI#31923) and Sonnet 4 (BerriAI#31943). This extends it to the missing model variants by setting bedrock_converse_supports_strict_tools: false on all regional Bedrock Converse entries for these two models. Fixes BerriAI#34388 Co-authored-by: Hermes Agent <hermes-agent@nousresearch.com>
Relevant issues
Closes #31582
Internal copy of #31585 by @ly-wang19 (original authorship preserved on the commits) so CircleCI can run on it. All credit to the original author
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays 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
From the original PR: sending a tool with
strict: truetobedrock/us.anthropic.claude-opus-4-7orclaude-opus-4-8on Bedrock Converse fails with400 tools.0.custom.strict: Extra inputs are not permitted. With this change,strictis dropped fromtoolSpecfor the Opus 4.7/4.8 family only, so the call succeeds; Sonnet 4.5/4.6, Opus <=4.6 and other Anthropic models keep forwardingstrictas before (#29814 behavior preserved), and non-Anthropic families (Nova, Llama, GPT-OSS) are unchangedRegression tests:
tests/test_litellm/litellm_core_utils/prompt_templates/test_bedrock_converse_strict_tools_opus_47_48.py(18 passed locally); existingtest_bedrock_tools_pt_strict_parameterstill passesLatest e2e QA run: 2026-07-02 02:32 UTC against commit 6bd1f9a, on a live proxy hitting real Bedrock (us-west-2, no mocks).
strict: truetool calls tous.anthropic.claude-opus-4-8andus.anthropic.claude-opus-4-7returned 200 with real tool calls,us.anthropic.claude-sonnet-4-5-20250929-v1:0still forwards"strict": truein its rawtoolSpecpayload (verified in--detailed_debuglogs, so the gate is model-scoped rather than a blanket drop), and the same Opus 4.8 request against a pre-fix proxy reproduced the exact400 tools.0.custom.strict: Extra inputs are not permittedType
🐛 Bug Fix
Changes
PR #29814 started forwarding
strictinto the Bedrock ConversetoolSpec, gated onget_bedrock_base_model(model).startswith("anthropic"). That gate is too broad: Bedrock routes Opus 4.7/4.8 through an Anthropic-compatible validator that mapstoolSpecto the native tool shape (thecustomvariant) and rejects the extrastrictkey. This replaces the gate inlitellm_core_utils/prompt_templates/factory.pywithbedrock_converse_supports_strict_toolsinlitellm/llms/bedrock/common_utils.py, which returnsFalsefor non-Anthropic Bedrock models and for the Opus 4.7/4.8 family, andTruefor every other Anthropic model on BedrockFollowing review feedback, the Opus 4.7/4.8 exclusion is not hardcoded in the source: the affected Bedrock entries in
model_prices_and_context_window.jsoncarry abedrock_converse_supports_strict_tools: falseflag, resolved throughget_model_infowith a local cost map fallback (the same approach asbedrock_output_config_effort_ceiling), so future models with the same restriction only need a JSON update> [!NOTE]
> Low Risk
> Targeted Bedrock tool-payload gating with JSON flags and regression tests; behavior change is limited to omitting
strictfor flagged Opus 4.7/4.8 models.>
> Overview
> Fixes Bedrock Converse 400 errors when tools include
strict: trueon Claude Opus 4.7/4.8, where the Converse validator rejectstoolSpec.stricteven though other Anthropic Bedrock models accept it.>
>
_bedrock_tools_ptno longer treats every Anthropic Bedrock model as strict-capable; it usesbedrock_converse_supports_strict_tools(model), which keepsstrictfor Sonnet and Opus ≤4.6 and omits it for Opus 4.7/4.8 and non-Anthropic families (unchanged).>
> The new helper reads
bedrock_converse_supports_strict_toolsfrom the model cost map (with version-suffix normalization and local fallback), matching the pattern used forbedrock_output_config_effort_ceiling. Opus 4.7/4.8 regional entries are flaggedfalseinmodel_prices_and_context_window.json, and the flag is wired throughModelInfo/get_model_info. Regression tests cover Opus 4.7/4.8 drop vs other models keep/drop behavior.>
> Reviewed by Cursor Bugbot for commit 6bd1f9a. Bugbot is set up for automated code reviews on this repo. Configure here.