Skip to content

fix: drop effort parameter for Haiku with azure_ai provider - #31188

Closed
dsteeley wants to merge 8 commits into
BerriAI:litellm_internal_stagingfrom
dsteeley:haiku-azure
Closed

fix: drop effort parameter for Haiku with azure_ai provider#31188
dsteeley wants to merge 8 commits into
BerriAI:litellm_internal_stagingfrom
dsteeley:haiku-azure

Conversation

@dsteeley

@dsteeley dsteeley commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes !31187

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

Type

🐛 Bug Fix

Changes

Following the vertex provider fix. Drop effort when sending requests to Azure AI hosted Haiku models.

@dsteeley
dsteeley requested a review from a team June 24, 2026 11:50
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a 400 error from Azure AI Foundry when output_config.effort is forwarded to models like Claude Haiku 4.5 that don't support it. The fix introduces a shared sanitize_azure_anthropic_output_params utility that drops effort for models without supports_output_config in the model map (using the existing AnthropicConfig._model_supports_effort_param lookup) and applies it to both the chat-completion and Anthropic Messages pass-through transformation paths.

  • New output_params_utils.py — leaf module providing sanitize_azure_anthropic_output_params, which correctly delegates capability checks to the model map rather than hardcoding model names, following the repo's established pattern.
  • Two transformation entry points patchedAzureAnthropicConfig.transform_request and AzureAnthropicMessagesConfig.transform_anthropic_messages_request both now call the sanitizer, ensuring the fix covers both the OpenAI-compatible path and the native Anthropic Messages pass-through path.
  • Tests — seven unit tests in a new file cover all sanitizer branches; integration-style tests added to the two existing transformation test files; all are mock-only with no real network calls.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to stripping an unsupported request parameter for Azure AI Anthropic models and leaves all other request paths untouched.

The sanitization logic reads capability flags from the model map rather than hardcoding model names, so it will automatically handle future models without code changes. Both affected transformation paths are covered, tests exercise all branches, and the proof-of-fix curl output confirms the 400 is resolved. No logic regressions or backwards-incompatible changes.

No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/azure_ai/anthropic/output_params_utils.py New shared utility that strips output_config.effort for models that don't support it; delegates to AnthropicConfig._model_supports_effort_param which reads from the model map — correctly follows the no-hardcoded-model-flags rule.
litellm/llms/azure_ai/anthropic/transformation.py Calls sanitize_azure_anthropic_output_params after the parent transform_request to drop unsupported effort params; straightforward and correctly placed.
litellm/llms/azure_ai/anthropic/messages_transformation.py Same sanitization applied to the Anthropic Messages pass-through path; correctly placed after _remove_scope_from_cache_control.
tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_output_params_utils.py New unit tests covering all branches of sanitize_azure_anthropic_output_params: drops effort for unsupported models, preserves for supported, handles non-dict and missing output_config. All mock-only, no real network calls.
tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_transformation.py Adds regression tests for transform_request, verifying effort is stripped for Haiku 4.5 and preserved for Sonnet 4.6.
tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_messages_transformation.py Adds similar regression tests for the Messages pass-through path; no real network calls.

Reviews (3): Last reviewed commit: "chore: further markups" | Re-trigger Greptile

Comment thread litellm/llms/azure_ai/anthropic/transformation.py Outdated
@dsteeley dsteeley changed the title fix: Drop effort parameter for Haiku with azure_ai provider fix: drop effort parameter for Haiku with azure_ai provider Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dsteeley

dsteeley commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

@Sameerlite

Copy link
Copy Markdown
Contributor

Thanks for the fix, @dsteeley! A couple of things to help move this along:\n- Proof of working — could you share some evidence the fix works? Even a quick before/after snippet showing the 400 error disappearing, a test run output, or a curl example against an Azure AI Haiku model would be great.\n- Triggering a fresh Greptile review against the current head to get an up-to-date score.\n\n@greptileai

@dsteeley

Copy link
Copy Markdown
Contributor Author

Thanks for the fix, @dsteeley! A couple of things to help move this along:\n- Proof of working — could you share some evidence the fix works? Even a quick before/after snippet showing the 400 error disappearing, a test run output, or a curl example against an Azure AI Haiku model would be great.\n- Triggering a fresh Greptile review against the current head to get an up-to-date score.\n\n@greptileai

@Sameerlite Here's me running a direct curl against azure_ai before and after my proposed fix.

Before:
curl -s -X POST http://localhost:4000/v1/messages -H "Content-Type: application/json" -d '{"model": "azure-haiku-4-5", "max_tokens": 64, "messages": [{"role": "user", "content": "say hi"}],"output_config": {"effort": "medium"}}' {"error":{"message":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This model does not support the effort parameter.\"},\"request_id\":\"req_011CcPbrxzbpBnomxynWNHxX\"}. Received Model Group=azure-haiku-4-5\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"400"}}
After:
curl -s -X POST http://localhost:4000/v1/messages -H "Content-Type: application/json" -d '{"model": "azure-haiku-4-5", "max_tokens": 64, "messages": [{"role": "user", "content": "say hi"}],"output_config": {"effort": "medium"}}' {"model":"azure-haiku-4-5","id":"msg_01ABGRsrHECfjpjyCQJjjj4E","type":"message","role":"assistant","content":[{"type":"text","text":"Hi! 👋 How's it going?"}],"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":9,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":14,"service_tier":"standard","inference_geo":"not_available"}}d

@greptileai

@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing dsteeley:haiku-azure (3b7ab86) with litellm_internal_staging (423b791)

Open in CodSpeed

Fixes TypeError from the PR BerriAI#31188 test failures and clears the
LIT001/LIT011 lint budget violations flagged in output_params_utils.py.
@mateo-berri

Copy link
Copy Markdown
Contributor

Thanks! The messages path is already fixed upstream by #32867, translating effort to legacy thinking. Residual chat-only case is non-standard, so closing. Appreciate the contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants