Repository navigation
chore(release): v1.105.2 patch - #47519
Conversation
…dget (#44277) * fix(proxy): stop queued registry read-throughs spending the resync budget RegistryReadThrough.attempt serializes misses behind one lock, but every request that was queued behind the first one still spent a unit of the 20-per-5s resync budget and re-ran the DB resync, even though the first request had already loaded the object. A burst of more than 20 requests for a model created on another worker therefore exhausted the budget and the rest got 400 "Invalid model name". attempt now checks whether the key is already loaded once it holds the lock and returns early without touching the budget. Models check the router's model names and deployment ids, guardrails and agents reuse their existing registry lookups. * test(proxy): gate the queued read-through test on events and cover each registry's loaded check The queued-requests test now holds the first resync on an asyncio.Event instead of a timed sleep and records calls in a recorder with tuple and frozenset state. New tests show the model, guardrail and agent read-throughs each answer an object that is already loaded without reading the database, so rewiring any registry's loaded check now fails a test * test(proxy): keep the queued read-through recorder inside its test and type the agent registry fixture (cherry picked from commit b877a38)
…o pricing sees the deployment model (#44341) * fix(proxy): stamp the client alias on a copy of each streamed chunk so pricing sees the deployment model Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(spend): streamed alias matching a capability rule bills the deployment price Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(spend): assert every streamed chunk carries the client alias Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(logging): log the client alias on the priced streamed response, the same as non-streamed Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: kerry <kerry@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 7b432d7)
…text (#44346) * revert(responses): revert "fix(responses): keep gpt-5.4/5.5 tool calls on chat and merge bridged tool calls into one choice" (#44295) This reverts commit ca1994e. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(responses): merge bridged tool calls into the same choice as the text Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: kerry <kerry@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 5724117)
…46099) * fix(responses): fold bridged Responses output into one chat choice A Chat Completions request bridged to /responses got one choice per Responses message item, so a reply shaped [message, message, function_call] put the tool call on choices[1] and clients reading only choices[0] never saw it. Fold every message text, annotation, reasoning item and tool call into choices[0] Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(responses): drop mutable annotations and the extra cast in the choice fold Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(responses): remove a cast-ok marker that suppressed nothing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(responses): join folded message texts with a newline Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * revert(responses): join folded message texts with no separator so stream and non-stream match Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 4b7b8ef)
…uests (#41362) The request-side sanitizer on /v1/messages dropped every thinking block whose text is empty, even with a valid signature. Claude Opus 4.8 / Fable 5 / Fable 5.1 return exactly that shape by default (thinking.display omitted): the signature is the preserved reasoning. Replaying the assistant turn as returned therefore lost the model's reasoning on every multi-turn request, silently (the provider answers 200 without it), and left preserved-thinking enforcement (thinking.block_binding) nothing to bind. Anthropic accepts an empty thinking block that carries a signature and binds it to its prefix; only an empty block with no signature (the LIT-6357 case, a turn a non-Anthropic model served through the bridge) is rejected with "each thinking block must contain thinking". Use the signature-aware predicate is_empty_unsigned_thinking_block, which #38809 already applied on the emit side, for the request side too. The unsigned case is still dropped. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 897bfea)
…block_binding (#46342) * fix(anthropic): treat adaptive thinking as enabled when mapping response_format is_thinking_enabled only recognised thinking.type=enabled, so a request that paired thinking.type=adaptive with response_format took the synthetic JSON tool path with a forced tool_choice, which Anthropic rejects alongside thinking. The same check also gates the Bedrock Converse and Databricks forced tool_choice downgrades, so they now see adaptive thinking too. * fix(anthropic): keep signed thinking blocks with empty text on chat completions Models that default to display: omitted return signed thinking blocks whose text is empty, and Anthropic rejects the next turn when they are not replayed unchanged. is_unsignable_thinking_block dropped them along with unsigned blocks, and the inline content path required non-empty text, so a tool-use turn on Opus 4.7+ or the 5 families lost its thinking blocks and 400ed on the tool-result turn. Only a missing signature now drops a block, and the mid-conversation system placement mirrors that rule. The /v1/messages strip helper is left to #41362. * fix(anthropic): skip the thinking-strip retry when block_binding asks for an error The /v1/messages retry loop strips thinking blocks and resends on any invalid-thinking 400, including the binding mismatch a caller opted into with thinking.block_binding.prefix_mismatch_behavior: error. The retry decision now sees the request body and surfaces that 400 instead of overriding the caller's choice. #42888 covers the litellm_params side. * fix(bedrock): carry thinking.block_binding through the Invoke thinking rebuilds Bedrock Invoke rebuilt the thinking param from scratch when display: updates was requested, on both the /v1/messages and chat completions paths, and the legacy enabled-to-adaptive translation plus the clear_thinking injection did the same, so thinking.block_binding never reached Bedrock. Every rebuild now spreads the caller's thinking and only overrides the keys it owns, and AnthropicThinkingParam types block_binding. The thinking-binding-controls beta was already on the Bedrock allowlist. * fix(anthropic): keep forcing the response_format tool under adaptive thinking This reverts ad9e861. Anthropic, Bedrock Invoke and Vertex all accept a forced tool_choice next to thinking.type=adaptive and only reject it with type=enabled, so counting adaptive as enabled fixed no live failure. It did drop the forced JSON tool, so Claude answered response_format requests in prose, and it downgraded a required tool_choice to auto on Bedrock Converse * test(e2e): drop the adaptive thinking tool round trip case With adaptive thinking the model often skips thinking on the weather prompt, so turn 1 carries no signed empty block and the case fails before the replay it is meant to cover. Anthropic also answers the replay with a 200 whether or not the block is forwarded, so the case could not tell the fix from main. The factory unit tests pin the outgoing shape instead * fix(anthropic): only skip the thinking-strip retry for a binding mismatch 400 prefix_mismatch_behavior: error asks Anthropic to reject a block bound to another conversation. It says nothing about unrelated bad blocks such as a null signature, so those still get the strip-and-retry self-heal. Also trims the empty-thinking docstrings to what the code guarantees and types the new test parameters * refactor(anthropic): narrow thinking fields with the mapping validator instead of typing.cast typing.cast is banned by the strict ruff gate (TID251), so the three new casts pushed that rule one over its merge-base count. The existing pydantic mapping validator gives the same typed view without an unchecked cast, and it now has a generic name since it is no longer only used for Claude Code payloads * refactor(anthropic): read thinking settings through the validated mapping so basedpyright stays at its merge-base count The Bedrock clear_thinking rewrite still narrowed with a cast and an untyped dict fallback, which added two reportUnknownVariableType errors. It now uses the same pydantic mapping validator, made public for that reuse, and the retry hook validates the request body itself so the handler passes a typed dict instead of an untyped one --------- Co-authored-by: yuneng-jiang <yuneng@berri.ai> (cherry picked from commit f470e41)
… retrieve/cancel (#47067) * fix(proxy): authorize the public name of a team-scoped model on batch retrieve/cancel A unified batch id resolves to the deployment's internal model_name (model_name_{team_id}_{uuid}), which is in no key or team allowlist, so authorize_model_for_key always denied and team keys got 403 retrieving or cancelling their own batches. Authorize against model_info team_public_model_name when the resolved deployment is team-scoped, falling back to the resolved name otherwise. Fixes #46958 * fix(proxy): authorize team-scoped batch models by their public name on both auth paths * fix(proxy): accept the owning team's public name for its own team deployment on every auth path Managed batch, file, fine-tuning, vector store, character and video ids resolve to the team deployment's internal name again, so teams that granted the internal name keep access. The model access check now also accepts the owning team's public name and its legacy team aliases for that internal name, and only when the caller's team owns the deployment. * fix(proxy): match a team deployment's public and alias names against the caller's own grants --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> (cherry picked from commit e979bd0)
…stable_1_104_x fix(count_tokens): backport October 19 fixes to stable/1.104.x (cherry picked from commit 5e4d160)
…shapes_stable_1_104_x fix(count_tokens): restore Google request compatibility on stable/1.104.x (cherry picked from commit a63df16)
…put_precedence fix(proxy): restore legacy token count input precedence (cherry picked from commit 5346a40)
litellm 1.105.1 already shipped, so the next release off this line is 1.105.2
|
@litellm-stampbot please review this nightly backport to stable/1.105.x, every pick and its gate result is in the description |
litellm-stampbot: risk highNot approved at Rules (
Judge: skipped, the rules alone decided. Pushes do not re-run this check. Comment |
…pic, Azure AI and Bedrock Invoke configs The #46342 backport carried block_binding through every subclass of the Anthropic and Bedrock Invoke configs, so Bedrock Mantle, Claude Platform and OpenAI-compatible Anthropic endpoints started sending it. Each of the six chat and messages configs now opts in by exact class, and the Bedrock Invoke display updates and clear_thinking rebuilds carry block_binding only when the config opts in. Every other config sends the same thinking as 1.105.1
|
|
TLDR
Problem this solves:
stable/1.105.xis missing 7 fixes from main and the v1.104.4 token count patchHow it solves it:
-xcherry-pick per main PR, in main merge order, plus 1 prerequisite-m 1, in their merge orderBackport
8d1d740bb9, verbatimbc05d543ca, verbatimb4a795a11c, verbatim (added prerequisite)d442ef4cbb, adaptedc2e40e31e8, verbatim05de300ed6, adapted3ed027b5a6, adapted5e4d160423picked with-m 1asde32a2a06e, adapteda63df167dapicked with-m 1asa251c0d6b4, verbatim5346a40c37picked with-m 1as422c280214, verbatim60876f2b2abumps litellm 1.105.1 -> 1.105.2, since 1.105.1 already shipped9a4884cd12fix(anthropic): carry thinking.block_binding only on the exact Anthropic, Azure AI and Bedrock Invoke configs, the second half of the fix(anthropic): keep signed empty thinking blocks and honor thinking.block_binding #46342 adaptation belowAdded prerequisites
Adaptation notes
#46099
accumulateandchaincome fromitertools, which this line's transformation module did not import yet, so the import is added (main and stable/1.103.x already have it)list_valueis added totests/integration/_support/client.pybyte for byte as on main, since the PR's integration test calls itInterdiff against main 4b7b8ef
#46342
tool_call_is_rebuilt_as_server_tool_useblock was dropped, since that helper does not exist on this line and only its rename hunk belonged to the PRoptional_paramson this line (main names itmapped_params)ChatCompletionAssistantMessage,Mappingandhttpxthat the PR's new tests use05de300ed6and the follow-up commit9a4884cd12. Only the Anthropic, Azure AI and Bedrock Invoke configs themselves carrythinking.block_bindingwhen they rebuildthinking, which covers the legacythinking.type: enabledto adaptive rebuild and Bedrock Invoke'sdisplay: updatesandclear_thinkingrebuilds, and they carry no other caller key. Configs that subclass them for other providers (Bedrock Mantle, Claude Platform, OpenAI-compatible Anthropic endpoints) opt out, so they and every other Anthropic-format provider send the samethinking1.105.1 sent, and no provider the PR does not name gets a new field. The PR's shared-helper test is replaced by tests that pin this per config on chat and/v1/messagesInterdiff against main f470e41
#47067
_check_model_access_helper: Final = check_model_access_helperalias, its helper is already named_check_model_access_helper, so the new ownership check calls that nameFinalin the batches endpoint test imports andRouterin the auth utils test importsInterdiff against main e979bd0
#47389 (the stable/1.104.x count_tokens merge)
litellm/llms/anthropic/experimental_pass_throughislitellm/llms/anthropic/pass_throughon this line. Git placed the new files in the new folder, and their imports were rewritten to the new module path in 9 filestests/test_litellm/live undertests/unit/here, with empty__init__.pyfiles in 4 new test folders (as on main) so same-named test modules do not collidetests/integration/_support/process.pykeeps this line's env-drivengraceful_stop_secondstest_utils.pycost map schema takes the union of both lines' keystest_routes_utils.pytakes fix(proxy)!: count prompt-only token_counter requests with the provider when call_endpoint is set #46839's own update of the prompt-with-tools fallback test, since the merge counts tools on the prompt path nowtoken_count_framingandtoken_count_tokenizer, plus two cost-less Databricks entries) are applied from the merge, matching main and v1.104.4. There is no other pricing change5346a40c37), and every remaining difference is either an import path or 1.105-only codeInterdiff against stable/1.104.x 5e4d160, with paths moved to this line's layout
Gate
9a4884cd12across 5 lenses, and this PR stays a draft until that review is donethinkingscoping in9a4884cd12holds. An intercepted request through every Anthropic-format config sends the samethinking1.105.1 sent, except Anthropic, Azure AI and Bedrock Invoke, which add onlyblock_bindingUser Flow
#44277
Before: right after an admin adds a model, part of a client burst for it fails with 400
openai/gpt-4o-miniand get 200Invalid model name passed in model=<name>, the rest 200After: the same burst succeeds in full
openai/gpt-4o-miniand get 200#44341
Before: a team streaming chat completions through a dotted Claude alias sees their spend and budgets stay at $0
model_name: claude-opus-4.6pointing atvertex_ai/claude-opus-4-6@default"model": "claude-opus-4.6"and"stream": true"model": "claude-opus-4.6"on every chunkAfter: the same streamed request is billed at the deployment's real price
model_name: claude-opus-4.6pointing atvertex_ai/claude-opus-4-6@default"stream": true"model": "claude-opus-4.6"on every chunk#44346
Before: an agent app sends a tools request through the proxy and the tool call lands in a second choice the app ignores
model: gpt-5.4-miniand one function toolchoices[0]holds the text "Let me check the weather." withfinish_reason: "stop"choices[1]holds theget_weathercall withfinish_reason: "tool_calls"choices[0], sees a finished answer, and never runs the toolAfter: the same request returns the text and the tool call together, so the app runs the tool
get_weathercall,finish_reason: "tool_calls"choices[0], runsget_weather, and continues the conversation#46099
Before: an agent built on a
choices[0]-only client never calls its weather toolmodel: azure/gpt-5.4-mini, aget_weathertool and noreasoning_effortget_weathercallchoices[0]is"Let me check the weather."withfinish_reason: stopand the tool call sits onchoices[1]choices[0], sees plain text, and replies to the user without running the toolAfter: the same request returns one choice with the text and the tool call together
choices[0].message.contentis"Let me check the weather. Looking up Paris now."andchoices[0].message.tool_calls[0]isget_weatherwithfinish_reason: tool_calls#41362
Before: a multi-turn tool-use loop against Claude Fable 5.1 behind the proxy loses the model's reasoning every turn
POST https://litellm-domain/v1/messagesto abedrock/us.anthropic.claude-fable-5-1(orvertex_ai//anthropic/) deployment with"thinking": {"type": "adaptive"}content: [{"type": "thinking", "thinking": "", "signature": "EqQB..."}, {"type": "text", ...}]content: [{"type": "text", ...}]; the provider answers without the earlier reasoning, and underthinking.block_bindingan edited earlier message is never reported because the block never arrivedAfter: the same replay reaches the provider intact
block_bindingan edited prefix is reported (input_transformations: [{"type": "thinking_dropped", "path": "messages.1.content.0", "reason": "prefix_binding_mismatch"}]) or rejected, as Anthropic documents. An empty block with no signature is still removed, so the LIT-6357 400 does not come back#46342
Before: a developer who pins thinking blocks to their conversation still gets a 200 when they replay a block from another conversation
anthropic-beta: thinking-binding-controls-2026-08-01"thinking": {"type": "adaptive", "block_binding": {"prefix_mismatch_behavior": "error"}}and an assistant turn holding a thinking block from an unrelated conversationTokyo.block_bindingbefore calling Bedrock, so the same replay is a 200 on /v1/messages and /v1/chat/completions tooAfter: the same replay gets the 400 the developer asked for
anthropic-beta: thinking-binding-controls-2026-08-01"thinking": {"type": "adaptive", "block_binding": {"prefix_mismatch_behavior": "error"}}and an assistant turn holding a thinking block from an unrelated conversationInvalid signature in thinking block. The block is bound to a different conversation.after one upstream callblock_bindingreaches Bedrock, and the replay gets Bedrock's same 400 on /v1/messages and /v1/chat/completionsThe same pinned request whose bad block is unrelated to binding (for example a null signature) still self-heals to a 200, and a chat completions replay of a signed thinking block with empty text now forwards that block to Anthropic instead of dropping it
#47067
Before: a team member can create a batch on their team's model but cannot check on it, cancel it, or download its results
team-batch-modelon https://litellm-domain/ui/?page=modelsteam_model_access_deniednamingmodel_name_<team id>_<uuid>, and POST .../cancel fails the same wayoutput_file_idfrom an admin, GET https://litellm-domain/v1/files/{output_file_id}/content returns 403After: the same team member checks, cancels, and downloads the results with the key that created the batch
team-batch-modelon https://litellm-domain/ui/?page=modelscompletedwith anoutput_file_id, and POST .../cancel returns 200 with statuscancellingteam-batch-model#47389
Before, counting a PDF and tool request drops most input tokens
After, the same count matches inference
#47446
Before: a developer receives 400 for a compatible Google countTokens request
/v1beta/models/gemini-3.8-flash:countTokenswith a single text system part ortools: nullInvalid Google countTokens request bodyAfter: the same developer receives a provider token count
/v1beta/models/gemini-3.8-flash:countTokenswith a single text system part ortools: nulltotalTokensandlitellm_count_source: provider#47454
Before, adding a prompt to a conversation rejects the count
After, adding a prompt preserves the conversation count
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreType
🐛 Bug Fix
Caveats (if any)
Low
/v1/messages/count_tokens400s now use Anthropic's error body shapeFinal Attestation