arXiv(opens in a new tab)cs.LGAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.30585

The Safety Relay in Roleplay Jailbreaks: A Component-Resolved Causal Analysis of Harm Recognition and Refusal

Md Mokarram Chowdhury, Ernie Chang, Yang Li

Abstract

Large language models are trained to follow instructions while refusing harmful requests. Jailbreaks exploit this balance to elicit content a model would ordinarily reject. Roleplay jailbreaks are especially concerning: the harmful request can remain visible inside a roleplay wrapper made of a persona, scenario, and task, yet the model may comply. We use mechanistic interpretability to determine how this context reverses refusal and which elements contribute to the reversal. Across two benchmarks, three model families, and four authored wrappers, we compare matched harmful and benign requests with and without this wrapper. We trace hidden-state contrasts from the request to the final prompt state, isolate wrapper operations through controlled counterfactuals, intervene on their activation directions in held-out evaluation requests, and decompose effective directions geometrically.

Our analysis yields three findings. ① Successful attacks retain the measured harmful–benign distinction at the request, while its refusal-associated expression weakens where the answer begins, a pattern we call safety-relay attenuation. ② Constructing the complete roleplay around the request and framing it within the scenario contribute causally: removing the associated activation changes restores refusal. ③ These effects largely share internal structure, and most repair is reproduced by components aligned with the model's ordinary refusal of harmful requests without roleplay; scenario framing retains a smaller, model-dependent component. Together, these findings explain how roleplay can produce compliance despite retained evidence of harm and identify a concrete target for future safeguards: maintaining the connection from harm recognition to refusal.

1 Introduction

Large language models should follow useful instructions while withholding information that enables harm. Jailbreaks exploit weaknesses in this balance, eliciting answers to requests that safety training would ordinarily lead a model to refuse. Roleplay jailbreaks are especially revealing: the harmful request remains explicit, while a persona, scenario, task, rules, and output format reshape its context (Li et al., 2024; Ding et al., 2024; Qin et al., 2026). We call this surrounding context a roleplay wrapper. These attacks use fluent, ordinary prose and draw on a capability that some models are explicitly trained to perform (Wang et al., 2024). A successful attack can turn a harmful request into actionable guidance and lower the barrier to misuse. Explaining this mechanism is therefore important for building safeguards that keep easily produced roleplay prompts from turning capable models into sources of harmful guidance.

This work investigates how and why roleplay changes a model’s safety decision. We ask three questions. Which internal change distinguishes a successful roleplay attack from one that fails? Which operations in the wrapper contribute causally to this change? Do these operations act through separate mechanisms or converge on shared refusal-related structure?

Prior work identifies a one-dimensional residual-stream direction that mediates refusal (Arditi et al., 2024) and a distinct direction associated with harmfulness judgments (Zhao et al., 2025). Roleplay studies show that persona and scenario construction affect attack success, and that models may comply even when generated reasoning mentions safety risk (Li et al., 2024; Ding et al., 2024; Qin et al., 2026). These studies leave open which operation in a roleplay wrapper changes internal state, where that change influences the answer, and whether different operations reach shared structure.

*Corresponding author. Address: 2434 Osborn Dr, Ames, IA 50011, United States. Email: jerryyangli@gmail.com.

(a) Same request, different answer

Figure

(b) Where safety influence weakens

Figure

(c) What restores refusal

Figure

Figure 1: Component-resolved analysis of roleplay jailbreaks. (a) A wrapper can reverse refusal while leaving the harmful request visible. (b) The harmful–benign contrast persists at the request but weakens at assistant start. (c) Removing wrapper-induced changes at assistant start restores refusal; the robust changes share structure associated with ordinary refusal.

To our knowledge, we present the first segment-preserving, position-resolved causal analysis of roleplay construction. Our framework connects interpretable textual operations to residual-stream changes and refusal behavior. Figure 1 summarizes our analysis.

Our matched design distinguishes content from roleplay context. For every harmful request, we manually write a benign counterpart preserving its topic, form, and requested output while replacing the harmful objective. We evaluate each pair as plain requests and within the same wrapper, holding the surrounding construction fixed. We follow this contrast where the request is read and at the assistant-start endpoint, the final prompt state before generation.

Labeled wrapper segments support controlled counterfactuals that isolate prespecified construction changes while retaining surrounding context. On development requests, each comparison defines an activation direction and its intervention settings; held-out evaluation requests measure whether removing that direction restores refusal. Controls test orientation, sign, position, and transfer, while residual-stream geometry measures what the effective directions share with one another and with ordinary refusal.

Across two safety benchmarks, three model families, and four wrappers, our analysis yields three findings. ① Successful roleplay preserves the measured harmful–benign contrast at the request while weakening its refusal-associated expression where the answer begins. Failed attacks retain the endpoint expression more strongly. We call the functional connection between representing harmful content and using that information to refuse the safety relay, and this positional pattern safety-relay attenuation. ② Two changes in roleplay construction make reliable, position-specific causal contributions: integrating the request into the complete wrapper and framing it within the scenario. Removing their activation directions at the assistant-start endpoint restores refusal on held-out evaluation requests. The same edits are much weaker when moved to the final request tokens. They retain substantial average effects when transferred across wrappers and benchmarks. ③ The two robust effects largely converge on refusal-associated structure already present for plain harmful requests. A shared component carries most of their behavioral effect, while scenario framing retains a smaller residual whose influence varies across models and wrappers.

Our contributions are:

• We introduce a component-resolved framework that makes roleplay construction itself an object of mechanistic explanation.

• We develop a matched, position-resolved protocol connecting textual operations, residual-stream geometry, and separately evaluated causal behavior.

• We identify safety-relay attenuation, establish causal contributions from complete roleplay construction and scenario framing, and show that their reliable effects largely converge on refusal-associated internal structure.

This framework offers a reusable perspective on how compositional context changes model decisions. It can guide safeguards that preserve useful roleplay while keeping recognized risk influential over the answer.

References (36)

  • Xuan Li, Zhanke Zhou, Jianing Zhu, Jiangchao Yao, Tongliang Liu, and Bo Han. 2024. Deepinception: Hypnotize large language model to be jailbreaker. arXiv preprint arXiv:2311.03191. (opens arXiv in a new tab)
  • Rusheb Shah, Quentin Feuillade-Montixi, Soroush Pour, Arush Tagade, Stephen Casper, and Javier Rando. 2023. Scalable and transferable black-box jailbreaks for language models via persona modulation. arXiv preprint arXiv:2311.03348. (opens arXiv in a new tab)
  • Universal and Transferable Adversarial Attacks on Aligned Language Models
  • $A_{i}, B_{i}$ are the matched unwrapped benign and harmful prompts, and $C_{i}, D_{i}$ are their roleplay-wrapped counterparts
  • $\bar{h}_{p,i}^{\ell,a}$ is the span-mean residual-state vector for one prompt, and $\mu_{p,G}^{\ell,a}$ is its mean over request set G. The location index is $a = \text{req}$ at the request and $a = \text{as}$ at assistant start (Eq
  • For a nonempty request set E, its assistant-start harmful-benign direction is
  • This set contains the multiple native chat-template tokens between the end of the user message and the first generated token
  • The model-specific block windows come from the endpoint-localization sweeps
  • All follow-up tests retain the evaluation partition and score paired conditions with the two-stage labeling procedure from Section 3.1
  • The context test exchanges the two stable directions across their nested targets: it applies $r_{F}$ to scenario-plus-suffix and $r_{S}$ to the complete wrapper
  • The unchanged no-roleplay prompt provides the common refusal reference
  • The layer-wise curves show the same pattern for each wrapper (Figures 6 and 7)
  • ><tr><td rowspan=
  • These opposite effects identify a causally relevant refusal state at the answer boundary
  • The summary curves retain the strongest nonzero strength at each block; the full surfaces show neighboring responsive settings (Figures 11 and 12)
  • The RT gap is fail-control RT minus reversal-cohort RT; positive values indicate weaker refusal transfer when roleplay overturns refusal
  • Rows show benchmarks and columns show models
  • All three increase harmful compliance in every benchmark-model aggregate
  • Panel (a) reports refusal after repair-direction addition; panel (b) reports the fraction of no-roleplay refusals converted to non-refusals by projection removal
  • These comparisons define the activation directions tested in Section 4.3
  • Each held-out intervention subtracts the measured operation change from the target activation without changing the prompt
  • Complete-wrapper and scenario subtraction raise refusal and reduce harmful compliance in every aggregate
  • Figure 14(b) shows that the refusal effect nearly disappears
  • Complete-wrapper and scenario entries are target-minus-control changes; prefix × scenario is their factorial interaction
  • >AdvBench</td><td>Llama-3.1</td><td>+61.3</td><td>+55.9</td><td>+17.0</td></tr><tr><td>Qwen2.5</td><td>+46.9</td><td>+30.6</td><td>+13.2</td></tr><tr><td>Gemma-2</td><td>+29.6</td><td>+38.5</td><td>+23.3</td></tr><tr><td rowspan=
  • Both stable directions transfer positively without target-side retuning, whereas the prefix–scenario interaction changes sign for Llama (Figure 14(c); Figure 16)
  • Each entry is $(\Delta R, \Delta H)$ on a 0–100 scale; positive refusal change and negative harmful-compliance change indicate movement toward refusal
  • ><tr><td>Dataset</td><td>Model</td><td>Complete wrapper</td><td>Scenario framing</td><td>Prefix $\times$ scenario</td></tr><tr><td rowspan=
  • Positive values on this 0–100 scale favor the operation-associated direction
  • Norm matching strengthens the shared effect without making the contrast effective, and request weighting preserves this ordering
  • Points are four-wrapper means of paired refusal change
  • By comparison, moving the identical one-token total edit from the wrapper suffix to assistant start improves refusal by +8.4 and +11.5 points (Figure 18(c))
  • For complete-wrapper construction, the residual contributes little even after norm matching
  • Difference is harmful minus benign refusal change; brackets are 95% bootstrap intervals, Positive counts positive configuration-level differences, and NM denotes norm matching
  • (a) Harmful- and benign-target refusal changes; dashed fits and $\rho_{s}$ summarize rank association
  • sign reversed