---
updatedAt: 2026-10-10T18:40:10.000Z
agentTools:
  projectIndex: https://docs.superwise.ai/llms.txt
---

# Jailbreak detection

How the jailbreak detection rule spots attempts to bypass the system prompt

Jailbreak detection checks each prompt sent to an agent and flags the ones written to talk the model out of its instructions, before the model acts on them. In SUPERWISE®, it is a guardrail rule on agent input. For each prompt it returns a verdict: `valid` is `true` when the prompt passes and `false` when the rule flags it as a jailbreak attempt.

A jailbreak is a prompt written to talk a model out of its instructions, for example by asking it to role-play, to ignore its system prompt, or to answer as an unrestricted assistant. Jailbreaks are one form of prompt injection; for the wider idea, see [What is prompt injection?](https://superwise.ai/learn/what-is-prompt-injection/?utm_source=docs\&utm_medium=referral\&utm_campaign=docs-jailbreak-detection) on superwise.ai.

The SUPERWISE jailbreak detection rule is based on the [jailbreak-classifier](https://huggingface.co/jackhhao/jailbreak-classifier) open source model. It allows users to apply a detection mechanism to prevent attempts to bypass the model’s built-in boundaries and system prompts to generate unwanted or unexpected interactions. Set the rule's **Threshold**, `threshold` in the SDK and API. The classifier scores each prompt from 0 to 1, and the rule flags a prompt when its jailbreak score is at or above the threshold. A lower threshold catches more prompts, with more false positives. A higher threshold flags fewer.

<Image alt="SUPERWISE guardrails: the Detect jailbreak rule form with a threshold slider set to 0.4" align="center" border={false} src="https://files.readme.io/81c5ee5e66b40be4254f47ade6fbb16ffca87863dd059448914ac26795b0b0b1-detect_jail.png" />

## Using the SDK

```python
from superwise_api.models.agent.agent import AgentDetectJailbreakGuard

jailbreak_guard = AgentDetectJailbreakGuard(
    name="Rule name",
    tags={"input"},
    threshold=0.7
)
```

The rule applies to input only, so `tags` takes `"input"`. `threshold` is a number from 0 to 1 and defaults to 0.7. A prompt is flagged when its jailbreak score is at or above it, so a lower value catches more.

## Reading the verdict

When you run guardrules from your own code with [Run guardrules](https://docs.superwise.ai/reference/guardrail_run), the response holds one result per rule. A prompt the jailbreak rule flags comes back with `valid` set to `false`:

```json
[
  {
    "name": "Rule name",
    "type": "detect_jailbreak",
    "valid": false,
    "message": "..."
  }
]
```

`message` explains the outcome. If any rule in a guardrail returns `valid: false`, the whole guardrail counts as violated. See [Configure a guardrail](https://docs.superwise.ai/docs/configuring-a-guardrail#test-the-guardrail).

## See also

* [Configure a guardrail](https://docs.superwise.ai/docs/configuring-a-guardrail): every rule type, and how to test a configuration.
* [Restricted topics](https://docs.superwise.ai/docs/restricted-topics) and [Allowed topics](https://docs.superwise.ai/docs/allowed-topics): limit what an agent discusses.
* [Toxicity detection](https://docs.superwise.ai/docs/toxicity-detection): flag toxic language in input and output.