fix: avoid MCP follow-up helper collision

This commit is contained in:
tarunag10 2026-08-20 13:07:52 +05:30
parent cf8a18ee7b
commit 05d4996a41
4 changed files with 6 additions and 8 deletions

View file

@ -453,9 +453,7 @@ async def acompletion_with_mcp(
)
# Make follow-up call with streaming
follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(
self.base_call_args
)
follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(self.base_call_args)
follow_up_call_args["messages"] = follow_up_messages
follow_up_call_args["stream"] = True
# Ensure follow-up call doesn't trigger MCP handler again
@ -627,7 +625,7 @@ async def acompletion_with_mcp(
)
# Make follow-up call with original stream setting
follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(base_call_args)
follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(base_call_args)
follow_up_call_args["messages"] = follow_up_messages
follow_up_call_args["stream"] = stream

View file

@ -72,7 +72,7 @@ class LiteLLM_Proxy_MCP_Handler:
"""
@staticmethod
def _prepare_follow_up_call_params(params: Mapping[str, Any]) -> dict[str, Any]:
def _prepare_chained_call_params(params: Mapping[str, Any]) -> dict[str, Any]:
"""Copy request params without state owned by the previous LLM call.
MCP auto-execution keeps the trace identifier so chained rounds remain

View file

@ -782,7 +782,7 @@ class MCPEnhancedStreamingIterator(BaseResponsesAPIStreamingIterator):
)
# Make follow-up call with streaming
follow_up_params: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(
follow_up_params: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(
self.original_request_params
)
follow_up_params.update(

View file

@ -444,7 +444,7 @@ async def test_execute_tool_calls_uses_unique_call_ids_and_preserves_parent_cont
assert all(item["metadata"]["parent_litellm_call_id"] == "cid" for item in captured)
def test_prepare_follow_up_call_params_resets_per_call_logging_state():
def test_prepare_chained_call_params_resets_per_call_logging_state():
original = {
"model": "gpt-4",
"litellm_call_id": "parent-call",
@ -457,7 +457,7 @@ def test_prepare_follow_up_call_params_resets_per_call_logging_state():
},
}
follow_up = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(original)
follow_up = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(original)
assert "litellm_call_id" not in follow_up
assert "litellm_logging_obj" not in follow_up