mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(anthropic): keep tool_use ids for non-Anthropic backends on /v1/messages Since v1.91.0 every /v1/messages request rewrote tool ids to Anthropic's ^[a-zA-Z0-9_-]+$ pattern, so Kimi on vLLM got functions_Bash_0 back for its own functions.Bash:0 and stopped calling tools The anthropic provider now rewrites only for a Claude model or an api_base that serves Anthropic's API (api.anthropic.com or Foundry, explicit or from ANTHROPIC_API_BASE / ANTHROPIC_BASE_URL), in Python and Rust. Every other native provider keeps the rewrite. Chat-bridged providers send and return the provider's own tool call ids, with only the Gemini thought suffix stripped * fix(anthropic): rename tool_use ids on Bedrock and Azure AI, skip logins when deciding A Bedrock application inference profile ARN or an Azure AI deployment name can serve Claude without saying so, and Bedrock rejects ids like functions.Bash:0, so both providers always rename The check now resolves the provider the way request metadata does, so a github_copilot or chatgpt model never starts that provider's login just to decide whether to rename * fix(anthropic): keep caller tool_use ids unless the upstream rejects them Rename tool_use ids up front only for Anthropic's own hosts and Foundry, Bedrock, Azure AI and providers with a native messages config, in Python and Rust, with the claude model name shortcut removed When an upstream answers 400 with a tool_use id pattern mismatch, native /v1/messages (Python and Rust), the chat-bridged adapter and anthropic chat completions resend once with renamed ids. The retry fires only when renaming changes the request and composes with the thinking and strict tools retries, so the attempt cap is now 3 and the thinking retry also fires only when stripping changes the request Token counting follows the same per-deployment decision so counts match the ids that are sent * fix(anthropic): rename ids when counting tokens, allow four attempts, fill empty tool ids Token counting renames tool_use ids again for every deployment, as it did before this branch, since a count has no resend and a Claude gateway rejects the caller's ids there The messages retry cap is 4 in Python and Rust, so the strict-tools drop, the tool_use id resend and the thinking strip can all fire on one request A tool call that comes back without an id, or with only a thought signature, gets a generated id on the streamed and non-streamed paths, so two such calls never share one * test(anthropic): cover function results and an unresolvable model in the tool id decision * fix(anthropic): keep caller tool ids through guardrail rewrites and the global api_base * fix(anthropic): send an empty tool id as tool_use_id when keeping caller ids --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| routes | ||
| __init__.py | ||
| test_cache.py | ||
| test_cache_invalidation.py | ||
| test_callbacks_legacy_python.py | ||
| test_model_capabilities.py | ||
| test_model_cost.py | ||
| test_preflight.py | ||
| test_redis_credentials.py | ||
| test_redis_events.py | ||
| test_route_groups.py | ||
| test_secret_manager.py | ||
| test_settings.py | ||