mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: add claude-haiku-4-5 to native structured output allowlist
claude-haiku-4-5-20251001 supports native structured output via the output_format parameter but was missing from the model substring allowlist in map_openai_params, causing it to fall back to the json_tool_call synthesis workaround. This broke downstream tool dispatch when the model also returned legitimate tool calls. Fixes https://github.com/BerriAI/litellm/issues/25308 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
62757ff48f
commit
1ef452e969
2 changed files with 41 additions and 0 deletions
|
|
@ -989,6 +989,9 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
|
|||
if any(
|
||||
substring in model
|
||||
for substring in {
|
||||
"haiku-4-5",
|
||||
"haiku-4.5",
|
||||
"haiku_4_5",
|
||||
"sonnet-4.5",
|
||||
"sonnet-4-5",
|
||||
"opus-4.1",
|
||||
|
|
|
|||
|
|
@ -447,6 +447,44 @@ def test_anthropic_tool_helper(cache_control_location):
|
|||
assert tool["cache_control"] == {"type": "ephemeral"}
|
||||
|
||||
|
||||
def test_haiku_4_5_uses_native_structured_output():
|
||||
"""
|
||||
Haiku 4.5 supports native structured output via output_format.
|
||||
It should NOT fall back to json_tool_call synthesis.
|
||||
Regression test for https://github.com/BerriAI/litellm/issues/25308
|
||||
"""
|
||||
from litellm.llms.anthropic.chat.transformation import AnthropicConfig
|
||||
|
||||
config = AnthropicConfig()
|
||||
response_format = {
|
||||
"type": "json_schema",
|
||||
"json_schema": {
|
||||
"name": "MovieReview",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"title": {"type": "string"},
|
||||
"rating": {"type": "number"},
|
||||
},
|
||||
"required": ["title", "rating"],
|
||||
},
|
||||
},
|
||||
}
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={"response_format": response_format},
|
||||
optional_params={},
|
||||
model="claude-haiku-4-5-20251001",
|
||||
drop_params=False,
|
||||
)
|
||||
# Should use native output_format, not json_tool_call
|
||||
assert "output_format" in optional_params, (
|
||||
"haiku-4-5 should use native output_format, not json_tool_call"
|
||||
)
|
||||
assert "tools" not in optional_params or not any(
|
||||
t.get("name") == "json_tool_call" for t in optional_params.get("tools", [])
|
||||
), "haiku-4-5 should not synthesize a json_tool_call"
|
||||
|
||||
|
||||
def test_create_json_tool_call_for_response_format():
|
||||
"""
|
||||
tests using response_format=json with anthropic
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue