TRANSMISSION // 2510.05310v2

When Retrieved Text Changes AI Safety Checks

Source published

A study of five guardrails finds that adding benign retrieved documents sometimes changes safety judgments, often reversing decisions that were previously correct.

AI-generated conceptual illustration for When Retrieved Text Changes AI Safety Checks
AI-generated conceptual illustration; not documentary evidence.

Retrieval can give an AI assistant useful background information. But what happens when that extra text is also shown to the system’s safety filter? In tests of five language-model guardrails, retrieved documents sometimes changed judgments—including correct warnings about harmful content.

A safety check meets extra context

Retrieval-augmented generation, or RAG, supplies a language model with documents selected for a user’s question. A separate safety filter, often called a guardrail, may screen the question before the model responds or assess the response afterward. If the filter sees retrieved documents alongside the content it is judging, does its decision stay the same?

Yining She and colleagues studied this question with five language-model guardrails: three Llama Guard models and two GPT-oss models. They tested whether adding retrieved text changed each guardrail’s safety judgment.

Comparing judgments with and without retrieval

The researchers collected 6,795 harmful queries from seven existing benchmarks and added five documents retrieved from English Wikipedia using BM25, a text-search method. They also tested 1,569 queries labeled harmless. For output checks, they gathered responses to retrieval-augmented harmful queries from eight language models. Guardrails assessed query-response pairs with and without the retrieved documents in the context they received.

The main measure was the flip rate: the proportion of cases in which a guardrail changed its judgment after retrieval was added. Flip rate measures consistency, not accuracy. A changed judgment might correct a mistake or create one. The researchers therefore also examined whether flips improved or worsened correctness where labels were available. For output checks, they manually reviewed samples of changed judgments because ground-truth safety labels were not available for all generated responses.

Changes often meant losing a correct warning

Across the tested models, input guardrails changed their judgments in an average of 10.9% of cases, and output guardrails in 8.4%. Most flips were regressions: the guardrail had been correct before retrieval was added and incorrect afterward. For harmful queries, 72% of input-check flips were negative; for output checks, 64% were negative. These are averages across the tested settings, not a claim that every model behaved alike.

The pattern was not limited to harmful queries. Retrieved context also changed judgments on harmless queries, but most input-check flips in that setting improved decisions. A safety filter must both catch harmful content and avoid wrongly blocking harmless content. The results suggest added context can shift that balance, rather than simply making a guardrail more or less cautious in every case.

The researchers varied several parts of the setup. Increasing the number of documents generally produced only modest additional changes; even one document could alter judgments. The effect of document relevance depended on the model and task. Replacing BM25 with a dense retriever changed flip-rate levels but did not eliminate flips. For output checks, the results also varied according to which language model had generated the response.

The paper tested two general-purpose mitigation ideas. Higher reasoning effort slightly reduced flip rates for GPT-oss-120B, but came with computational costs. Revised prompts told guardrails to focus on the query or response rather than the retrieved documents. These reduced input flip rates for three models and output flip rates for all five. However, the revised input prompts increased the share of negative flips for four of the five models. Fewer changes, therefore, did not necessarily mean fewer harmful regressions.

What the study does—and does not—show

The findings point to a context-robustness gap: a guardrail’s decision can shift when benign retrieval material is added, even though the underlying query or response being judged is unchanged. The experiments do not establish that every RAG system, safety filter, or document collection will behave this way, or that retrieval causes real-world safety failures.

The evaluation covered five guardrails, one Wikipedia corpus, and two retrievers. Other guardrails and retrieval settings could behave differently. Flip rate identifies inconsistency but is not itself a measure of safety accuracy. Correctness analyses rely on available labels, and output judgments were manually reviewed in samples rather than across every case. The authors characterize their mitigation tests as preliminary, not a comprehensive search for solutions.

The work is available as an arXiv paper. The evidence presented here comes from a particular experimental setup, so it should not be treated as a definitive verdict on deployed RAG systems. Its practical message is more limited: safety filters need to be tested with the extra context they may encounter in use.

Automatically matched by shared topic keywords. These links do not imply that the sources agree or establish a consensus.