Skip to content

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]

chore(techdebt): clear fresh debt from the 2026-09-01 window

mateo1400070d711f
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json
index 2d4adc02234..f14f8e002dd 100644
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@ -57,7 +57,7 @@
"limit": 5601
},
"reportMissingTypeArgument": {
- "limit": 15300
+ "limit": 15298
},
"reportMissingTypeStubs": {
"limit": 40
@@ -105,13 +105,13 @@
"limit": 109
},
"reportUnknownMemberType": {
- "limit": 38347
+ "limit": 38344
},
"reportUnknownParameterType": {
"limit": 19626
},
"reportUnknownVariableType": {
- "limit": 29884
+ "limit": 29880
},
"reportUnnecessaryCast": {
"limit": 111
diff --git a/litellm/integrations/SlackAlerting/slack_alerting.py b/litellm/integrations/SlackAlerting/slack_alerting.py
index 748ef938cea..dc41c7dadc8 100644
--- a/litellm/integrations/SlackAlerting/slack_alerting.py
+++ b/litellm/integrations/SlackAlerting/slack_alerting.py
@@ -1955,11 +1955,10 @@ Model Info:
if not thresholds_enabled and not anomalies_enabled:
return
- if prisma_client is None:
- from litellm.proxy.proxy_server import prisma_client as global_prisma_client
+ from litellm.proxy.proxy_server import prisma_client as global_prisma_client
- prisma_client = global_prisma_client # rebind-ok: fall back to the proxy's global client
- if prisma_client is None:
+ client: Final = prisma_client if prisma_client is not None else global_prisma_client
+ if client is None:
return
from litellm.integrations.SlackAlerting.user_spend_alerts import (
@@ -1970,7 +1969,7 @@ Model Info:
try:
today: Final = datetime.datetime.now(datetime.timezone.utc).date()
rows: Final = await fetch_user_spend_rows(
- prisma_client=prisma_client,
+ prisma_client=client,
today=today,
baseline_days=self.alerting_args.spend_anomaly_baseline_days,
)
diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py
index dc61ee38a8c..2d737bc34e7 100644
--- a/litellm/integrations/websearch_interception/handler.py
+++ b/litellm/integrations/websearch_interception/handler.py
@@ -419,7 +419,6 @@ class WebSearchInterceptionLogger(CustomLogger):
if call_type in (CallTypes.responses, CallTypes.aresponses):
return self._convert_responses_tools(kwargs=kwargs, tools=tools)
- # Check if any tool is a web search tool (native or already LiteLLM standard)
has_websearch: Final = any(is_web_search_tool(t) for t in tools)
if not has_websearch:
diff --git a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
index d1ef73a15cd..90474bfc5e6 100644
--- a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
+++ b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py
@@ -92,6 +92,9 @@ def _connection_error_message(exc: BaseException) -> str:
if MCP_AVAILABLE:
+ from mcp.types import Tool as MCPTool
+
+ from litellm.experimental_mcp_client.client import MCPClient
from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
_UPSTREAM_OAUTH_DISCOVERY_AUTH_TYPES,
global_mcp_server_manager,
@@ -876,7 +879,6 @@ if MCP_AVAILABLE:
return (), classify_list_exception(e)
return tools_result, ServerListOk(tool_count=len(tools_result))
- # Query all servers the user has access to
queried_servers: Final = tuple(
server
for server in map(global_mcp_server_manager.get_mcp_server_by_id, allowed_server_ids)
@@ -1141,6 +1143,11 @@ if MCP_AVAILABLE:
scopes: Final[list[str] | None] = scopes_raw if isinstance(scopes_raw, list) else None
return client_id, client_secret, scopes
+ async def _list_tools_within(client: MCPClient, deadline: float) -> list[MCPTool] | None:
+ with anyio.move_on_after(deadline):
+ return await client.list_tools(raise_on_error=True)
+ return None
+
async def _execute_with_mcp_client(
request: NewMCPServerRequest,
operation: Callable[..., Awaitable[Mapping[str, object]]],
@@ -1422,9 +1429,7 @@ if MCP_AVAILABLE:
getattr(client, "timeout", MCP_CLIENT_TIMEOUT) or MCP_CLIENT_TIMEOUT,
MCP_TOOL_LISTING_TIMEOUT,
)
- list_tools_result = None # rebind-ok: set inside the timeout scope below
- with anyio.move_on_after(listing_deadline):
- list_tools_result = await client.list_tools(raise_on_error=True) # rebind-ok: fills the init above
+ list_tools_result: Final = await _list_tools_within(client, listing_deadline)
if list_tools_result is None:
verbose_logger.warning(
"MCP tools/list preview timed out after %s seconds while paginating upstream tools",
diff --git a/litellm/proxy/guardrails/guardrail_hooks/alice/alice.py b/litellm/proxy/guardrails/guardrail_hooks/alice/alice.py
index 27018769909..9cabac2d0fa 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/alice/alice.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/alice/alice.py
@@ -8,6 +8,7 @@
import json
import os
from collections.abc import Mapping
+from itertools import islice
from typing import (
TYPE_CHECKING,
Any, # noqa: TID251 # **kwargs forwards verbatim to CustomGuardrail.__init__; see ruff-strict.toml
@@ -341,19 +342,18 @@ def _json_safe(
if depth >= _MAX_DEPTH or id(value) in seen:
return None
- nested: Final = seen | {id(value)} # mutable-ok: one-shot set literal, unioned into a frozenset immediately
+ nested: Final = seen | frozenset((id(value),))
if isinstance(value, dict):
- out: dict[str, object] = {} # mutable-ok: bounded accumulator local to this call, never escapes as-is
- for key, item in list(value.items())[:_MAX_ITEMS]: # mutable-ok: list() only to slice an unordered view
- if isinstance(key, str) and key not in strip_keys:
- out[key] = _json_safe(item, depth + 1, nested, strip_keys)
- return out
+ return {
+ key: _json_safe(item, depth + 1, nested, strip_keys)
+ for key, item in islice(value.items(), _MAX_ITEMS)
+ if isinstance(key, str) and key not in strip_keys
+ }
if isinstance(value, (list, tuple, set, frozenset)):
return [ # mutable-ok: return value is a one-shot list, discarded by the caller after use
- _json_safe(item, depth + 1, nested, strip_keys)
- for item in list(value)[:_MAX_ITEMS] # mutable-ok: list() only to slice an unordered view
+ _json_safe(item, depth + 1, nested, strip_keys) for item in islice(value, _MAX_ITEMS)
]
dump: Final = getattr(value, "model_dump", None)
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index fbf998533f8..0f39b32670a 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -6,7 +6,7 @@
"limit": 26777
},
"LIT003": {
- "limit": 266
+ "limit": 265
},
"LIT004": {
"limit": 40
@@ -27,10 +27,10 @@
"limit": 0
},
"LIT010": {
- "limit": 16504
+ "limit": 16502
},
"LIT011": {
- "limit": 5531
+ "limit": 5529
},
"LIT012": {
"limit": 4495