mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix: avoid MCP follow-up helper collision
This commit is contained in:
parent
cf8a18ee7b
commit
05d4996a41
4 changed files with 6 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue