The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge pull request #23222 from BerriAI/litellm_oss_staging_02_18_2026
Sameer Kankute9bc7357e7ca2
diff --cc litellm/responses/litellm_completion_transformation/transformation.pyindex d901bbc2105,1ab5d7bf239..a99c2a8ed54--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@@ -384,45 -384,10 +384,45 @@@ class LiteLLMCompletionResponsesConfigif call_id_raw:existing_tool_call_ids.add(str(call_id_raw))+ #########################################################+ # Merge consecutive function_call items into a single assistant+ # message. Anthropic requires that all tool_use blocks appear in+ # ONE assistant message immediately followed by the tool_result+ # blocks. Without this merging, each function_call creates its own+ # assistant message, producing back-to-back assistant messages that+ # Anthropic rejects with "tool_use ids were found without+ # tool_result blocks immediately after".+ #########################################################+ if messages:+ last_msg = messages[-1]+ last_role = (+ last_msg.get("role")+ if isinstance(last_msg, dict)+ else getattr(last_msg, "role", None)+ )+ if last_role == "assistant":+ for new_msg in chat_completion_messages:+ new_role = (+ new_msg.get("role")+ if isinstance(new_msg, dict)+ else getattr(new_msg, "role", None)+ )+ if new_role == "assistant":+ new_tcs = (+ new_msg.get("tool_calls")+ if isinstance(new_msg, dict)+ else getattr(new_msg, "tool_calls", None)+ ) or []+ for tc in new_tcs:+ LiteLLMCompletionResponsesConfig._add_tool_call_to_assistant(+ last_msg, tc+ )+ continue+########################################################## If Input Item is a Tool Call Output, add it to the tool_call_output_messages list- # preserving the ordering of tool call outputs. Some models require the tool- # result to immediately follow the assistant tool call.+ # preserving the ordering of tool call outputs. Some models require the tool+ # result to immediately follow the assistant tool call.#########################################################if LiteLLMCompletionResponsesConfig._is_input_item_tool_call_output(input_item=_input