mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* feat(anthropic-messages): per-deployment deferred_tools handling on the /v1/messages bridge model_info.deferred_tools picks passthrough, native or drop for tools Claude Code sends with defer_loading. native routes through the Responses API with client tool search so a tool load keeps the prompt cache. drop stays the default and no longer leaks defer_loading into the tool schema * feat(anthropic-messages): emulate deferred tools with a dispatcher on chat-only backends * fix(anthropic-messages): import deferred tool emulation lazily and restore only deferred tools * fix(anthropic-messages): tighten deferred_tools native routing and tool search replay native now needs a provider with client tool search (azure, fireworks_ai, openai) and wins over the global chat completions flag. ToolSearch results keep their text and is_error state, a forced ToolSearch tool_choice answers 400 or drops, emulate forces a deferred tool through the dispatcher, sync emulate streams work, and an unknown deferred_tools value is refused on every route * fix(anthropic-messages): refuse deferred_tools values a route cannot apply and quote tool search text A provider served through its own /v1/messages API now answers 400 for any deferred_tools value but passthrough, and passthrough on OpenAI answers 400 since OpenAI rejects defer_loading without its own tool search. Both fall back under drop_params. count_tokens routes a native deployment the way its messages call goes. A ToolSearch result's text replays as a quoted string labeled as tool output * fix(anthropic-messages): drop native on Fireworks, refuse passthrough on Azure, and name loaded tools under passthrough Fireworks' Responses tool search still bills deferred tools as prompt input, so native now answers 400 there like any provider without client tool search. passthrough answers 400 on Azure as it does on OpenAI, since both reject defer_loading outside their own tool search. Every deferred_tools fallback under drop_params now logs one warning naming the setting, because Claude Code requests get drop_params on by default and never see the 400. Under passthrough a ToolSearch result's tool_reference blocks reach a chat backend as text naming each loaded tool, instead of an empty tool result. drop keeps main's handling. * fix(anthropic-messages): keep emulate calls to the forced or loaded tool, close sync streams, and refuse passthrough on Mistral Under emulate, a CallLoadedTool call now comes back to the client only when it names a deferred tool that a ToolSearch result in the request loaded, or the tool that tool_choice forced. A forced deferred tool also limits the dispatcher's name to that tool. Any other call stays a CallLoadedTool call, so the client never runs a tool it did not load or force The dispatcher takes the first CallLoadedTool name the caller's tools do not use, and closing a restored sync stream closes the provider stream too, before or during iteration passthrough on mistral answers 400 naming the setting, or falls back to drop under drop_params, since Mistral's chat API answers 422 on deferred tools * fix(anthropic-messages): answer 400 for strict deferred tools under emulate Under emulate a loaded tool's arguments reach the model as the dispatcher's free-form input, so the provider cannot enforce strict input for it. A deferred tool with strict set now answers 400 naming the setting, or goes without strict under drop_params with the fallback warning, the way an unsupported strict already drops elsewhere. Claude Code sends no strict, so its sessions are unaffected * fix(anthropic): bill a dropped emulate stream on the Responses route The emulate stream wrapper forwarded attributes through __getattr__, which the proxy's runtime-checkable disconnect billing protocol does not see, so a client that dropped a streamed /v1/messages request on an openai/ deployment set to emulate logged no spend. The wrapper now passes on the inner stream's partial_response_on_disconnect * fix(anthropic): refuse deferred_tools passthrough where the provider request drops defer_loading * fix(anthropic): treat Bedrock native chat as Converse for deferred_tools passthrough and fall back to drop there Under drop_params, passthrough on Bedrock Converse, Bedrock native chat, Gemini and Vertex Gemini (vertex_ai_beta included) now sends the same request drop sends * fix(anthropic): read base_model and api_base when routing deferred_tools passthrough on Vertex A Vertex deployment that reaches Gemini through base_model or a numeric PSC endpoint with api_base now gets the same passthrough refusal and drop_params fallback as a gemini model name * fix(anthropic): check the provider-local model for Vertex PSC and keep non-string tool names out of set lookups * fix(anthropic): load each tool once per tool search result and mark loop locals final * fix(anthropic): skip defer_loading in tool token counts and ignore a non-object tool_choice on deferred tool routes * fix(anthropic): answer 400 when native deferred tools meet stop_sequences instead of silently dropping tool search The Responses API has no stop_sequences, so a native request carrying them went to chat completions with deferred tools sent the drop way. It now answers 400 naming the way out, and under drop_params falls back with a warning * fix(anthropic): refuse native stop_sequences only when the request carries ToolSearch Without the ToolSearch tool, native sends deferred tools the drop way on the Responses API too, so a stop_sequences request has no tool search to lose and goes to chat completions as before * fix(anthropic): keep deferred tools usable through cache injection, guardrails, native replays and emulate The tool_config cache point now skips tools with defer_loading, since Anthropic refuses a deferred tool that carries cache_control. When a guardrail removes the tool search tool, the tools it kept go up without defer_loading, so they stay callable. A native replay sends a tool's schema only in the first tool_search_output that loads it. Emulate restores a CallLoadedTool call to any tool the client declared without deferring it. native with stop_sequences refuses only when the request has tool search and at least one deferred tool * fix(anthropic): keep strict tools out of emulate's dispatcher restore A CallLoadedTool call carries free-form input, so restoring it to a strict tool would skip that tool's schema. Such a call now goes back unchanged, like a call naming an unknown tool, and the model retries with the tool itself. The tool_config cache point test now records the request at the wire instead of replacing the handler --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| cache | ||
| chat_completions | ||
| embeddings | ||
| messages | ||
| ocr | ||
| responses | ||
| support | ||
| tokenizer | ||
| AGENTS.md | ||
| conftest.py | ||
| test_clickhouse_spend.py | ||
| test_dispatch.py | ||
| test_fork_guard.py | ||
| test_public_entries.py | ||