fix(model_prices): add supports_native_structured_output to claude-haiku-4-5 direct API entries - #31221
Conversation
|
|
Greptile SummaryAdds
Confidence Score: 4/5The targeted fix is correct and narrow; the only risk is merge conflicts from the unrelated whole-file reformat. Both model_prices_and_context_window.json — confirm the whole-file reformat is intentional before merging to avoid conflict churn with other open PRs targeting this file.
|
| Filename | Overview |
|---|---|
| model_prices_and_context_window.json | Added supports_native_structured_output: true to claude-haiku-4-5-20251001 and claude-haiku-4-5; also reformatted the entire file from 4-space to 2-space indentation and normalized some number formats (semantically equivalent) |
Comments Outside Diff (1)
-
model_prices_and_context_window.json, line 1 (link)Unintended whole-file reformat outside stated scope
The PR description says "No code changes" but the diff re-indents the entire file from 4-space to 2-space JSON indentation and normalises number literals (e.g.,
0.000003→3e-06). While every numeric value remains mathematically equivalent, a ~43k-line formatting churn will conflict with any other open PRs that touch this file. Consider reverting the formatting change and committing only the two targeted entries, or documenting the reformat as intentional.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "fix(model_prices): add supports_native_s..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Retargeted base branch from |
a4b1b26 to
0df8bb7
Compare
|
Rebased onto the current |
|
Thanks for this targeted fix, @adhavan18 — filling in the missing |
|
@Sameerlite — addressed both open items: 1. JSON whole-file reformat — reverted (commit deab51a) Replaced the reformatted file with the current
The diff is now ~4 lines instead of ~80 K lines, and won't conflict with other in-flight PRs touching this file. 2. Verification # After the change, both entries return True
import litellm
assert litellm.utils.supports_native_structured_output('claude-haiku-4-5-20251001', custom_llm_provider='anthropic') is True
assert litellm.utils.supports_native_structured_output('claude-haiku-4-5', custom_llm_provider='anthropic') is True
# Existing Bedrock/regional variants are unchanged
assert litellm.utils.supports_native_structured_output('bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0', custom_llm_provider='bedrock') is True3. CI failures ( The failing test suite requires live API keys that are not forwarded to fork PRs by GitHub Actions. The same workflow passes on Note: CLA still needs to be signed at https://cla-assistant.io/BerriAI/litellm?pullRequest=31221. |
|
CI status update: the |
|
FYI: This PR has all CI checks passing. The only outstanding item is the CLA — I will sign that to unblock merging. |
|
Thanks @Sameerlite! Re: JSON whole-file reformat concern — The PR diff only has 90 changed lines in Re: verification — Ran locally with from litellm.utils import _supports_factory
print(_supports_factory("claude-haiku-4-5-20251001", "anthropic", "supports_native_structured_output")) # True
print(_supports_factory("claude-haiku-4-5", "anthropic", "supports_native_structured_output")) # TrueRe: CI failure — Same |
|
Thanks @Sameerlite — all three addressed: 1. Reformat reverted. Reset the file back to base and re-applied only the two targeted entries, so the diff is now just the 2. Backup sync — this is why it was not taking effect. litellm reads the bundled 3. Verification: On misc / Run tests — same as on my other PRs, it is the unrelated |
|
@Sameerlite following up — all three review points are addressed: the whole-file reformat is reverted (diff is now just the two targeted entries), the bundled backup JSON is synced (which was why the flag was not taking effect at runtime), and the verification snippet returns |
…iku-4-5 direct API entries Adds the flag to both claude-haiku-4-5 and claude-haiku-4-5-20251001 in the root pricing file and the bundled backup (litellm reads the backup in local mode, so both must be in sync for supports_native_structured_output() to return True at runtime).
dcaa5d6 to
2a4140c
Compare
|
Re-verified this against the current base today, since the base moved to Both entries are still there with So the fix is still live, and the diff is now only the four added lines, two per file. Mergeable state is All three of your earlier points are addressed: the whole-file reformat is reverted, the bundled backup is synced (that was the reason the flag did not take effect at runtime, since local mode reads the backup), and the verification returns No rush at all, and I realise a metadata flag is low on the queue. Flagging mainly because it is a four-line data change that will keep silently drifting out of date while it sits. Happy to rebase if it picks up a conflict. |
|
still relevant. same note as #31211: only 3 checks have ever run on this one (PR title, CodeRabbit, Veria), because fork PRs need a maintainer to approve the workflow run, so the full suite has never executed. could someone approve it? this is a model_prices json addition so it should be quick to verify once |
|
recheck |
1 similar comment
|
recheck |
|
Superseded by rolling registry PR #38207, whose branch already carries both supports_native_structured_output flags, confirmed against Anthropic's structured outputs docs |
Summary
Fixes #25308
Root cause
claude-haiku-4-5-20251001andclaude-haiku-4-5(the direct Anthropic API model IDs) were missingsupports_native_structured_output: trueinmodel_prices_and_context_window.json, even though the model supports it (all the Bedrock and regional cross-region variants already had the flag set correctly).When a caller passes
response_format=SomePydanticModeltolitellm.completionwith one of these model IDs, litellm falls back to synthesising ajson_tool_callinstead of forwarding the request natively. This causes issues when the call also has real tools —_should_convert_tool_call_to_json_modeonly strips the synthetic wrapper when there is exactly one tool call, so legitimatetool_callsleak into the response alongsidejson_tool_call.Fix
Add
"supports_native_structured_output": trueto:claude-haiku-4-5-20251001claude-haiku-4-5No code changes; the existing
supports_native_structured_output()helper already routes throughmodel_prices_and_context_window.json.Verification
After this change,
litellm.utils.supports_native_structured_output("claude-haiku-4-5-20251001")returnsTrue, andresponse_formatis forwarded natively to the Anthropic API instead of being wrapped in a synthetic tool call.