Commit 962dc7f
test(bedrock): repair a vacuous test, drop a dead condition, pin the hardening
Round 3 of review. The production logic held up -- 6 of 7 mutations killed, no
breakage across the full bedrock directory (1089 passed; the 5 errors are a
missing pytest-mock in this env and reproduce at base) -- but one round-2 test
asserted nothing.
test_response_format_injected_tools_still_honour_parallel_tool_calls picked
"anthropic.claude-sonnet-4-5-20250929-v1:0", which advertises
supports_native_structured_output, so _translate_response_format_param takes the
outputConfig branch and injects NO synthetic tool. optional_params had no tools,
the list was empty, and the whole assertion sat behind `if listed:` and never ran
-- it passed with the round-2 fix reverted, which made it the only coverage for
half that fix and worthless. Of the 59 models carrying
supports_parallel_tool_use_config exactly one lacks native structured output
("claude-sonnet-4-5-20250929-v1:0", bare id), so the test now uses that and
asserts the exact payload unconditionally:
toolConfig.tools = [json_tool_call]
additionalModelRequestFields.tool_choice = {"type": "tool",
"name": "json_tool_call", "disable_parallel_tool_use": True}
Verified it now dies under the mutation it exists to catch.
Dropped `and "type" in passthrough_tool_choice` from
_apply_parallel_tool_use_config: the builder sets type on all three branches, so
it could never be false -- the same reasoning round 1 used to delete the
unreachable merge branch two lines above.
Softened the guard comment, which claimed more than the guard delivers. A
non-empty optional_params["tools"] does not imply a non-empty toolConfig.tools:
_bedrock_tools_pt later drops tools carrying neither "function" nor
"input_schema" (the Responses built-ins, e.g. web_search), so a request whose
tools are all of that kind still reaches the provider with a tool_choice and no
toolConfig. Measured, and identical before this feature, so it is not a
regression -- but the comment should not assert the payload is prevented.
Added the one test that pins the non-dict native["tool"] hardening, which no
mutation was catching.
Confirmed by review that the tool_choice="none" early return is in the right
place: Anthropic's ToolChoiceNone carries only `type`, and
disable_parallel_tool_use exists on auto/any/tool only -- so emitting the bare
flag is the "missing field type" 400 this PR fixes, and {"type":"none",
disable_parallel_tool_use} would be rejected as an extra input. Emitting nothing
is the only correct option, which is also what litellm's own Anthropic transform
does.
174 pass.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 7105fb9 commit 962dc7f
2 files changed
Lines changed: 46 additions & 11 deletions
File tree
- litellm/llms/bedrock/chat
- tests/test_litellm/llms/bedrock/chat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| |||
1014 | 1016 | | |
1015 | 1017 | | |
1016 | 1018 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1021 | 1030 | | |
1022 | 1031 | | |
1023 | 1032 | | |
| |||
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6107 | 6107 | | |
6108 | 6108 | | |
6109 | 6109 | | |
| 6110 | + | |
| 6111 | + | |
| 6112 | + | |
| 6113 | + | |
| 6114 | + | |
| 6115 | + | |
| 6116 | + | |
6110 | 6117 | | |
6111 | | - | |
| 6118 | + | |
6112 | 6119 | | |
6113 | 6120 | | |
6114 | 6121 | | |
| |||
6120 | 6127 | | |
6121 | 6128 | | |
6122 | 6129 | | |
6123 | | - | |
6124 | | - | |
6125 | | - | |
6126 | | - | |
| 6130 | + | |
| 6131 | + | |
| 6132 | + | |
| 6133 | + | |
| 6134 | + | |
| 6135 | + | |
| 6136 | + | |
| 6137 | + | |
6127 | 6138 | | |
6128 | 6139 | | |
6129 | 6140 | | |
| |||
6143 | 6154 | | |
6144 | 6155 | | |
6145 | 6156 | | |
| 6157 | + | |
| 6158 | + | |
| 6159 | + | |
| 6160 | + | |
| 6161 | + | |
| 6162 | + | |
| 6163 | + | |
| 6164 | + | |
| 6165 | + | |
| 6166 | + | |
| 6167 | + | |
| 6168 | + | |
| 6169 | + | |
| 6170 | + | |
| 6171 | + | |
0 commit comments