mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix(bedrock): forward output_config effort for application inference profile ARNs
This commit is contained in:
parent
929ee52b87
commit
0f41365c34
2 changed files with 34 additions and 1 deletions
|
|
@ -80,6 +80,7 @@ from ..common_utils import (
|
|||
bedrock_converse_supports_parallel_tool_use_config,
|
||||
get_anthropic_beta_from_headers,
|
||||
get_bedrock_tool_name,
|
||||
is_bedrock_application_inference_profile_arn,
|
||||
is_claude_4_5_on_bedrock,
|
||||
normalize_bedrock_opus_output_config_effort,
|
||||
)
|
||||
|
|
@ -1318,7 +1319,12 @@ class AmazonConverseConfig(BaseConfig):
|
|||
additional_request_params = filter_exceptions_from_params(additional_request_params)
|
||||
|
||||
if anthropic_output_config is not None and isinstance(anthropic_output_config, dict):
|
||||
if base_model.startswith("anthropic"):
|
||||
# Application inference profile ARNs hide the underlying model, so the
|
||||
# effort ceiling and capability gates below cannot run; forward
|
||||
# verbatim (like ``thinking``) and let Bedrock enforce.
|
||||
if is_bedrock_application_inference_profile_arn(model):
|
||||
additional_request_params["output_config"] = anthropic_output_config
|
||||
elif base_model.startswith("anthropic"):
|
||||
if litellm.drop_params is True and not AnthropicConfig._model_supports_effort_param(model, "bedrock"):
|
||||
litellm.verbose_logger.warning(
|
||||
DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING,
|
||||
|
|
|
|||
|
|
@ -410,6 +410,33 @@ def test_output_config_supported_param_for_arn_models_converse():
|
|||
assert "output_config" in config.get_supported_openai_params(arn_model)
|
||||
|
||||
|
||||
def test_output_config_effort_forwarded_for_application_inference_profile_arn():
|
||||
"""Regression: opaque application inference profile ARNs cannot resolve a
|
||||
base model, so the anthropic-only serialization gate dropped ``output_config``
|
||||
while still sending ``thinking``: adaptive thinking with no effort tier, and
|
||||
Bedrock streams zero ``reasoningContent`` blocks. The effort must be forwarded
|
||||
verbatim (ceilings and capability gates are unknowable behind the alias) for
|
||||
Bedrock to enforce."""
|
||||
config = AmazonConverseConfig()
|
||||
arn_model = "arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abcdef123456"
|
||||
|
||||
result = config._transform_request(
|
||||
model=arn_model,
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
optional_params={
|
||||
"maxTokens": 256,
|
||||
"thinking": {"type": "adaptive"},
|
||||
"output_config": {"effort": "max"},
|
||||
},
|
||||
litellm_params={},
|
||||
headers={},
|
||||
)
|
||||
|
||||
additional = result.get("additionalModelRequestFields", {})
|
||||
assert additional.get("thinking") == {"type": "adaptive"}
|
||||
assert additional.get("output_config") == {"effort": "max"}
|
||||
|
||||
|
||||
def test_output_config_format_translated_to_native_output_config_converse():
|
||||
"""``output_config.format`` becomes Bedrock ``outputConfig`` and is not forwarded raw."""
|
||||
config = AmazonConverseConfig()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue