litellm/litellm
Mateo Wang c734ee772f
fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#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 #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.

* 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 #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

* 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 85f924148a)
2026-07-03 16:43:50 -07:00
..
a2a_protocol style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
anthropic_interface style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
assistants style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
batch_completion style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
batches style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
caching style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
completion_extras style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
compression style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
containers style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
endpoints/speech/speech_to_completion_bridge style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
evals style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
experimental_mcp_client style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
files style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
fine_tuning style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
google_genai style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
images style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
integrations style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
interactions style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
litellm_core_utils fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00
llms fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00
models style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
ocr style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
passthrough style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
proxy fix(mcp): support client_secret_basic for upstream OAuth token endpoints (#31635) 2026-07-03 16:41:08 -07:00
proxy_auth style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rag style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
realtime_api style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
repositories style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rerank_api style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
responses style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
router_strategy style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
router_utils style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rust_bridge feat(ocr): thin Rust OCR Python bridge (#31368) 2026-06-25 18:42:59 -07:00
sandbox style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
search style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
secret_managers style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
skills style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
types fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00
vector_store_files style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
vector_stores style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
videos style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
__init__.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_internal_context.py fix(proxy): harden request parameter handling 2026-04-16 01:38:12 +00:00
_lazy_imports.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_lazy_imports_registry.py chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
_logging.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_redis.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_redis_credential_provider.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_service_logger.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_uuid.py build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
_version.py
anthropic_beta_headers_config.json chore(oss): litellm oss staging 120626 (#30292) 2026-06-12 09:49:25 -07:00
anthropic_beta_headers_manager.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
blog_posts.json docs(blog): add WebRTC blog post link 2026-03-13 17:54:33 +05:30
budget_manager.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
constants.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
cost.json
cost_calculator.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
exceptions.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
main.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
model_prices_and_context_window_backup.json fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00
policy_templates_backup.json feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
provider_endpoints_support_backup.json chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
py.typed
router.py fix(router): persist global retry_policy via /config/update (#29540) 2026-06-28 00:20:20 +00:00
scheduler.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
setup_wizard.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
timeout.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
utils.py fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00