This prompt is designed for privacy-sensitive assistant deployments that process user data across multiple conversation turns. Its primary job is to act as a policy enforcement gate: it evaluates whether an assistant's generated response or stored session state contains personally identifiable information (PII) that violates a defined redaction policy. The ideal user is an AI engineer or platform developer integrating a chat assistant into a regulated product, such as a healthcare intake form, a financial advisory copilot, or a customer support agent handling account details. You need this prompt when your system-level instructions alone are insufficient to prevent PII leakage, especially in long-running sessions where context drift can erode initial privacy constraints.
Prompt
PII Redaction Policy Enforcement Prompt

When to Use This Prompt
Define the job, ideal user, and operational boundaries for the PII Redaction Policy Enforcement Prompt.
Use this prompt as a post-generation validation step before a response is sent to the user or written to a persistent session log. It requires a clear [REDACTION_POLICY] specifying which PII categories to detect (e.g., names, emails, credit card numbers, SSNs), a [SESSION_CONTEXT] containing recent turns, and the [ASSISTANT_OUTPUT] to be audited. The prompt is not a replacement for deterministic input sanitization or API-level PII scrubbing; it is a semantic safety net that catches contextual leaks, such as an assistant inferring and restating a user's name from a previous turn. It should not be used for real-time, character-by-character redaction in streaming outputs, nor as the sole defense in environments requiring certified data loss prevention (DLP) systems.
Before deploying this prompt, define the exact failure modes you are guarding against. Common risks include the assistant echoing a user's full name after a casual introduction, exposing a phone number embedded in a multi-turn troubleshooting dialogue, or writing unmasked PII into a session summary. The prompt's output includes a structured audit trail, which is essential for compliance review and debugging false positives. If your application operates in a jurisdiction with strict data residency or privacy regulations (e.g., GDPR, HIPAA), this prompt should be paired with a human review step for any redacted output or policy violation flag. Do not rely on this prompt to classify data it cannot see; ensure your [SESSION_CONTEXT] includes all turns that might contain PII, as omission is a primary cause of silent failures.
Use Case Fit
Where the PII Redaction Policy Enforcement prompt delivers value and where it creates risk. Use these cards to decide if this prompt fits your workflow before integrating it into a production harness.
Good Fit: Privacy-Sensitive Chat Sessions
Use when: you are building a customer support, healthcare, or financial assistant that processes user messages across multiple turns and must guarantee that no PII survives in assistant responses or stored state. Guardrail: Run this prompt as a post-generation gate before any response is returned to the user or written to session storage.
Bad Fit: Real-Time Streaming Without Buffering
Avoid when: your application streams tokens directly to the user without buffering the complete response. Guardrail: This prompt requires the full assistant output to inspect for PII. Buffer the response, run the enforcement check, and only release the output after validation passes.
Required Input: Session Redaction Policy Contract
Risk: Without an explicit, machine-readable redaction policy, the prompt cannot distinguish between permitted and prohibited data types. Guardrail: Provide a structured policy object specifying which PII categories require redaction, permitted exceptions, and the required redaction format before invoking this prompt.
Operational Risk: Latency Budget Bloat
Risk: Adding a full-pass PII enforcement prompt to every turn can double response latency, degrading user experience in synchronous chat. Guardrail: Implement tiered enforcement: run the full audit on turns flagged as high-risk by a lightweight classifier, and use a faster regex-based pre-scan for low-risk turns.
Operational Risk: Over-Redaction Breaking Output Utility
Risk: Aggressive redaction can strip names, dates, and identifiers that are necessary for the assistant's response to be useful, frustrating users. Guardrail: Configure the policy with explicit permitted-context exceptions and require the prompt to produce a redaction rationale log so operators can audit false-positive redactions.
Bad Fit: Unstructured Free-Text Policy Descriptions
Avoid when: your redaction policy exists only as a paragraph of natural language with no structured schema. Guardrail: Convert your policy into a structured format with explicit PII categories, redaction actions, and exception rules before using this prompt. Ambiguous policies produce inconsistent enforcement.
Copy-Ready Prompt Template
A reusable prompt template for detecting PII in assistant outputs and enforcing redaction or refusal policies with an audit trail.
This prompt template is designed to be inserted into a multi-turn assistant pipeline whenever a response is generated or state is stored. It evaluates the proposed output against a configurable PII redaction policy and produces either a sanitized version of the output or a policy-compliant refusal. The template uses square-bracket placeholders so you can wire in your specific policy definitions, risk levels, and output schemas without modifying the core logic.
textYou are a PII Redaction Policy Enforcement agent. Your job is to inspect the [OUTPUT_TO_CHECK] against the active [REDACTION_POLICY] and produce a compliant result. [REDACTION_POLICY] defines: - Which PII categories must be redacted (e.g., name, email, phone, SSN, address, IP, financial account numbers). - The redaction method: [REDACT] (replace with [REDACTION_TOKEN]), [REFUSE] (block the output and return a refusal message), or [MASK] (partial masking, e.g., "j***@example.com"). - The [RISK_LEVEL] threshold: [LOW] (redact only explicit PII), [MEDIUM] (redact explicit and inferred PII), or [HIGH] (refuse any output that may contain or imply PII). [OUTPUT_TO_CHECK] is the assistant's proposed response or state update that must be inspected. Your response must be valid JSON matching this schema: { "decision": "pass" | "redact" | "refuse", "redacted_output": "string or null if refused", "audit_trail": [ { "pii_type": "string", "original_value": "string", "action": "redacted" | "masked" | "blocked", "location": "string describing where in the output it was found", "confidence": "high" | "medium" | "low" } ], "refusal_message": "string or null if not refused", "policy_version": "string from [POLICY_VERSION]" } Rules: 1. If [RISK_LEVEL] is [HIGH] and any PII is detected, you must refuse the entire output. 2. If [RISK_LEVEL] is [MEDIUM] and inferred PII is detected (e.g., context suggests an email without explicit @ sign), treat it as PII. 3. If [RISK_LEVEL] is [LOW], only redact explicit matches and allow the output through. 4. Never output the original PII values outside the audit_trail. The redacted_output field must be safe to display. 5. If no PII is detected, return "decision": "pass" with an empty audit_trail and the original output in redacted_output. 6. The audit_trail must include every detected PII instance with its type, action taken, and confidence. [EXAMPLES] Example 1: Input: "My name is John Smith and my email is john@example.com" Policy: [REDACT], [MEDIUM] Output: {"decision": "redact", "redacted_output": "My name is [REDACTED] and my email is [REDACTED]", "audit_trail": [{"pii_type": "name", "original_value": "John Smith", "action": "redacted", "location": "start of message", "confidence": "high"}, {"pii_type": "email", "original_value": "john@example.com", "action": "redacted", "location": "end of message", "confidence": "high"}], "refusal_message": null, "policy_version": "1.0"} Example 2: Input: "The account number is 4111-1111-1111-1111" Policy: [REFUSE], [HIGH] Output: {"decision": "refuse", "redacted_output": null, "audit_trail": [{"pii_type": "financial_account", "original_value": "4111-1111-1111-1111", "action": "blocked", "location": "end of message", "confidence": "high"}], "refusal_message": "I cannot process this request because it contains sensitive financial information. Please remove the account number and try again.", "policy_version": "1.0"}
To adapt this template, replace the square-bracket placeholders with your actual policy definitions before sending it to the model. The [REDACTION_POLICY] placeholder should contain a concrete list of PII categories and their handling rules. The [RISK_LEVEL] should be set based on your deployment context—use HIGH for regulated industries where any PII leakage is unacceptable. Wire the JSON output into a post-processing validator that checks the schema before the redacted output reaches the user. For production deployments, log every audit_trail entry to your monitoring system and set up an alert if the refusal rate spikes, which may indicate an upstream data leak or a policy misconfiguration.
Prompt Variables
Required inputs for the PII Redaction Policy Enforcement Prompt. Each variable must be populated before the prompt is assembled and sent. Missing or malformed variables will cause the prompt to fail closed (refuse to process) rather than risk PII leakage.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_MESSAGE] | The raw user utterance or assistant draft that must be scanned for PII before release or storage. | My SSN is 123-45-6789 and I live at 742 Evergreen Terrace. | Must be a non-empty string. Null or empty input should trigger an immediate refusal response without model invocation. |
[REDACTION_POLICY] | A structured definition of which PII categories to detect and the required action per category (redact, block, allow, mask). | {"ssn": "redact", "email": "mask", "phone": "redact", "address": "block", "name": "allow"} | Must be valid JSON with known PII category keys. Unknown keys should be treated as 'block' by default. Schema validation required before prompt assembly. |
[SESSION_CONTEXT] | Optional prior turns or stored state that may contain PII introduced earlier in the session. Used to detect PII leakage through context persistence. | User previously provided: 'My work email is alice@company.com' | Can be null or empty string. If provided, must be a string under 4000 tokens. Longer context should be summarized before passing to this prompt. |
[DETECTION_AUDIT_REQUIRED] | Boolean flag controlling whether the output must include a structured audit trail of every detection decision. | Must be exactly 'true' or 'false'. If 'true', the output schema must include the 'audit_trail' array. If 'false', the audit trail field may be omitted. | |
[OUTPUT_SCHEMA] | The expected JSON schema for the redaction result, including fields for redacted text, blocked categories, and optional audit trail. | {"redacted_output": "string", "pii_detected": ["ssn", "address"], "action_taken": "redacted", "audit_trail": [{"category": "ssn", "match": "--***", "action": "redact"}]} | Must be valid JSON Schema or a TypeScript interface definition. The prompt will validate its own output against this schema. Schema mismatch between policy and output contract is a critical failure. |
[MASKING_STYLE] | Defines how redacted PII should appear in the output: full removal, character masking, category labels, or custom replacement strings. | {"ssn": "--***", "email": "[REDACTED_EMAIL]", "default": "[REDACTED]"} | Must be valid JSON mapping PII categories to replacement strings. If a category in REDACTION_POLICY has action 'redact' or 'mask' but no entry here, the default value must be used. Missing default key is a validation failure. |
[FAILURE_MODE] | Controls whether the prompt should refuse to respond, return an error, or attempt best-effort redaction when detection confidence is low. | best_effort | Must be one of: 'strict_refuse', 'best_effort', 'flag_for_review'. 'strict_refuse' blocks any uncertain detection. 'best_effort' redacts and flags. 'flag_for_review' passes through but marks for human review. |
Implementation Harness Notes
How to wire the PII Redaction Policy Enforcement Prompt into a production application with validation, logging, and human review gates.
The PII Redaction Policy Enforcement Prompt is not a standalone filter—it is a policy decision point that must be integrated into your assistant's response pipeline. The prompt receives the assistant's draft response, the session's redaction policy, and any stored state, then produces a structured verdict: either a redacted output or a policy-compliant refusal, along with a detection audit trail. This prompt should run as a synchronous pre-release gate before any assistant response reaches the user. If your system stores conversation state or summaries, you must also run this prompt against any state payloads before they are written to your database or passed to downstream retrieval systems. The prompt's value is in the audit trail it produces—without it, you have no evidence that redaction was attempted or why a refusal was issued.
Pipeline placement: Insert this prompt between the assistant's response generation step and the user-facing delivery step. The typical flow is: (1) assistant generates a draft response, (2) draft is passed to this prompt along with [REDACTION_POLICY] and [SESSION_CONTEXT], (3) the prompt returns a JSON verdict with action (redact/refuse/pass), redacted_output (if applicable), and detections array, (4) your application layer inspects the verdict and either delivers the redacted output, surfaces the refusal message, or escalates for human review. Do not rely on the model to enforce the policy inline during response generation—separation of generation and enforcement gives you independent auditability and makes policy changes deployable without retuning your generation prompt.
Validation and retry logic: Parse the prompt's JSON output and validate it against a strict schema before acting on it. Required fields: action (enum: redact, refuse, pass), redacted_output (string, required when action is redact), refusal_message (string, required when action is refuse), detections (array of objects with type, confidence, location, redaction_applied). If validation fails, retry once with the validation error injected into the prompt's [PREVIOUS_ERROR] placeholder. If the second attempt also fails validation, escalate to human review and log the raw output. For high-risk domains (healthcare, finance, legal), consider requiring human approval for any redact action where confidence is below 0.9 or where the detection count exceeds a threshold you define in [RISK_THRESHOLDS].
Logging and audit trail: Log every invocation of this prompt, including the input draft, the full JSON verdict, the validation result, and the final action taken. The detections array is your compliance evidence—store it alongside the conversation turn for audit review. If you are using a model router or fallback chain, ensure the prompt runs against the final draft response, not an intermediate candidate. For session state redaction, run this prompt against any serialized state before storage and log the redaction verdict separately from the conversation log. This separation lets auditors verify that PII was removed from state without reconstructing the full conversation.
Model choice and latency budget: This prompt benefits from models with strong instruction-following and structured output capabilities. GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro are suitable defaults. Expect 200-800ms of added latency depending on input length and model. If your latency budget is tight, consider running this prompt asynchronously for low-risk turns (where [RISK_LEVEL] is low) and synchronously for medium and high risk turns. Never skip the prompt entirely—a missed redaction is a compliance incident. For local or air-gapped deployments, test this prompt thoroughly with open-weight models; structured output reliability varies significantly and you may need to add a repair step using the Output Repair and Validation Prompts pillar patterns.
Expected Output Contract
Fields, types, and validation rules for the PII Redaction Policy Enforcement prompt output. Use this contract to parse, validate, and route the assistant response before it reaches downstream systems or users.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
redaction_decision | string enum: redacted | refused | clean | Must match one of the three allowed values exactly. If the input contains no detectable PII, return clean. If PII is detected and redaction succeeds, return redacted. If PII is detected but redaction would break output utility or policy requires refusal, return refused. | |
redacted_output | string or null | Required when redaction_decision is redacted. Must be the fully redacted version of [INPUT_TEXT] with all detected PII instances replaced by [REDACTION_PLACEHOLDER]. Null when decision is clean or refused. Validate that no PII patterns from the detection audit trail appear in this field. | |
detection_audit_trail | array of objects | Each object must contain pii_type, start_index, end_index, confidence, and action fields. pii_type must match one of the [PII_CATEGORIES] provided. start_index and end_index must be valid character offsets in [INPUT_TEXT]. confidence must be a float between 0.0 and 1.0. action must be redact or flag. Array may be empty only when decision is clean. | |
policy_violation_summary | string or null | Required when redaction_decision is refused. Must explain which [REDACTION_POLICY] rules were violated and why redaction was insufficient. Null when decision is redacted or clean. Must not contain any PII from the original input. | |
refusal_message | string or null | Required when redaction_decision is refused. Must be a user-facing message explaining that the request cannot be processed due to PII policy, using the tone specified in [REFUSAL_TONE]. Null when decision is redacted or clean. Must not expose detected PII types or locations. | |
redaction_timestamp | string ISO 8601 | UTC timestamp of when the redaction check was performed. Must be parseable as a valid datetime. Used for audit trail correlation with session logs. | |
session_policy_version | string | Must match the [POLICY_VERSION] provided in the prompt input. Enables traceability when redaction policies are updated mid-session. Reject if this field does not match the expected version. | |
processing_notes | string or null | Optional field for internal logging. May contain edge-case notes, low-confidence flags, or human-review recommendations. Must not contain any PII from the original input. Null if no notes are needed. |
Common Failure Modes
What breaks first when enforcing PII redaction policies across multiple turns and how to guard against it.
Context Window PII Leakage
What to watch: PII redacted in the final output still appears in the raw conversation history or tool-call logs that remain in the context window. The model may reference this unredacted PII in later turns, reintroducing it into visible responses. Guardrail: Redact PII at the application layer before it enters the context window. Never rely solely on output-layer redaction. Audit full conversation traces, not just final messages.
Redaction Fatigue Over Long Sessions
What to watch: The assistant correctly redacts PII in early turns but gradually stops applying the policy as the session lengthens. Instruction priority decays when the redaction rule scrolls out of active attention or is diluted by accumulated context. Guardrail: Re-inject the redaction policy instruction every N turns or when the policy is within K tokens of context window truncation. Use a policy re-insertion trigger prompt to automate this.
Partial Redaction of Structured PII
What to watch: The model redacts obvious fields like email addresses and phone numbers but misses PII embedded in free-text narratives, code snippets, JSON payloads, or log excerpts. Structured data fields with non-obvious PII labels are especially vulnerable. Guardrail: Use a dedicated PII detection model or regex-based scanner as a pre-processing step before the prompt. The LLM prompt should act as a secondary enforcement layer, not the primary detector.
Redaction Inconsistency Across Synonyms
What to watch: The model redacts a name in one turn but fails to redact a pronoun, title, or role reference that uniquely identifies the same individual in a later turn. Partial redaction creates a mosaic identification risk where remaining fragments can be recombined. Guardrail: Include explicit instructions to redact not just direct identifiers but also quasi-identifiers and unique combinations of attributes. Test with adversarial examples that use indirect references.
Over-Redaction Breaking Response Utility
What to watch: The model applies redaction too aggressively, stripping necessary context like dates, locations, or category labels that are not actually PII. The resulting response becomes useless for the user's task, triggering frustration and re-prompting that may cause further policy violations. Guardrail: Define a clear PII taxonomy with explicit inclusion and exclusion examples. Include a calibration instruction that balances privacy with task utility. Log over-redaction events for policy tuning.
Audit Trail Gaps in Redaction Decisions
What to watch: The assistant redacts PII but provides no record of what was redacted, why, or under which policy rule. Compliance reviewers cannot verify whether redaction was appropriate or whether PII was missed. Guardrail: Require the prompt to produce a structured redaction audit block alongside the response, listing each redaction with the field type, policy rule invoked, and confidence level. Store this audit trail separately from the user-facing output.
Evaluation Rubric
Use this rubric to test whether the PII Redaction Policy Enforcement Prompt produces compliant, auditable outputs before deploying to production. Each criterion includes a pass standard, failure signal, and test method that can be automated in eval harnesses.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
PII Detection Completeness | All PII instances in [INPUT_TEXT] matching [PII_CATEGORIES] are identified in the detection audit trail | Audit trail misses a PII instance present in the input (false negative) | Golden dataset with known PII instances; compare detection audit trail against ground truth labels |
Redaction Coverage | Every detected PII instance is replaced with its corresponding [REDACTION_PLACEHOLDER] in the output text | Output text contains raw PII value that appears in the detection audit trail | Regex scan of output text for values listed in the detection audit trail's original_value field |
Policy-Compliant Refusal | When [REDACTION_POLICY] requires refusal, output contains refusal message and empty redacted_text field | Output provides redacted text when policy mandates refusal, or refusal when redaction is permitted | Schema check: refusal_triggered is true implies redacted_text is null; test with inputs matching refusal conditions |
Audit Trail Structure Validity | Detection audit trail is valid JSON matching [OUTPUT_SCHEMA] with all required fields populated | Audit trail missing required fields, contains invalid types, or is not parseable JSON | JSON Schema validation against [OUTPUT_SCHEMA]; field presence check for detection_id, category, original_value, action_taken |
Placeholder Consistency | Same PII entity receives identical placeholder across all occurrences within a single turn | Same email or name receives different placeholders in different positions | Extract all placeholder-to-value mappings from audit trail; verify one-to-one mapping per unique original_value |
Non-PII Content Preservation | All text not classified as PII remains unchanged in redacted_text output | Non-PII words, punctuation, or structure are altered or removed during redaction | Diff original input against redacted output with PII spans masked; remaining text must be character-identical |
Multi-Turn State Isolation | Redaction applies only to current [INPUT_TEXT]; no PII from prior turns leaks into current turn output | Current turn output or audit trail references PII from earlier conversation turns | Session-level test: run prompt across multiple turns with different PII; verify each turn's audit trail contains only that turn's PII |
Confidence Threshold Adherence | Entities with detection confidence below [CONFIDENCE_THRESHOLD] are flagged as uncertain and handled per [LOW_CONFIDENCE_ACTION] | Low-confidence entities are either silently redacted without flagging or silently passed through | Check audit trail for confidence_score field; verify entities below threshold have action_taken matching [LOW_CONFIDENCE_ACTION] |
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 detection prompt and a simple JSON schema. Use a single model call that checks the last [USER_MESSAGE] and [ASSISTANT_RESPONSE] pair against your redaction policy. Skip the audit trail initially—just return redacted_output or policy_refusal.
codeSystem: You are a PII redaction enforcer. Policy: [REDACTION_POLICY]. Check this turn for PII violations. Return {"violation": bool, "redacted_output": str|null, "refusal": str|null}. User message: [USER_MESSAGE] Assistant response: [ASSISTANT_RESPONSE]
Watch for
- Missing schema checks—the model may return prose instead of JSON
- Overly broad instructions that flag names in non-PII contexts
- No handling of partial redactions where only some fields need masking

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