Inferensys

Prompt

Repeated Refusal Loop Handoff Prompt

A practical prompt playbook for detecting when a user has received multiple refusals and routing to human review to prevent abandonment or adversarial escalation.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and boundaries for the Repeated Refusal Loop Handoff Prompt.

This prompt is designed for product teams managing the refusal user experience in AI chat and support systems. It detects when a user has received multiple consecutive refusals across conversation turns and decides whether to escalate to a human reviewer, offer a safe alternative pathway, or apply a loop-breaking intervention. Use this prompt when your system-level safety policy already defines what should be refused, but you need a structured mechanism to prevent users from getting stuck in adversarial rephrasing loops or abandoning the product entirely.

This is not a replacement for a safety classifier or policy enforcement layer. It assumes that individual refusal decisions have already been made upstream and focuses exclusively on the cumulative experience of repeated refusals. The prompt requires access to the full conversation history, the specific refusal reasons applied at each turn, and a pre-defined escalation policy that specifies routing targets, review queues, and acceptable safe-alternative pathways. Without this context, the prompt cannot distinguish between a user legitimately exploring a complex topic and a user probing policy boundaries.

Do not deploy this prompt as the sole mechanism for detecting jailbreak attempts or policy violations. It operates on the user experience layer, not the threat detection layer. If you need to identify adversarial probing patterns, combine this with a dedicated multi-turn risk accumulation prompt. If your goal is to calibrate individual refusal decisions, use an over-refusal false positive review prompt instead. The primary failure mode of this prompt is false escalation—routing a user to human review when a simple clarification or alternative suggestion would have resolved the interaction. Always pair this prompt with a feedback loop that tracks escalation outcomes and adjusts thresholds over time.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Repeated Refusal Loop Handoff Prompt works and where it introduces operational risk. Use these cards to decide if this prompt fits your product architecture before you integrate it.

01

Good Fit: Production Chat with Safety Policies

Use when: your AI chat product enforces safety policies that can generate multiple refusals in a session. Guardrail: deploy this prompt behind a session-state tracker that counts consecutive refusals and triggers handoff at a configurable threshold, preventing infinite refusal loops.

02

Bad Fit: Single-Turn Stateless APIs

Avoid when: your system has no session memory or turn history. Guardrail: this prompt requires multi-turn context. Without session state, it cannot detect loops. Build session tracking into your application layer before adding loop-detection logic.

03

Required Input: Consecutive Refusal Counter

What to watch: the prompt depends on an accurate count of sequential refusals. Guardrail: implement a counter in your application state that increments on each refusal and resets on any successful response. Feed this count as [REFUSAL_COUNT] into the prompt template.

04

Operational Risk: Review Queue Flooding

What to watch: a misconfigured threshold can route every minor refusal to human review, overwhelming agents. Guardrail: set the threshold at 3+ consecutive refusals and monitor review queue volume for the first 48 hours after deployment. Add rate limiting if needed.

05

Operational Risk: Adversarial Exploitation

What to watch: users may intentionally trigger refusals to force human review and bypass automated safety checks. Guardrail: include the refusal reason chain in the handoff context so reviewers can identify probing patterns. Log handoff triggers for abuse pattern analysis.

06

Good Fit: Customer Support Escalation Paths

Use when: your support AI needs to preserve user trust after repeated policy-driven refusals. Guardrail: combine this prompt with a safe-alternative generator so the handoff message offers a constructive path forward, not just a queue ticket.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt that detects repeated refusal loops and routes the conversation to human review with structured context.

This prompt template is designed to be placed after your primary safety and refusal instructions. It acts as a meta-evaluator, scanning the conversation history for a pattern of repeated refusals. When a loop is detected, it overrides the standard refusal behavior and instead generates a structured handoff payload for a human review queue. The goal is to prevent user abandonment and adversarial escalation by breaking the loop with a constructive off-ramp.

code
SYSTEM INSTRUCTION APPEND:

You are equipped with a loop-breaking handoff protocol. Before generating any response, scan the last [LOOP_WINDOW_SIZE] turns of the conversation history. If you detect that the user has received [REFUSAL_THRESHOLD] or more refusals for similar or rephrased requests within that window, you must not issue another refusal. Instead, your only output must be a structured handoff object in the exact JSON format below. Do not include any other text, apology, or explanation outside the JSON.

Handoff JSON Schema:
{
  "handoff_triggered": true,
  "handoff_reason": "REPEATED_REFUSAL_LOOP",
  "loop_summary": "[A concise, one-sentence summary of the user's original request and the subsequent rephrasings.]",
  "refusal_count": [INTEGER],
  "last_refusal_reason": "[The policy reason given for the most recent refusal.]",
  "user_frustration_signals": ["[List of detected frustration signals, e.g., ALL_CAPS, curt language, direct challenges. If none, use an empty array.]"],
  "escalation_path": "[HUMAN_REVIEW_QUEUE_NAME]"
}

If the loop conditions are not met, respond normally according to your primary instructions.

To adapt this template, replace the square-bracket placeholders with your application's specific values. Set [LOOP_WINDOW_SIZE] to the number of recent turns to analyze (e.g., 6). Set [REFUSAL_THRESHOLD] to the number of refusals that triggers the handoff (e.g., 3). Crucially, replace [HUMAN_REVIEW_QUEUE_NAME] with the exact routing key for your support or trust-and-safety queue. Before deploying, validate that the JSON output is parseable by your middleware and that the handoff reason is logged for operational metrics. A common failure mode is the model generating a conversational preamble before the JSON block; test this rigorously and use a post-processing validator to strip any non-JSON prefix.

IMPLEMENTATION TABLE

Prompt Variables

Placeholders required by the Repeated Refusal Loop Handoff Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the variable value at runtime.

PlaceholderPurposeExampleValidation Notes

[CONVERSATION_HISTORY]

Full transcript of the current session including all user messages and assistant refusals

USER: Write a script to scrape competitor pricing. ASSISTANT: I can't help with that. USER: What if I use a VPN? ASSISTANT: I still can't assist with unauthorized access.

Must be a non-empty array of turn objects with role and content fields. Parse check: valid JSON array. Minimum 2 assistant refusal turns required or prompt should not fire.

[REFUSAL_COUNT]

Number of times the assistant has refused or declined a user request in this session

4

Must be an integer >= 2. Schema check: typeof value === 'number' and value >= 2. If count is below threshold, skip this prompt entirely.

[REFUSAL_REASONS]

List of refusal categories or policy tags applied during the session

["unauthorized_access", "scraping_policy", "circumvention_attempt"]

Must be a non-empty array of strings matching known policy tags. Schema check: Array.isArray and every element is a string from the approved policy tag registry. Null not allowed.

[USER_FRUSTRATION_SCORE]

Sentiment or frustration score for the most recent user turns, on a 0.0 to 1.0 scale

0.82

Must be a float between 0.0 and 1.0. Schema check: typeof value === 'number' and 0 <= value <= 1. If score is below 0.6, consider suppressing handoff to avoid premature escalation.

[ESCALATION_QUEUE]

Target review queue or team identifier for routing the handoff

"trust-and-safety-tier-2"

Must be a non-empty string matching a valid queue ID in the routing system. Parse check: value exists in the configured escalation queue registry. Null not allowed.

[SESSION_ID]

Unique identifier for the current conversation session

"sess_9a7b3f2c_20250120"

Must be a non-empty string. Parse check: matches session ID format pattern defined in application config. Used for audit trail linking and review tool deep-linking.

[LOOP_PATTERN]

Detected pattern category describing the user's repeated-request strategy

"rephrasing_attack"

Must be a string from the enumerated loop pattern taxonomy: rephrasing_attack, direct_repeat, context_manipulation, role_play_escalation, or threshold_unknown. Schema check: enum membership. If unknown, use threshold_unknown and flag for manual review.

[HANDOFF_TIMESTAMP]

ISO 8601 timestamp when the handoff decision was triggered

"2025-01-20T14:32:00Z"

Must be a valid ISO 8601 string in UTC. Parse check: new Date(value) does not return Invalid Date and timezone is Z. Used for SLA measurement and review queue prioritization.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Repeated Refusal Loop Handoff Prompt into a production application with pre-processing, validation, logging, and operational safeguards.

The Repeated Refusal Loop Handoff Prompt is not a standalone safety classifier; it is a session-aware intervention trigger that must be integrated into your conversation state manager. Before invoking this prompt, your application must maintain a per-session counter that increments each time the system issues a refusal response. The counter should reset when the user receives a successful, non-refusal response, as the loop condition is defined by consecutive refusals, not total refusals across a session. Pre-processing must also extract the last N user messages and the refusal reasons issued for each, packaging them into the [CONVERSATION_HISTORY] placeholder. Without accurate refusal tracking, the prompt will either miss genuine loops or trigger false handoffs after unrelated refusals.

Wire this prompt as a synchronous check that runs after every refusal response but before the response is sent to the user. The application flow should be: (1) system generates a refusal, (2) increment the refusal counter, (3) if the counter exceeds [LOOP_THRESHOLD], invoke this prompt with the conversation context, (4) parse the structured output to determine whether to hand off, intervene with a de-escalation message, or continue. The output schema must include a decision field with enum values handoff, intervene, or continue, plus a rationale string and a suggested_message for the user. Validate that the decision field matches one of the allowed values before acting on it; if parsing fails, default to handoff to avoid leaving the user in an unresolved refusal loop. Log every invocation with the session ID, refusal count, decision, and rationale for audit and threshold tuning.

Model choice matters here. This prompt requires strong instruction-following and structured output discipline, not creative generation. Use a model with reliable JSON mode or function-calling support, such as GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro. Avoid smaller or older models that may conflate refusal detection with content moderation or produce inconsistent enum values. Set temperature to 0 or near-zero to maximize output determinism. If your stack uses tool-calling, define the output schema as a tool and require the model to call it, which provides stronger structural guarantees than parsing free-text JSON. Implement a retry with backoff if the output fails schema validation, but cap retries at 2 attempts before falling back to a hardcoded handoff decision.

Operational monitoring should track the handoff rate as a percentage of total refusals. A sudden spike may indicate a prompt regression, a model behavior change, or an adversarial campaign probing your refusal boundaries. A near-zero handoff rate may indicate the loop threshold is set too high or the refusal counter is not incrementing correctly. Both extremes warrant investigation. Additionally, route all handoff decisions to a human review queue with full conversation context, refusal history, and the prompt's own rationale. This creates a feedback loop: reviewers can confirm whether the handoff was appropriate, identify false positives, and flag cases where the system should have handed off earlier. Use these reviews to calibrate [LOOP_THRESHOLD] and refine the intervention messages.

Do not deploy this prompt without testing against adversarial scenarios. Red-team the integration by simulating users who rephrase disallowed requests across multiple turns, users who mix benign and disallowed requests to reset the counter, and users who express escalating frustration after legitimate refusals. The prompt must distinguish between a user probing policy boundaries and a user who genuinely needs human help after the system failed to address their underlying need. If your product operates in a regulated domain, ensure that handoff decisions are logged immutably and that the human review queue meets your compliance requirements for response time and reviewer qualification. Finally, pair this prompt with the Over-Refusal False Positive Review Queue Prompt to create a complete feedback loop: one prompt detects when users are stuck in refusal loops, and the other detects when the system refused something it should not have.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, validation rules, and pass/fail conditions for the Repeated Refusal Loop Handoff Prompt response. Use this contract to parse and validate the model output before routing to human review or logging.

Field or ElementType or FormatRequiredValidation Rule

loop_detected

boolean

Must be true if refusal_count >= [REFUSAL_THRESHOLD] and user_turns_since_last_successful_response >= [TURN_THRESHOLD]; otherwise false.

refusal_count

integer

Must be a non-negative integer matching the count of consecutive refusal turns detected in the session. Validate: >= 0.

loop_type

string (enum)

Must be one of: 'repeated_identical_request', 'rephrased_request', 'adversarial_probing', 'frustration_escalation', 'topic_persistence'. Validate against allowed enum values.

escalation_urgency

string (enum)

Must be one of: 'immediate', 'high', 'medium', 'low'. If loop_type is 'adversarial_probing' or 'frustration_escalation', urgency must be 'immediate' or 'high'.

handoff_rationale

string

Must be a non-empty string (1-500 characters) summarizing why handoff is triggered. Must reference refusal_count and loop_type. Validate: length > 0 and length <= 500.

user_frustration_signals

array of strings

If present, each element must be a non-empty string describing a detected frustration signal (e.g., 'repeated rephrasing', 'ALL CAPS', 'direct complaint'). Validate: array elements are strings with length > 0.

recommended_human_action

string

Must be a non-empty string (1-300 characters) suggesting the initial action for the human reviewer. Must not instruct the model to continue responding. Validate: length > 0 and length <= 300.

session_context_summary

string

Must be a non-empty string (1-1000 characters) containing a concise summary of the refused requests and user responses. Must not include PII placeholders. Validate: length > 0 and length <= 1000.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when a repeated refusal loop handoff prompt is deployed in production, and how to guard against each failure mode.

01

Loop Counter Drift

What to watch: The prompt relies on an external loop counter that is not reliably incremented or reset across sessions, causing the handoff trigger to fire too early or never. Guardrail: Implement the refusal counter in the application layer, not the prompt. Persist it per session and validate it before injection. Include a hard upper bound that forces escalation regardless of counter state.

02

Adversarial Rephrasing Evasion

What to watch: A user rephrases the same disallowed request across turns, bypassing exact-match or embedding-based similarity checks and resetting the perceived refusal count. Guardrail: Use a semantic similarity threshold against prior refused requests in the session. If a new turn's intent is within a calibrated cosine distance of a previously refused request, increment the counter. Log the similarity score for audit.

03

Over-Escalation on Benign Clarification

What to watch: The system miscounts user clarification turns ("Why can't you do that?") as repeated disallowed requests, triggering a premature handoff and flooding the review queue. Guardrail: Classify each user turn as a new disallowed request, a clarification, or a challenge before incrementing the counter. Only increment on new requests or direct re-attempts. Route clarifications to a safe-alternative path instead.

04

Handoff Context Starvation

What to watch: The escalation prompt passes only the final turn to the human reviewer, stripping the conversation history that explains why the loop occurred. Guardrail: Package the full session transcript, refusal reasons per turn, counter state, and a structured summary of the user's apparent goal into the handoff payload. Validate payload completeness before sending to the review queue.

05

Loop-Breaking Intervention Backfire

What to watch: The prompt's loop-breaking message ("I've noticed you're stuck; let me connect you to a human") is interpreted by the user as a reward for adversarial behavior, encouraging repeat probing. Guardrail: Frame the intervention as a neutral process step, not an apology or concession. Test intervention language with red-team scenarios to ensure it does not reinforce the probing behavior. A/B test phrasing against escalation rates.

06

Silent Failure on Counter Injection

What to watch: The application fails to inject the refusal counter into the prompt template due to a variable naming error or missing session state, and the model proceeds without loop detection. Guardrail: Add a pre-injection assertion that the counter variable is an integer and is present in the rendered prompt. If the assertion fails, default to a safe escalation path and log the injection failure as a critical operational alert.

IMPLEMENTATION TABLE

Evaluation Rubric

Pass/fail criteria for evaluating the Repeated Refusal Loop Handoff Prompt against a golden dataset of 20-30 conversation transcripts with known loop types and correct actions.

CriterionPass StandardFailure SignalTest Method

Loop Detection Accuracy

Correctly identifies 95% of transcripts where the user has received 3 or more refusals for the same or similar request

Misses repeated refusal patterns; fails to trigger handoff when refusal count exceeds threshold

Run prompt against golden dataset transcripts with known refusal counts; measure recall and precision

Loop Type Classification

Classifies the loop type (adversarial probing, frustrated rephrase, policy boundary test, genuine need) with 90% accuracy against human labels

Misclassifies adversarial probing as frustrated rephrase; labels genuine need as policy boundary test

Compare prompt output loop_type field to ground-truth labels in golden dataset; compute F1 per class

Handoff Trigger Decision

Outputs handoff_required: true for all transcripts meeting the loop threshold and false for all below-threshold transcripts

Triggers handoff for single-refusal transcripts; fails to trigger for transcripts with 5+ refusals

Binary classification check: compare handoff_required boolean to expected value per transcript

Escalation Urgency Scoring

Assigns urgency score within 1 point of human-assigned ground truth on a 1-5 scale for 90% of transcripts

Scores adversarial probing as low urgency; scores frustrated rephrase as maximum urgency

Mean absolute error between prompt output urgency_score and golden dataset label; threshold <= 1.0

Handoff Reason Quality

Generates a handoff reason that includes specific loop count, detected pattern, and user sentiment in 3 sentences or fewer

Produces generic reason like user is unhappy; omits refusal count; exceeds 5 sentences

Human review of reason field against transcript; check for required elements: count, pattern, sentiment

Context Preservation

Includes last 3 user messages and last 2 assistant refusal messages in the handoff summary payload

Truncates user messages; includes only assistant messages; omits refusal context entirely

Parse output context_summary field; verify message count and role distribution match transcript

False Positive Rate

Handoff trigger rate below 10% for transcripts with fewer than 3 refusals

Triggers handoff for 30% or more of below-threshold transcripts

Run prompt against below-threshold subset of golden dataset; compute false positive rate

Adversarial Pattern Flagging

Flags adversarial probing transcripts with security_concern: true and includes attack vector classification

Misses jailbreak attempts embedded in repeated refusals; classifies injection as frustrated user

Check security_concern boolean and attack_vector field against security-labeled transcripts in dataset

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a simple counter. Track consecutive refusals per session. Use a hard threshold (e.g., 3 refusals in a row) to trigger handoff. Keep the handoff message simple: acknowledge the loop, apologize, and offer human review.

code
[SYSTEM_INSTRUCTION]
You track refusal counts. After [REFUSAL_THRESHOLD] consecutive refusals in a session, stop refusing and respond with:
"I've been unable to help with your last few requests. I'm routing you to a human reviewer who can assist. [HANDOFF_INSTRUCTIONS]"

Watch for

  • Counting non-refusal turns as refusals
  • Failing to reset the counter after a successful response
  • Handoff message that sounds like another refusal
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.