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
fix(responses): requalify echoed namespace tool calls with their flattened name
Mateo Wangca14e52b08b0
diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex 11ea495008c..42aea1d0e62 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -1223,11 +1223,13 @@ class LiteLLMCompletionResponsesConfig:if not raw_arguments and function_call.get("type") == "custom_tool_call":raw_input: Final = function_call.get("input") or ""raw_arguments = json.dumps({"content": raw_input}) if raw_input else ""+ raw_name: Final = function_call.get("name") or ""+ namespace: Final = function_call.get("namespace") or ""tool_call: Final = ChatCompletionToolCallChunk(id=function_call.get("call_id") or function_call.get("id") or "",type="function",function=ChatCompletionToolCallFunctionChunk(- name=function_call.get("name") or "",+ name=f"{namespace}__{raw_name}" if namespace else raw_name,arguments=str(raw_arguments or ""),),index=0,diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.pyindex 0fec2d8601c..a82bdf40eed 100644--- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py+++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py@@ -1843,6 +1843,21 @@ class TestToolTransformation:assert "mcp__everything__get_sum" in json.dumps(result_tools)+ def test_function_call_echo_requalifies_namespace_tool_name(self):+ """Codex echoes restored history items as short name plus namespace; the+ outbound chat tool_call must use the flattened name the provider was given."""+ messages = LiteLLMCompletionResponsesConfig._transform_responses_api_function_call_to_chat_completion_message(+ function_call={+ "type": "function_call",+ "name": "get_sum",+ "namespace": "mcp__everything",+ "call_id": "call_1",+ "arguments": '{"a": 21, "b": 21}',+ }+ )++ assert messages[0]["tool_calls"][0]["function"]["name"] == "mcp__everything__get_sum"+@pytest.mark.parametrize("nested", [True, False])def test_transform_namespace_tools_preserves_allowed_callers(self, nested):function_tool = {diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_tool_output_order_preserved_for_gemini.py b/tests/test_litellm/responses/litellm_completion_transformation/test_tool_output_order_preserved_for_gemini.pyindex e03a1fcc08c..3a1c77d1dab 100644--- a/tests/test_litellm/responses/litellm_completion_transformation/test_tool_output_order_preserved_for_gemini.py+++ b/tests/test_litellm/responses/litellm_completion_transformation/test_tool_output_order_preserved_for_gemini.py@@ -90,7 +90,8 @@ def test_assistant_message_after_tool_call_is_folded_into_it():},{"type": "function_call",- "name": "mcp__everything__get_sum",+ "name": "get_sum",+ "namespace": "mcp__everything","call_id": "call_1","arguments": '{"a":21,"b":21}',},