mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(mcp): skip hanging alert tracking for tool calls
This commit is contained in:
parent
bf02a4a47f
commit
dd7bc06306
2 changed files with 22 additions and 1 deletions
|
|
@ -1349,7 +1349,8 @@ class ProxyLogging:
|
|||
"""
|
||||
verbose_proxy_logger.debug("Inside Proxy Logging Pre-call hook!")
|
||||
|
||||
self._init_response_taking_too_long_task(data=data)
|
||||
if call_type != CallTypes.call_mcp_tool.value:
|
||||
self._init_response_taking_too_long_task(data=data)
|
||||
|
||||
if data is None:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import litellm
|
|||
from litellm.exceptions import RejectedRequestError
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
from litellm.proxy.utils import ProxyLogging
|
||||
from litellm.types.utils import CallTypes
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -102,6 +103,25 @@ async def test_pre_call_hook_returns_none_for_none_data(proxy_logging, make_user
|
|||
assert out is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pre_call_hook_does_not_track_mcp_tool_as_hanging_request(
|
||||
proxy_logging, make_user_api_key_auth, mock_callbacks_disabled
|
||||
):
|
||||
data = {"messages": [{"role": "user", "content": "Tool: search"}], "model": "mcp-tool-call"}
|
||||
proxy_logging.slack_alerting_instance = MagicMock()
|
||||
proxy_logging.slack_alerting_instance.alerting = ["slack"]
|
||||
proxy_logging.slack_alerting_instance.response_taking_too_long = AsyncMock()
|
||||
|
||||
out = await proxy_logging.pre_call_hook(
|
||||
user_api_key_dict=make_user_api_key_auth(),
|
||||
data=data,
|
||||
call_type=CallTypes.call_mcp_tool.value,
|
||||
)
|
||||
|
||||
assert out is data
|
||||
proxy_logging.slack_alerting_instance.response_taking_too_long.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pre_call_hook_invokes_pre_call_override(proxy_logging, make_user_api_key_auth, monkeypatch):
|
||||
captured: Dict[str, Any] = {}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue