From 3381d6217f00489cf8f89b12c1c2a5c48d70d858 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Thu, 19 Feb 2026 23:35:35 -0300 Subject: [PATCH] fix(policy): use litellm.acompletion directly in AiPolicySuggester The suggest() method was calling llm_router.acompletion(), which requires the proxy router to be initialised. This caused: ValueError: LLM router not initialized in every test (and in any deployment without a configured router). AiPolicySuggester is a self-contained feature that calls an LLM directly; it has no need for proxy routing. Switch to litellm.acompletion, which is always available and is what the tests already mock. Co-Authored-By: Claude Sonnet 4.6 --- .../policy_endpoints/ai_policy_suggester.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/litellm/proxy/management_endpoints/policy_endpoints/ai_policy_suggester.py b/litellm/proxy/management_endpoints/policy_endpoints/ai_policy_suggester.py index ae0dc5c20eb..040acd9222c 100644 --- a/litellm/proxy/management_endpoints/policy_endpoints/ai_policy_suggester.py +++ b/litellm/proxy/management_endpoints/policy_endpoints/ai_policy_suggester.py @@ -6,6 +6,7 @@ based on user-provided attack examples and descriptions. import json from typing import List, Optional +import litellm from litellm._logging import verbose_proxy_logger from litellm.constants import DEFAULT_COMPETITOR_DISCOVERY_MODEL @@ -56,17 +57,12 @@ class AiPolicySuggester: description: str, model: Optional[str] = None, ) -> dict: - from litellm.proxy.proxy_server import llm_router - - if llm_router is None: - raise ValueError("LLM router not initialized") - system_prompt = self._build_system_prompt(templates) user_prompt = self._build_user_prompt(attack_examples, description) model = model or DEFAULT_COMPETITOR_DISCOVERY_MODEL try: - response = await llm_router.acompletion( + response = await litellm.acompletion( model=model, messages=[ {"role": "system", "content": system_prompt},