This commit is contained in:
hcl 2026-10-29 06:00:47 +09:00 • committed by GitHub
commit e832339488
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View file

@ -1063,6 +1063,17 @@ class AmazonConverseConfig(BaseConfig):
)
for param, value in non_default_params.items():
if param == "reasoning_effort" and isinstance(value, dict):
# Accept both the string form ("low") and the dict form
# ({"effort": "low", "summary": "concise"}). The Responses->Chat
# parser keeps the full dict whenever `summary` is set, so a dict
# is the standard shape Responses-bridge callers send. Every
# `reasoning_effort` branch below gates on `isinstance(value, str)`,
# so without this the dict matches nothing and is dropped silently.
# Same shape-tolerance the direct Anthropic chat path already does.
effort_value: object = cast(dict[str, object], value).get("effort") # cast-ok: caller-supplied dict
if isinstance(effort_value, str):
value = effort_value
if param == "response_format" and isinstance(value, dict):
optional_params = self._translate_response_format_param(
value=value,

View file

@ -10789,3 +10789,26 @@ def test_a_deployment_with_a_batch_control_plane_endpoint_keeps_it_out_of_chat_r
assert response.choices[0].message.content == "ok"
assert "aws_bedrock_control_plane_endpoint" not in route.calls[0].request.content.decode()
@pytest.mark.parametrize(
"model",
[
"us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
],
)
def test_reasoning_effort_dict_is_coerced_converse(model):
"""The Responses->Chat parser keeps `reasoning_effort` as a dict whenever
`summary` is set. Every branch gates on `isinstance(value, str)`, so without
coercion the dict matches nothing and thinking is dropped silently."""
config = AmazonConverseConfig()
optional_params = config.map_openai_params(
non_default_params={"reasoning_effort": {"effort": "low", "summary": "concise"}},
optional_params={},
model=model,
drop_params=False,
)
assert optional_params.get("thinking") == {"type": "enabled", "budget_tokens": 1024}