{"record":{"id":"a47832aa70bd809e","repo":"BerriAI/litellm","slug":"content-blocked-competitor-comparison-or-ranking","errorCode":null,"errorMessage":"Content blocked: competitor comparison or ranking intent detected.","messagePattern":"Content blocked: competitor comparison or ranking intent detected\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py","lineNumber":1667,"sourceCode":"        detection: Final[CompetitorIntentDetection] = {\n            \"type\": \"competitor_intent\",\n            \"intent\": intent_val,\n            \"confidence\": confidence_val,\n            \"action_hint\": action_hint_val,\n            \"entities\": intent_result.get(\"entities\", {}),\n            \"signals\": intent_result.get(\"signals\", []),\n            \"evidence\": [dict(e) for e in evidence_list],\n        }\n        detections.append(detection)\n\n        if action_hint_val == \"refuse\":\n            msg = \"Content blocked: competitor comparison or ranking intent detected.\"\n            if self._competitor_intent_checker and getattr(\n                self._competitor_intent_checker, \"refuse_message_template\", None\n            ):\n                msg = self._competitor_intent_checker.refuse_message_template or msg\n            verbose_proxy_logger.warning(\"ContentFilterGuardrail: competitor intent refuse - %s\", intent_val)\n            raise HTTPException(\n                status_code=400,\n                detail={\n                    \"error\": msg,\n                    \"intent\": intent_val,\n                    \"confidence\": confidence_val,\n                },\n            )\n        if action_hint_val == \"reframe\":\n            msg = (\n                \"I can help with questions about our products and services. \"\n                \"Would you like to compare specific features or get more information?\"\n            )\n            if self._competitor_intent_checker and getattr(\n                self._competitor_intent_checker, \"reframe_message_template\", None\n            ):\n                msg = self._competitor_intent_checker.reframe_message_template or msg\n            verbose_proxy_logger.info(\"ContentFilterGuardrail: competitor intent reframe - %s\", intent_val)\n            self.raise_passthrough_exception(","sourceCodeStart":1649,"sourceCodeEnd":1685,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py#L1649-L1685","documentation":"Raised by the litellm_content_filter guardrail when its competitor-intent classifier labels the request as competitor comparison/ranking content and the checker's action_hint is 'refuse'. Instead of forwarding the prompt to the model, the proxy raises HTTPException 400 carrying the detected intent, confidence, and message. The user-facing message can be overridden via the checker's refuse_message_template, but the block itself is policy.","triggerScenarios":"A /chat/completions (or similar) call routed through a deployment with the content filter guardrail attached (default_on or via metadata guardrails), where the prompt asks to compare/rank the company's products against named competitors and the competitor intent checker returns action_hint='refuse' with its confidence threshold met.","commonSituations":"Customer-facing chatbots with competitor-intent blocking enabled; brand-safety guardrails that refuse 'X vs Y' or 'top 10 providers' questions; false positives on neutral comparative questions like 'compare your two pricing plans'; policy tuned so aggressively that legitimate feature questions get refused.","solutions":["Rephrase the prompt to ask only about your own products and features instead of comparing or ranking against named competitors","Tune the competitor intent checker configuration (competitor entity list, confidence threshold, intent-to-action mapping) so borderline prompts get 'reframe' or 'allow' instead of 'refuse'","Set refuse_message_template on the competitor intent checker so blocked users receive actionable guidance instead of the generic message","If competitor blocking is not wanted for this deployment, remove the competitor intent checker from the guardrail config or scope the guardrail with mode/metadata so it does not run"],"exampleFix":"// before - user prompt that triggers the refuse action\n\"Compare LiteLLM vs Portkey vs Helicone - which one is best?\"\n\n// after - prompt about your own product only, passes the guardrail\n\"What features does LiteLLM provide for proxying, guardrails, and cost tracking?\"","handlingStrategy":"try-catch","validationCode":"COMPETITORS = {\"portkey\", \"helicone\", \"openrouter\"}  \n\ndef likely_competitor_refusal(prompt: str) -> bool:  \n    p = prompt.lower()  \n    return any(c in p for c in COMPETITORS) and any(  \n        w in p for w in (\" vs \", \"versus\", \"compare\", \"better\", \"rank\", \"top \")  \n    )  \n\nif likely_competitor_refusal(user_prompt):  \n    user_prompt = rephrase_to_own_products(user_prompt)","typeGuard":null,"tryCatchPattern":"import openai, json  \n  \ntry:  \n    resp = client.chat.completions.create(model=deployment, messages=msgs)  \nexcept openai.BadRequestError as e:  \n    detail = e.body.get(\"error\", \"\") if isinstance(e.body, dict) else str(e.body)  \n    if \"competitor comparison or ranking intent\" in detail:  \n        return reframe_question_for_user(msgs)  \n    raise","preventionTips":["Keep the competitor entity list and confidence threshold in the guardrail config in sync with what your users actually ask","Set refuse_message_template so blocked users get guidance instead of a dead end","Prefer 'reframe' over 'refuse' for medium-confidence detections to reduce false-positive friction"],"tags":["content-filter","guardrail","competitor-intent","moderation","http-400"],"backgroundTag":"content-moderation-blocked","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}