This prompt is designed for safety engineers and product teams who need a deterministic, auditable gate that enforces the declared capability boundaries of an AI system. Its job is to receive a user input and a machine-readable policy document, then return a structured decision: in_scope or out_of_scope. For out-of-scope requests, it also produces a stable reason code and a safe, graceful rejection message that can be surfaced directly to the user or logged for review. Use this prompt when you need a single, consistent enforcement point before any model reasoning, tool use, or data access occurs—particularly in customer-facing products where hallucinating an answer to an unsupported request damages trust or creates liability.
Prompt
Out-of-Scope Detection Prompt for Boundary Enforcement

When to Use This Prompt
Define the exact job this prompt performs, the operator who should use it, and the hard boundaries where it stops being the right tool.
Deploy this prompt at the ingress layer of your AI pipeline, immediately after input sanitization and before intent classification or agent dispatch. It works best when your system has a clearly defined, version-controlled capability boundary document that enumerates supported domains, excluded categories, and edge-case handling rules. The prompt expects that boundary policy as a structured input alongside the user message, which means you can update your system's scope without changing the prompt itself—just update the policy payload. Do not use this prompt for ambiguous gray-area detection where you need nuanced confidence scores; it is optimized for binary enforcement with clear rejection paths. For ambiguous cases, pair it with an upstream ambiguity detection prompt that can request clarification before reaching this gate.
Avoid deploying this prompt as the sole safety mechanism in high-stakes regulated domains without a human review fallback for edge cases. The prompt is strong at enforcing explicit boundaries but can be brittle when policy documents contain contradictions or when users employ sophisticated social engineering to reframe out-of-scope requests. Always log the reason codes and rejection messages for false-positive analysis, and set up a monitoring dashboard that tracks rejection rates by category. If your rejection rate spikes in a particular category, investigate whether your boundary policy is too restrictive or whether users have a legitimate unmet need that should be added to scope. The next section provides the copy-ready prompt template you can adapt to your own boundary policy format.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the Out-of-Scope Detection Prompt is the right tool for your boundary enforcement problem before you integrate it into a production router.
Good Fit: Pre-Processing Guard
Use when: you need to block unsupported requests before they consume expensive model inference, tool calls, or database lookups. Guardrail: Deploy this prompt as a lightweight first-stage classifier with a strict latency budget. Route out-of-scope inputs to a static rejection message without invoking the primary agent.
Bad Fit: Open-Ended Discovery
Avoid when: the system's capability boundary is intentionally broad or undefined, such as in general-purpose chatbots or exploratory research tools. Guardrail: If you cannot enumerate what is out of scope, use a confidence-based ambiguity detector instead. A rigid boundary prompt will generate excessive false positives and frustrate users.
Required Inputs
What to watch: The prompt requires a maintained boundary policy document, a taxonomy of supported capabilities, and example inputs for both in-scope and out-of-scope cases. Guardrail: Version your boundary policy alongside the prompt. If the policy is stale, the classifier will silently reject valid requests or pass disallowed ones.
Operational Risk: Policy Drift
What to watch: As your product adds features, the boundary policy must be updated. An out-of-date policy causes false out-of-scope rejections for newly supported capabilities. Guardrail: Treat boundary policy updates as a release gate. Run regression tests against a golden set of new in-scope examples before deploying any prompt change.
Operational Risk: False Positives
What to watch: Overly strict boundary enforcement blocks legitimate requests that use unexpected phrasing, misspellings, or indirect language. Guardrail: Monitor the false-positive rate by sampling rejected inputs daily. Provide users with a clear escalation path, such as
Operational Risk: Hallucinated Rejections
What to watch: The model may fabricate a reason code or rejection message that misrepresents the system's actual capabilities, damaging user trust. Guardrail: Constrain the output to a predefined enum of reason codes and a curated set of rejection templates. Never allow the model to generate free-form explanations of what the system cannot do.
Copy-Ready Prompt Template
A reusable prompt template for classifying user requests as in-scope or out-of-scope with reason codes and rejection messages.
This template provides the core instruction set for an out-of-scope detection prompt. It is designed to be injected into a system prompt or used as a standalone classifier. The prompt forces the model to make a binary decision, provide a structured reason code, and generate a graceful, non-hallucinatory rejection message when a request falls outside the system's defined boundaries. This is not a generic safety filter; it is a capability boundary enforcer that prevents the system from attempting tasks it was not designed to handle.
codeYou are a boundary enforcement classifier. Your only job is to determine if a user request falls within the system's defined capabilities. ## SYSTEM CAPABILITIES [CAPABILITY_DEFINITION] ## USER REQUEST [USER_INPUT] ## INSTRUCTIONS 1. Analyze the user request against the system capabilities above. 2. If the request is fully addressable by the capabilities, classify as "in_scope". 3. If any part of the request requires capabilities not listed, classify as "out_of_scope". 4. For out-of-scope requests, identify the primary reason from the [REASON_CODE_LIST]. 5. Generate a rejection message that is polite, helpful, and does not hallucinate capabilities. ## OUTPUT SCHEMA Respond with a single JSON object: { "classification": "in_scope" | "out_of_scope", "reason_code": "[REASON_CODE_LIST]", "rejection_message": "string, only if out_of_scope, otherwise null", "violated_capability": "string, the specific capability that is missing, only if out_of_scope" } ## CONSTRAINTS - Do not attempt to fulfill the user request. - Do not provide partial solutions for out-of-scope requests. - The rejection message must not imply future capability.
To adapt this template, replace [CAPABILITY_DEFINITION] with a clear, bulleted list of what your system can actually do. The [REASON_CODE_LIST] should be a finite set of codes like unsupported_domain, requires_external_action, prohibited_use_case, or missing_tool. The [USER_INPUT] placeholder receives the raw user message. For high-stakes domains, always route out_of_scope classifications to a human review queue before sending the rejection message to the user, and log the reason_code and violated_capability for boundary policy review.
Prompt Variables
Required inputs for the Out-of-Scope Detection Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Validation notes describe how to programmatically verify the input before invocation.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_INPUT] | The raw user message or request to classify as in-scope or out-of-scope | Can you help me file my taxes for last year? | Non-empty string required. Max length check against context window budget. Sanitize for null bytes and control characters before insertion. |
[BOUNDARY_POLICY] | A natural-language description of the system's supported capabilities, domains, and explicit exclusions | This assistant supports software engineering questions, code review, and debugging. It does not provide legal, financial, or medical advice. | Non-empty string required. Must contain both inclusion and exclusion criteria. Version-controlled policy document. Schema check: policy text must include at least one exclusion statement. |
[OUTPUT_SCHEMA] | The expected JSON structure for the classification result, including reason codes and rejection message template | {"classification": "in_scope"|"out_of_scope", "reason_code": "string", "rejection_message": "string|null"} | Valid JSON schema required. Must include classification enum, reason_code field, and nullable rejection_message. Parse check before prompt assembly. Schema must match downstream routing handler expectations. |
[REASON_CODES] | An enumerated list of valid reason codes the model can use to explain out-of-scope decisions | ["unsupported_domain", "policy_violation", "safety_boundary", "capability_gap", "legal_restriction"] | Non-empty array of strings required. Each code must be a valid identifier matching downstream handler case statements. Duplicate check on codes. Must align with BOUNDARY_POLICY exclusion categories. |
[REJECTION_TEMPLATE] | A base template for the graceful rejection message shown to users when input is out-of-scope | I'm unable to help with [domain]. I can assist with [supported_capabilities]. Would you like to rephrase your request? | Non-empty string required. Must contain at least one variable slot for domain insertion. Template syntax check: all bracketed slots must be resolvable from classification output or policy context. |
[CONFIDENCE_THRESHOLD] | The minimum confidence score required for automated routing; scores below this trigger human review or clarification | 0.85 | Float between 0.0 and 1.0. Must be parseable as number. Threshold should be configurable per environment. Values below 0.7 risk high false-positive rates in production. |
[FALLBACK_ACTION] | Instruction for what the system should do when confidence is below threshold or classification is ambiguous | Route to human review queue with classification attempt and confidence score attached. Do not send automated rejection. | Non-empty string required. Must specify a concrete action. Acceptable values: route_to_human, ask_clarification, log_and_abstain. Must not default to silent acceptance or rejection. |
Implementation Harness Notes
How to wire the out-of-scope detection prompt into a production application with validation, logging, and safe fallback paths.
The out-of-scope detection prompt is a pre-processing guard that should execute before any domain-specific logic, tool dispatch, or LLM generation. In a typical request pipeline, this prompt sits immediately after input ingestion and PII redaction, but before intent classification or model routing. Its job is to produce a binary in_scope / out_of_scope decision with a machine-readable reason_code and a user-facing rejection_message. The rejection message must be safe to display directly to end users without modification—never include internal system details, policy names, or capability hints that could be exploited in adversarial probing.
Integration pattern: Call this prompt synchronously and block downstream processing when in_scope is false. The recommended flow: (1) Receive user input. (2) Run PII redaction if needed. (3) Execute the out-of-scope detection prompt with the current [BOUNDARY_POLICY] injected from a configuration store. (4) Parse the JSON response and validate the schema—reject malformed outputs as a system error. (5) If in_scope is false, return the rejection_message to the user with HTTP 422 or an equivalent "unprocessable" status, log the reason_code and input hash, and increment a rejection_count metric. (6) If in_scope is true, pass the input to the next stage (intent classification, tool router, or agent loop). Never fall through to generation on a parse failure—treat unparseable outputs as out-of-scope with a generic fallback message.
Validation and retries: The output must conform to a strict schema: {"in_scope": boolean, "reason_code": string, "rejection_message": string | null}. Validate this with a JSON schema validator in application code, not with a follow-up LLM call. If validation fails, retry once with the same prompt and a stronger constraint instruction appended (e.g., "You must respond with valid JSON only"). If the retry also fails, log the raw output, return the generic rejection message, and fire an alert for prompt degradation. Do not retry more than once—latency budgets for guard prompts should be tight (under 500ms p95).
Observability and policy updates: Log every decision with reason_code, input_hash, model_version, prompt_version, and latency_ms. Build a dashboard that tracks rejection rates by reason code and monitors for sudden spikes that indicate policy drift or adversarial campaigns. The [BOUNDARY_POLICY] placeholder should be populated from a version-controlled configuration file or feature flag, not hardcoded. When the product scope expands, update the policy document, run the new prompt version against a golden dataset of known in-scope and out-of-scope examples, and compare rejection rates before promoting. Human review is required when the rejection rate shifts by more than 5% in a release window or when a new reason_code appears in production traffic—this may indicate misclassification or an unanticipated user need that should be routed to product management, not silently rejected.
Expected Output Contract
Define the exact shape, types, and validation rules for the Out-of-Scope Detection prompt's output. Use this contract to build a parser, validator, and retry logic in your application harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
classification | string enum: | Must be exactly one of the two allowed enum values. Reject any other string. | |
reason_code | string from [POLICY_CODE_LIST] | Must match an entry in the provided policy code list. If classification is | |
confidence_score | float between 0.0 and 1.0 | Parse as float. Must be >= 0.0 and <= 1.0. If below [CONFIDENCE_THRESHOLD], trigger human review. | |
rejection_message | string or null | If classification is | |
policy_evidence | array of strings | Each string must be a direct quote or reference from [BOUNDARY_POLICY]. Array must not be empty if classification is | |
clarification_question | string or null | If confidence_score < [CLARIFICATION_THRESHOLD], this must be a non-empty string asking for clarification. Otherwise null. | |
escalation_required | boolean | Must be true if classification is |
Common Failure Modes
Out-of-scope detection prompts fail in predictable ways. These are the most common production failure modes and the specific guardrails that prevent them.
False Negatives: In-Scope Requests Rejected
What to watch: The prompt rejects valid requests as out-of-scope because the boundary policy is too narrow, uses brittle keyword matching, or fails to recognize legitimate paraphrases. Users hit dead ends on supported capabilities. Guardrail: Maintain a golden set of boundary-case in-scope examples. Run regression tests on every policy update. Log rejection reasons and review a sample daily for false negatives. Use semantic similarity thresholds rather than exact keyword lists.
False Positives: Out-of-Scope Requests Accepted
What to watch: The model hallucinates a capability it doesn't have, accepts dangerous requests by reframing them as in-scope, or gets persuaded by adversarial phrasing. The system then attempts unsupported work, wastes compute, or produces unsafe output. Guardrail: Require the prompt to output a specific reason code and evidence span from the input before classifying as in-scope. Implement a secondary lightweight check on high-risk categories. Monitor the ratio of accepted requests that later produce errors or empty tool calls.
Boundary Policy Drift After Updates
What to watch: When the product scope expands or contracts, the prompt's boundary description becomes stale. New capabilities aren't recognized as in-scope, or deprecated features are still accepted. The prompt silently diverges from the actual system contract. Guardrail: Version the boundary policy alongside the prompt template. Run the full eval suite—not just the new cases—after every policy change. Include a 'last updated' timestamp in the system prompt that must match the deployment version. Flag mismatches in CI/CD.
Rejection Message Leaks Capability Hints
What to watch: The graceful rejection message accidentally reveals what the system can do, invites prompt injection, or suggests workarounds. Example: 'I can't help with financial advice, but I can analyze spreadsheets' opens a new attack surface. Guardrail: Audit rejection templates for information leakage. Use fixed, minimal rejection messages that don't enumerate capabilities. Test rejection responses against a red-team checklist. Never let the model generate free-form rejection text for high-risk categories.
Ambiguous Boundary Cases Default to Rejection
What to watch: When the model is uncertain, it conservatively rejects requests that a human would handle. Over time, this trains users to rephrase requests to bypass the guard, or drives them to abandon the system. Guardrail: Add a 'clarify' action for ambiguous cases instead of binary in/out. The prompt should output action: clarify with a specific question when confidence is below threshold. Track the clarify-to-reject ratio. If clarification never resolves to acceptance, the boundary is too strict.
Multi-Turn Context Corrupts Boundary Enforcement
What to watch: A user starts with an in-scope request, then gradually steers the conversation out-of-scope across multiple turns. The prompt evaluates each turn in isolation and misses the cumulative drift. Guardrail: Include a compressed conversation summary in the classification context, not just the latest user message. Add a 'conversation trajectory' check: if the topic has shifted significantly from the initial in-scope intent, re-evaluate the entire session against the boundary policy.
Evaluation Rubric
Use this rubric to test the Out-of-Scope Detection Prompt before deployment. Each criterion targets a specific failure mode that breaks boundary enforcement in production.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
In-Scope Classification Accuracy | Correctly classifies 100% of in-scope test cases as in_scope with the correct [SCOPE_CATEGORY] | In-scope input flagged as out_of_scope or assigned wrong [SCOPE_CATEGORY] | Run against a golden dataset of 50 in-scope examples covering all defined [SCOPE_CATEGORY] values |
Out-of-Scope Detection Recall | Correctly classifies 100% of out-of-scope test cases as out_of_scope | Out-of-scope input classified as in_scope with a hallucinated [SCOPE_CATEGORY] | Run against a curated set of 30 clearly out-of-scope inputs spanning adjacent domains, adversarial prompts, and nonsense queries |
Reason Code Validity | Every out_of_scope classification includes a [REASON_CODE] that exactly matches one of the allowed values in [OUT_OF_SCOPE_REASON_CODES] | Missing [REASON_CODE], null value, or a reason code not present in the allowed list | Parse all out_of_scope outputs and validate [REASON_CODE] against the allowed enum using a strict string match |
Rejection Message Template Compliance | Every out_of_scope output includes a [REJECTION_MESSAGE] that uses the approved template structure without hallucinated capabilities or future promises | Rejection message suggests the system can handle the request, invents features, or uses a tone inconsistent with the [BRAND_VOICE] policy | Human review of 20 rejection messages sampled across reason codes; automated check for banned phrases like 'I can help with that' in out_of_scope paths |
Boundary Policy Adherence | Classification respects the latest [BOUNDARY_POLICY] document including edge cases and explicit inclusions/exclusions | Input that matches an explicit exclusion in [BOUNDARY_POLICY] is classified as in_scope, or an explicit inclusion is rejected | Update [BOUNDARY_POLICY] with 5 new edge cases and verify the prompt correctly classifies all 5 within 3 evaluation runs |
False Positive Rate Stability | False positive rate on in-scope inputs remains below 5% when measured across a 200-example production sample | False positive rate exceeds 5% or spikes more than 2 percentage points between evaluations | Weekly automated run against a fixed 200-example benchmark; alert if rate exceeds threshold |
Ambiguity Handling | Inputs that are genuinely ambiguous between in-scope and out-of-scope produce an out_of_scope classification with reason_code 'ambiguous_boundary' and a rejection message that asks for clarification | Ambiguous input is confidently misclassified as in_scope or produces a generic out_of_scope rejection without the clarification request | Test with 10 hand-crafted ambiguous inputs that sit at the boundary of [SCOPE_CATEGORY] definitions; verify consistent reason_code and clarification language |
Latency Budget Compliance | Classification completes within [LATENCY_BUDGET_MS] milliseconds for 99th percentile of requests | 99th percentile latency exceeds [LATENCY_BUDGET_MS] or timeout errors occur on valid inputs | Load test with 100 concurrent requests; measure p50, p95, p99 latency and timeout rate |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a static boundary policy list in [BOUNDARY_POLICY]. Use a simple in-scope/out-of-scope binary decision without reason codes. Accept any structured output format the model produces naturally, then post-process to extract the decision.
codeClassify the following input as in-scope or out-of-scope based on this policy: [BOUNDARY_POLICY] Input: [USER_INPUT] Return only "in-scope" or "out-of-scope".
Watch for
- Missing reason codes make debugging classification errors harder
- Static policy lists drift from actual product capabilities
- No confidence threshold means borderline cases get arbitrary labels
- Overly broad policy descriptions cause false positives on edge cases

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us