mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
* fix(messages): honor an explicit output_config.effort beside a thinking budget on the Responses bridge * fix(messages): fall back to the thinking budget when the target drops the explicit effort Under drop_params, an output_config.effort beside enabled thinking that the deployment's declared levels or the target's own reasoning gate would drop now counts as never sent, so the budget's effort goes out with exactly one drop warning. Adaptive thinking keeps the base behavior, and without drop_params the explicit effort still goes out as before The chat adapter path (stop_sequences or use_chat_completions_url_for_anthropic_messages) now lets an explicit effort beat the budget on non-Claude, non-Bedrock targets under the same rule, judged by the gate of the route the request takes * fix(messages): limit the explicit effort on the chat route to GPT reasoning targets On enabled thinking through the chat adapter, an explicit output_config.effort now beats the budget only when the request ends on the Responses API or the target's chat config is the GPT reasoning config. Gemini, Vertex Gemini, xAI, DeepSeek, Kyma and every other target send the budget's effort again, the same as before the explicit effort could win there When the request stays on Chat Completions, the drop_params pre-check counts a route-specific level (max) as refused. So the budget's effort goes out with one drop warning instead of a max that Azure answers with a 400. Without drop_params max still goes out as sent, the same as /v1/chat/completions The pre-check reads base_model only where completion does, which is Azure today (LOOKS_UP_BASE_MODEL), and uses the deployment model everywhere else, so the pre-check and the real gate judge the same row. The messages handler reads base_model from the request kwargs or the deployment's model_info the way completion does, so azure/prod-reasoner with base_model azure/gpt-5 is gated as gpt-5, while an openai deployment keeps its own config and row whatever its base_model says Bedrock non-Claude models such as Nova and gpt-oss keep the budget because their resolved provider's chat config is not the GPT reasoning config, with or without a bedrock/ prefix on the model. bedrock_mantle/openai.gpt-6-sol resolves to the Mantle chat config and keeps the budget for the same reason. Disabled thinking beside an explicit effort still sends what disabled thinking alone sends, now under a test * fix(messages): let an explicit effort lower the thinking budget's effort, never raise it Beside thinking.budget_tokens, an explicit output_config.effort now goes out only when it is at or below the level the budget maps to (none < minimal < low < medium < high < xhigh < max), on both the Responses bridge and the chat adapter. A higher level sends the budget's effort with no drop warning, as before the explicit effort was read. The check uses the budget's own level, before any deployment rounding A value that is not a known level keeps its handling. The budget's effort is now always computed, so a malformed budget_tokens raises without drop_params and logs its drop warning with it, whatever the explicit effort is Azure o-series deployments join the chat-route check and refuse no level, the same as completion with AzureOpenAIO1Config. The chat gate's max refusal is removed because max can no longer reach it beside a budget * fix(messages): never send an explicit effort above the budget's after rounding The budget check now compares the level that would go out, after the explicit effort is lowered or raised onto what the model accepts, with the budget's own level. Before, minimal beside a 1024 budget passed the check and then went out as medium on models without minimal and low (gpt-5.5-pro, chat-latest), where the budget alone sends low or answers 400. Now those requests send exactly what the budget alone sends, on both the chat adapter and the Responses bridge. A level the deployment's own reasoning_effort_levels name is compared as sent, since completion rounds it onto those levels A translation with no provider (the shadow eval logger, the guardrail translation, adapter_completion) keeps the budget's effort beside an explicit one, as it did before the explicit effort was read. The chat route no longer guesses the provider from the model name for this check * fix(messages): keep the budget's effort for levels o-series refuses and for default An o-series target now refuses every explicit output_config.effort other than low, medium and high unless its map row opts in to that level, on both the Responses bridge and the chat adapter. Under drop_params the thinking budget's effort goes out in its place, and without drop_params the request answers 400 An explicit default beside an enabled thinking budget now sends the budget's effort on every target, as it did before this branch Plain /v1/responses and /v1/chat/completions calls are unchanged * fix(messages): keep the budget's effort beside a malformed thinking budget An explicit output_config.effort beside budget_tokens now applies only when the budget is a whole number of at least one token (an integral float counts, a bool never does). An inf, nan, zero, negative, fractional or missing budget sends exactly what the same request without output_config sends, on the Responses bridge and the chat route, with the same 400 or drop warning The gate reads the thinking block itself, so no caller can rank an explicit level against an effort derived from a malformed budget * fix(cost-map): mark the reasoning levels OpenAI refuses on gpt-5-pro, gpt-5.2-pro and gpt-5.4-pro * fix(messages): let a cost map entry's declared levels refuse an explicit effort beside a budget * fix(cost-map): mark Azure gpt-5-pro as taking only high reasoning effort Azure's reasoning guide says gpt-5-pro supports only reasoning_effort high, so the row now lists high as its only level and marks minimal and low unsupported, matching the OpenAI gpt-5-pro row * fix(messages): honor an explicit output_config.effort beside a thinking budget An explicit effort at or below the budget's effort now reaches GPT and o-series models through both the Responses and chat bridges. A stronger effort keeps the budget's effort, and one the target drops under drop_params falls back to the budget * fix(messages): drop an unknown output_config.effort under drop_params on the chat bridge With drop_params set, an output_config.effort that no reasoning API defines now falls back to the thinking budget's effort on the chat completions bridge, the same way the Responses bridge and the messages handler already drop it. Before this, the bridge forwarded the value and Gemini answered 400 even with drop_params set, where the merge base sent the budget's effort and answered 200 The unit case that pinned forwarding an unknown effort ran under the default drop_params=True, so it now runs under both settings, forwarding without drop_params and falling back to the budget with it * fix(messages): send the budget's effort when the model refuses or rounding raises the explicit one An explicit output_config.effort that the model's cost map row refuses now falls back to the thinking budget's effort under drop_params on the chat completions bridge, as the Responses bridge already did. On the Responses bridge an explicit effort that rounds above the budget's effort, like minimal on a model without minimal or low, sends what the budget alone sends. The OpenAI, Azure and Azure AI rows for gpt-5-pro, gpt-5.2-pro, gpt-5.4-pro and the dated gpt-5.5-pro now mark minimal and low unsupported, and gpt-5-pro lists only high, matching the values OpenAI's 400s list for each model. * fix(messages): find a refused effort through base_model, keep side callers quiet, and let the budget decide beside default * fix(messages): send the budget's effort on the chat bridge when rounding would raise the explicit one past it * fix(messages): round an explicit effort before checking the cost map on the chat bridge under drop_params * fix(messages): round an explicit effort with the deployment's base_model levels A custom-named deployment with a base_model rounded minimal against its own name, which has no cost map row, so it fell to low. The cost map check then read base_model, refused low, and sent the budget's effort under drop_params, or sent low to a model that rejects it without drop_params. Rounding now reads the same base_model levels as the check on both the Responses and chat routes. --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| batches | ||
| chat | ||
| files | ||
| messages | ||
| pass_through | ||
| __init__.py | ||
| anthropic_docs_refusal.py | ||
| test_anthropic_common_utils.py | ||
| test_anthropic_count_tokens_transformation.py | ||
| test_anthropic_files_and_batches.py | ||
| test_anthropic_output_format_filter.py | ||
| test_anthropic_prompt_cache_prediction.py | ||
| test_anthropic_prompt_cache_pricing.py | ||
| test_anthropic_reasoning_effort.py | ||
| test_anthropic_schema_filter.py | ||
| test_anthropic_structured_output.py | ||
| test_anthropic_wif.py | ||
| test_azure_ai_cache_pricing.py | ||
| test_cost_calculation_dict_safety.py | ||
| test_count_tokens_oauth.py | ||
| test_message_sanitization.py | ||
| test_messages_http_error_retry_cases.py | ||