mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix: only show semantic tool filter warning when feature is configured (#20651)
The warning 'Semantic tool filter hook not initialized' was appearing on every startup, even when the mcp_semantic_tool_filter feature was not configured. This was confusing for users. Now the function checks if the feature is actually configured and enabled before proceeding with initialization. The warning will only appear if the feature was explicitly enabled but failed to initialize. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
parent
f2ba3cc6e1
commit
d26878af70
1 changed files with 13 additions and 8 deletions
|
|
@ -4942,13 +4942,17 @@ class ProxyStartupEvent:
|
|||
"""Initialize MCP semantic tool filter if configured"""
|
||||
from litellm.proxy.hooks.mcp_semantic_filter import SemanticToolFilterHook
|
||||
|
||||
verbose_proxy_logger.info(
|
||||
f"Initializing semantic tool filter: llm_router={llm_router is not None}, "
|
||||
f"litellm_settings keys={list(litellm_settings.keys())}"
|
||||
)
|
||||
|
||||
mcp_semantic_filter_config = litellm_settings.get("mcp_semantic_tool_filter", None)
|
||||
verbose_proxy_logger.debug(f"Semantic filter config: {mcp_semantic_filter_config}")
|
||||
|
||||
# Only proceed if the feature is configured and enabled
|
||||
if not mcp_semantic_filter_config or not mcp_semantic_filter_config.get("enabled", False):
|
||||
verbose_proxy_logger.debug("Semantic tool filter not configured or not enabled, skipping initialization")
|
||||
return
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
f"Initializing semantic tool filter: llm_router={llm_router is not None}, "
|
||||
f"config={mcp_semantic_filter_config}"
|
||||
)
|
||||
|
||||
hook = await SemanticToolFilterHook.initialize_from_config(
|
||||
config=mcp_semantic_filter_config,
|
||||
|
|
@ -4956,10 +4960,11 @@ class ProxyStartupEvent:
|
|||
)
|
||||
|
||||
if hook:
|
||||
verbose_proxy_logger.debug("✅ Semantic tool filter hook registered")
|
||||
verbose_proxy_logger.debug("Semantic tool filter hook registered")
|
||||
litellm.logging_callback_manager.add_litellm_callback(hook)
|
||||
else:
|
||||
verbose_proxy_logger.warning("❌ Semantic tool filter hook not initialized")
|
||||
# Only warn if the feature was configured but failed to initialize
|
||||
verbose_proxy_logger.warning("Semantic tool filter hook was configured but failed to initialize")
|
||||
|
||||
@classmethod
|
||||
def _initialize_jwt_auth(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue