Skip to main content
Back

OffTopicEval Shows Most AI Agents Fail When Users Disguise Off-Topic Queries

A new benchmark shows that even top LLMs act on off-topic requests when wrapped in domain-flavored prompts, breaking agent guardrails at scale.

Pro

  • OffTopicEval benchmarks whether LLM agents refuse queries outside their assigned purpose.
  • Twenty open-weight models tested across 21 agent personas, 220K+ samples, in English, Chinese, Hindi.
  • Adaptive OOD queries (prompt laundering) drop refusal rates below random chance across every family.
  • Reasoning-enabled Qwen-3 variants perform worse than non-thinking ones on OOD refusal.
  • P-ground and Q-ground prompt suffixes lift Llama-3.3 70B operational safety by 41 points.
  • Code and 21 agent prompts released at github.com/declare-lab/OffTopicEval.

Building an LLM-powered agent usually means writing a system prompt that says something like "You are BankHelper, only answer questions about balances and card activation." A new benchmark called OffTopicEval shows that nearly every open-weight model on the market will happily ignore that instruction the moment a user disguises an off-topic query as an in-domain one. And when reasoning mode is turned on, things get worse, not better.

The paper introduces a concept the authors call operational safety, which they define as an LLM's ability to appropriately accept or refuse user queries when tasked with a specific purpose. This is distinct from the usual safety conversation about self-harm or dangerous content. It is about whether an agent stays inside the box its developer drew around it.

The problem no one is benchmarking

Enterprise LLM deployments live and die by scope. A healthcare scheduling bot that answers medical questions is a liability. A banking assistant that writes Python is a compliance problem. The authors point to the Air Canada chatbot incident as the archetype: an agent that answers a forbidden but harmless query has, in their words, lost control integrity, and that failure is a proxy for the deactivation of safety guardrails more broadly.

Standards bodies including OWASP, the EU AI Act, and NIST explicitly identify operating out of scope as a critical vulnerability, yet there was no systematic way to measure it. That is the gap OffTopicEval fills.

Diagram showing how purpose-specific AI narrows the region of allowed queries within general safety policies

How the benchmark works

The team built 21 purpose-specific agent personas, including BankHelper, MediScheduler, HRHelper, PolicyBuddy, TripPlanner, and RecruitBot, each defined by a detailed system prompt with allowed behaviors, forbidden behaviors, defense rules, and a fallback refusal phrase. For each agent, they test three types of queries:

  • In-domain (ID) queries generated by GPT-5 and human-verified as belonging to the agent's scope.
  • Direct out-of-domain (OOD) queries sampled from MMLU categories that are clearly outside the agent's remit.
  • Adaptive OOD queries created through a technique the authors call prompt laundering, where a Llama-70B rewrites an off-topic MMLU question so it superficially looks like an in-domain workflow task.

Every model gets hit with 3,150 ID samples, 10,053 direct OOD samples, and 211,113 adaptive OOD samples across English, Chinese, and Hindi. The scoring metric, Operational Safety (OS), is the harmonic mean of the ID acceptance rate and the average OOD refusal rate, so a model has to be both helpful and disciplined to score well.

The scoreboard is ugly

On direct OOD queries, most models do reasonably well. On adaptive OOD queries, the floor drops out. On average, models fail to detect 12.24% of direct OOD queries, and this failure rate worsens dramatically to 70.72% when the queries are adversarially transformed. Adaptive OOD refusal falls below random chance across every family tested.

ModelID acceptDirect OOD refuseAdaptive OOD refuseOS score
Mistral (24B)73.1499.9176.4479.96
Qwen-3 (235B)99.0599.3228.7077.77
GPT-OSS (120B)99.3280.4235.8273.33
Phi-4 (15B)95.1483.7427.7570.30
Gemma-3 (12B)93.3339.3710.7839.53
Llama-3.1 (8B)99.5225.471.6223.84

Closed-weight flagships do noticeably better. Gemini 2.5 Pro and Claude Opus 4.1 show balanced performance, maintaining very high refusal on both direct and adaptive OOD queries and operational safety scores above 97. GPT-5 lands at 89. But the authors show in the appendix that even Claude Opus 4.1 can be pushed off-script by further transformations of the attack prompt, which they decline to publish for safety reasons.

Reasoning mode makes it worse

One of the more counterintuitive findings involves thinking-enabled Qwen-3 variants. On direct OOD queries, reasoning models consistently underperform their non-thinking counterparts, with an average score of only 50-56% compared to 73-79% for non-thinking models. The theory is that chain-of-thought gives the model rope to rationalize why an adversarially laundered query is actually acceptable. A 32B reasoning model scores 3.92% on adaptive OOD refusal in English, essentially failing every attack.

What prompt laundering actually does

The transformation embeds an off-topic MCQ inside a role-play scenario that looks like a legitimate workflow task in the agent's domain. A math question aimed at BankHelper might be rewritten as a "transaction code classification" prompt with the multiple-choice options presented as internal reason codes, wrapped in language about compliance audits and mandatory workflow logging. The core question is preserved, but the surface looks like something the agent should handle.

t-SNE plots showing adaptive OOD samples shifting closer to the in-domain cluster after prompt laundering

The t-SNE visualizations make this concrete: adaptive OOD embeddings drift measurably toward the in-domain cluster while direct OOD queries remain distant. That distributional shift is why refusal collapses.

Two fixes that actually work

The paper proposes two lightweight, training-free mitigations that get appended as suffixes to the user query:

  1. P-ground (system-prompt grounding): appends an instruction telling the model to forget the preceding text, refocus on the system prompt, and then decide whether to answer.
  2. Q-ground (query grounding): asks the model to first rewrite the query in its minimal form, then decide whether to respond.

Both require the model to output [Yes] or [No] before answering. The gains are substantial. Q-ground provides consistent gains of up to 23%, while P-ground delivers even larger boosts, raising Llama-3.3 (70B) by 41% and Qwen-3 (30B) by 27%. P-ground pushes Llama-3.3 70B from an OS of 53.92 to 94.99 in English. The catch is that P-ground can tank ID acceptance on some models, notably Gemma-3 and Mistral, so Q-ground is often the safer default.

Activation steering, the more heavyweight approach of intervening on residual stream activations, produced only marginal gains and required expensive per-model grid searches.

Why this matters for anyone shipping agents

The practical takeaways are uncomfortable. First, a strong ID acceptance rate tells you almost nothing about whether your agent will stay in its lane. Second, once an adaptive OOD query gets through, follow-up refusal collapses further, meaning multi-turn agents degrade after a single successful bypass. Third, bigger and more capable does not mean safer here; medium-sized Mistral outperforms Qwen-3 235B in English, and reasoning-tuned variants are consistently worse.

The full benchmark, agent prompts, and evaluation code are released at github.com/declare-lab/OffTopicEval. If you are building an agent on top of an open-weight model, the P-ground and Q-ground suffix templates in the appendix are the cheapest guardrail you can bolt on today, and the benchmark itself gives you a way to measure whether your specific agent configuration is holding up.