Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

Stop Leaking PII to LLM APIs: Build a Reversible Redaction Layer for Your AI Agents

A practical design for stopping PII from reaching hosted LLM APIs: transform data locally, protect the mapping, restore only after the reply is checked, and cover tools, logs, and traces too.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put the privacy boundary in your own code, before any HTTP request reaches a hosted model. Detect sensitive values locally, replace them with typed placeholders, keep the original-value mapping in a protected store scoped to one request, and send only the transformed text. When the model replies, check the reply, then restore only the placeholders that belong to that request.

This reduces exposure. It does not guarantee that every identifier will be detected, and it does not change what a model provider retains. The sections below cover the design, the trade-offs between removal and reversible replacement, and the paths beyond the first prompt that most implementations leave open.

As an Amazon Associate I earn from qualifying purchases.

Where the privacy boundary belongs

The boundary sits between the code that holds user, customer, or business data and the client that calls the model. Anything that crosses it leaves your trust domain, so transformation has to happen before serialization, not inside the provider’s pipeline and not as a cleanup step afterward.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the inventory of every path that can carry content to a model. Most teams start with the main chat call and miss the rest:

#1 Best Overall
Sale
SightPro Magnetic Laptop Privacy Screen 14 Inch 16:10 - Patented Removable Laptop Privacy Filter Shield and Protector
  • 【Instant Snap-on Magnetic Attachment】- The Patented Magnetic Privacy Screen – Protected by U.S. Patents 9,829,669 and D844,012. Simply place the privacy screen along the top of your MacBook and let the magnets attach along the top. No need for tricky placement, messy tape, or damaging adhesive. Easily remove and reattach when you need it.
  • 【Filter Dimensions】: Width: 11 15/16" (304 mm), Height: 7 1/2" (190 mm), Diagonal: 14.1" (358.14 mm) - SightPro Blackout Privacy Filter is engineered to be compatible with Lenovo, HP, Dell, Acer, Asus, Samsung, and other laptop brands. Please verify your screen's width and height measurements before ordering. It's not recommended to make your selection based solely on your screen's diagonal size. [Not optimized for touchscreens.]
  • 【Superior Privacy】- Our advanced multi-layered film filter blacks out your screen when viewing from the side, while maintaining a crystal clear screen straight-on. It also protects your eyes from harmful UV and blue light. [Note: It does not block visibility directly behind you, regardless of the distance.]
  • 【Perfect for Travel and Open Workspaces】- The Laptop Privacy Screen Filter is the ideal solution for healthcare providers, mobile workers, commuters, students, and business travelers. Now you can stay compliant and safeguard sensitive corporate information while working in airplanes, subways, airports, and public areas.
  • 【Package Contents】- Each package includes a magnetic privacy screen filter, magnetic stickers, a webcam privacy cover, a storage folder, and a cleaning cloth. Buy with confidence – located in the US, Sight Pro specializes in providing best-in-class privacy solutions to individuals, small businesses, corporations, government, and educational institutions. Our privacy screens are Section 889 and TAA compliant.
  • The first prompt and any system prompt built from user data.
  • Retries and regeneration calls, which resend the original payload unless the retry reuses the transformed one.
  • Background jobs such as summarization, classification, or nightly report generation.
  • Embedding requests for search or retrieval.
  • Follow-up model calls triggered by tool results, where the tool output itself contains personal data.
  • Evaluation and prompt-testing harnesses that replay production data.

Each path needs the same transformation. The practical way to enforce that is to route every model call through one shared client or agent runtime that applies the boundary, so a developer cannot make a direct call by accident.

Choose a transformation for each kind of value

Four approaches cover most designs. They differ in whether the original can be recovered, what secret has to be protected, and how much meaning the model keeps. Presidio, the open-source PII detection and anonymization framework, offers separate operators for replace, redact, hash, mask, and encrypt, and its deanonymizer reverses only the operations that are reversible, such as encryption. The table compares the approaches as a design choice rather than a product ranking.

Approach Restoration possible What must be protected Repeated values Context the model keeps Operational overhead
Irreversible removal (redact) No Nothing for restoration, but the original must stay out of logs, retries, and traces Not applicable; every occurrence is removed Lowest; the model knows only that something was removed Low
Stable typed placeholder, such as [PERSON_1] Yes, from a request-scoped mapping The placeholder-to-original mapping Yes, within that scope Entity type and relationships, such as which person is the sender Medium: mapping store, restore step, tests
Salted hash Generally no; hashing is one-way The salt. If it leaks, someone can test guesses against short values such as phone numbers Yes, if the same salt is used Equality only; the model sees opaque strings with no meaning Low to medium: salt lifecycle; the same hash can link records across systems
Encryption or token vault Yes, with the key or vault The key and the vault; compromise exposes every stored value Only with deterministic encryption; randomized ciphertext differs on each call Little when ciphertext is sent to the model, because the model cannot reason about it High: key management, decrypt path, access control

For prompts, a typed placeholder usually gives the best balance. Encryption is the better tool for storage: keep the ciphertext or the vault at rest and send the model a placeholder. Hashing fits equality checks and deduplication, such as confirming two records refer to the same customer, not restoration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Every approach inherits the same detection risk. If the recognizer misses a value, removal, placeholders, hashing, and encryption all leave it in the clear. The choice affects what happens to the values you do catch.

Rank #2
15.6 Inch Privacy Screen Filter for 16:9 Monitor 1920 x 1080 Resolution
  • Compatible Models: Width: 13 9/16" (13.5 inch/344 mm), Height: 7 5/8" (7.6 inch/194 mm), Diagonal: 15.6" (396.24 mm) widescreen laptops which have a 16:9 aspect ratio. Not touchscreen compatible !!! Not fit for 16:10.Do NOT rely solely on your laptop’s diagonal size when ordering. Use a ruler to measure your screen’s visible area (excluding the black bezels). If the width reads 344mm and height reads 194mm, this filter is a perfect match for your device.
  • Keep Information Privacy: Effective "black out" privacy from side views outside the 60-degree viewing angle. Designed for optical clarity when viewing from the front, a person not at the front of the screen can only see the dark side of the screen, so it protects buisness secrets and personal privacy
  • Eye and Screen Protection: Privacy filter does not only protect your private life but also protects your eyes by blocking 30% of blue light , blocking the harmful blue light between 380 - 495nm, it filters out the blue light and relieves eye strain. Our laptop privacy screen also helps keep your screen safe from dust and scratches
  • Perfect For Open Workspaces: Great for maintaining screen privacy in high traffic areas such as open work spaces, airports, airplanes, commuter trains, coffee shops and other public places, etc
  • Easy Installation: Choose between 2 simple Options; Slide-On/Off or Mounted. Not touchscreen compatible

Build the layer

Step 1: Write an entity policy

List the values the agent may encounter and assign each one a rule. Typical entries include names, email addresses, phone numbers, account identifiers, API keys and other secrets, internal project names, and free-text spans such as a medical note or a dispute description. For each entry, decide one of three things:

  • Remove: the task does not need the value at all. Secrets almost always belong here.
  • Replace with a placeholder: the task needs to distinguish entities, such as which of two people sent a message, and the caller must restore the value later.
  • Hash or encrypt: the value is needed for matching or storage but should not appear in model-visible text.

Write the policy as configuration that the code reads, not as comments. Reviewers can then check it, and changes are tracked.

Step 2: Detect locally

Run detection in your own process before anything is serialized. Presidio’s analyzer combines several methods: regular-expression patterns, deny lists, checksum validation for formats such as card numbers, rule logic, named-entity recognition for names and locations, and context words near a match that raise or lower confidence. Those methods are useful, but none of them is complete.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add recognizers for your own identifiers, such as internal ticket formats, customer number schemes, or project code names. Test the language and formats your application actually handles. A recognizer tuned to English email addresses will not catch the same information written in a different script or inside a table export.

Rank #3
SightPro 14 Inch 16:10 Laptop Privacy Screen Filter - Computer Monitor Privacy Shield and Anti-Glare Protector
  • Filter Dimensions: Width: 11 15/16" (304 mm), Height: 7 1/2" (190 mm), Diagonal: 14.1" (358.14 mm) - SightPro Blackout Privacy Filter is engineered to be compatible with Lenovo, HP, Dell, Acer, Asus, Samsung, and other laptop brands. Please verify your screen's width and height measurements before ordering. It's not recommended to make your selection based solely on your screen's diagonal size. [Not optimized for touchscreens.]
  • Two Attachment Options - Installs in minutes. Option 1 uses clear adhesive strips that securely attach to any screen. Option 2 uses slide mount tabs that easily stick to the display frame, allowing you to slide the filter on and off the screen as needed.
  • Superior Privacy and Anti Glare - Our advanced multi-layered film filter blacks out your screen when viewing from the side, while maintaining a crystal clear screen straight-on. It also protects your eyes from harmful glare, UV, and blue light. [Note: It does not block visibility directly behind you, regardless of the distance.]
  • Perfect for Travel and Open Workspaces - Our computer screen privacy filter is the ideal solution for healthcare providers, mobile workers, commuters, students, and business travelers. Now you can stay compliant and safeguard sensitive corporate information while working in airplanes, subways, airports and public areas.
  • Package Contents - Each package includes one privacy screen shield filter, two sets of clear adhesive strips, two sets of slide mount tabs, and a microfiber cleaning cloth. Buy with confidence – located in the US, Sight Pro specializes in providing best-in-class privacy solutions to individuals, small businesses, corporations, government, and educational institutions. Our privacy screens are Section 889 and TAA compliant.

Step 3: Transform with request-scoped placeholders

The sketch below shows the core pattern with a single email recognizer. It is an illustration of the mapping logic, not a production implementation. It omits real detection, encryption at rest, expiry, and error reporting.

import re
from dataclasses import dataclass, field

EMAIL = re.compile(r"[w.+-]+@[w-]+(?:.[w-]+)+")
TOKEN = re.compile(r"[[A-Z]+_d+]")

@dataclass
class Scope:
    mapping: dict = field(default_factory=dict)   # token to original value
    index: dict = field(default_factory=dict)     # (kind, value) to token
    counts: dict = field(default_factory=dict)

    def token_for(self, kind, value):
        key = (kind, value)
        if key not in self.index:
            n = self.counts.get(kind, 0) + 1
            self.counts[kind] = n
            token = f"[{kind}_{n}]"
            self.index[key] = token
            self.mapping[token] = value
        return self.index[key]

def redact(text, scope):
    if TOKEN.search(text):
        raise ValueError("input contains placeholder-shaped text")
    return EMAIL.sub(lambda m: scope.token_for("EMAIL", m.group(0)), text)

def restore(reply, scope):
    unknown = []
    def swap(m):
        tok = m.group(0)
        if tok in scope.mapping:
            return scope.mapping[tok]
        unknown.append(tok)
        return tok
    out = TOKEN.sub(swap, reply)
    if unknown:
        raise ValueError(f"unknown placeholders: {sorted(set(unknown))}")
    return out

The scope is created per request and discarded when the workflow ends. The placeholder is typed and numbered within that scope, so the same address appears as the same token throughout one request, and a different request starts over at [EMAIL_1]. That keeps one request’s tokens from being linkable to another’s.

Step 4: Protect the mapping

The mapping is the secret that makes restoration possible. A leaked mapping undoes the benefit of pseudonymization, because the placeholders become reversible by anyone who holds it. Treat it as sensitive data in its own right:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Keep it outside prompts, outside any tool schema the model can see, and out of the model’s context window.
  • Scope it to a request, user, tenant, or bounded workflow, and expire it when the workflow ends.
  • Encrypt it at rest and restrict who and what can read it.
  • Keep it out of debug logs, analytics events, traces, and exception messages. Log the placeholder text instead of the value.

Keep the mapping as narrow as the task allows. Reusing one mapping across unrelated tasks lets a placeholder from one task carry meaning into another.

Rank #4
SightPro Magnetic Laptop Privacy Screen 14 Inch 16:9 - Patented Removable Laptop Privacy Filter Shield and Protector
  • 【Instant Snap-on Magnetic Attachment】- The Patented Magnetic Privacy Screen – Protected by U.S. Patents 9,829,669 and D844,012. Simply place the privacy screen along the top of your MacBook and let the magnets attach along the top. No need for tricky placement, messy tape, or damaging adhesive. Easily remove and reattach when you need it.
  • 【Filter Dimensions】: Width: 12 3/16" (310 mm), Height: 6 7/8" (175 mm), Diagonal: 14" (355.6 mm) - There are two different 14 inch screen sizes, please select the correct one. SightPro Blackout Privacy Filter is engineered to be compatible with Lenovo, HP, Dell, Acer, Asus, Samsung, and other laptop brands. Please verify your screen's width and height measurements before ordering. It's not recommended to make your selection based solely on your screen's diagonal size. [Not optimized for touchscreens.]
  • 【Superior Privacy】- Our advanced multi-layered film filter blacks out your screen when viewing from the side, while maintaining a crystal clear screen straight-on. It also protects your eyes from harmful UV and blue light. [Note: It does not block visibility directly behind you, regardless of the distance.]
  • 【Perfect for Travel and Open Workspaces】- The Laptop Privacy Screen Filter is the ideal solution for healthcare providers, mobile workers, commuters, students, and business travelers. Now you can stay compliant and safeguard sensitive corporate information while working in airplanes, subways, airports, and public areas.
  • 【Package Contents】- Each package includes a magnetic privacy screen filter, magnetic stickers, a webcam privacy cover, a storage folder, and a cleaning cloth. Buy with confidence – located in the US, Sight Pro specializes in providing best-in-class privacy solutions to individuals, small businesses, corporations, government, and educational institutions. Our privacy screens are Section 889 and TAA compliant.

Step 5: Route every model call through one client

Make the boundary part of the shared client, not a function that callers must remember. A practical pattern is a wrapper that accepts only transformed payloads and refuses requests that still contain values matching the policy. The wrapper is also the right place to add the inventory from the first section: retries, background jobs, and tool-triggered calls all pass through the same path.

Restore names only after the reply is checked

Model output is untrusted text. It can drop a placeholder, alter its format, or invent one. Restoration is the last step, and it should run in this order:

  1. Parse the reply and find every placeholder-shaped token.
  2. Check each token against the mapping for the current request. Tokens from another request, or tokens the mapping does not contain, are not restored.
  3. Replace only exact matches, using a pattern-based substitution as shown above. Do not run a blind string replacement across the whole reply, because that can restore a value into a field, URL, or log line where it should never appear.
  4. Apply output policy: check the restored text against the same entity rules, since the model may have produced new sensitive content.
  5. Write logs using placeholder text, not restored values.

Failures need explicit handling. The table lists the cases that most often appear in practice.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Symptom Likely cause Handling
A token is missing from the reply The model dropped it or paraphrased around it Do not guess the value. Return the reply with the gap marked, or retry with the same placeholder context
An unknown token such as [EMAIL_9] appears The model invented it, or copied a token from another request Fail closed. Do not restore it, and record the event without any original value
A token is malformed, such as [EMAIL_1 with the bracket missing The model altered the format Treat it as unrestored and send the reply through review before display
Input already contains token-shaped text, such as a literal [PERSON_1] Collision between user text and placeholder syntax Reject the input or escape it before transformation, so restoration cannot touch user text
One person appears under two different placeholders The detector missed an alias, such as a nickname Accept as a known limit for that entity class, and add alias handling to the policy if the case recurs
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Extend the boundary beyond the prompt

Protecting only the first model prompt leaves other paths open. Apply the same controls to each of these:

Best Value
Sale
SightPro 15.6 Inch 16:9 Laptop Privacy Screen Filter - Computer Monitor Privacy Shield and Anti-Glare Protector
  • 【Filter Dimensions】: Width: 13 9/16" (345 mm), Height: 7 5/8" (194 mm), Diagonal: 15.6" (396.24 mm) - SightPro Blackout Privacy Filter is engineered to be compatible with Lenovo, HP, Dell, Acer, Asus, Samsung, and other laptop brands. Please verify your screen's width and height measurements before ordering. It's not recommended to make your selection based solely on your screen's diagonal size. [Not optimized for touchscreens.]
  • 【Two Attachment Options】- Installs in minutes. Option 1 uses clear adhesive strips that securely attach to any screen. Option 2 uses slide mount tabs that easily stick to the display frame, allowing you to slide the filter on and off the screen as needed.
  • 【Superior Privacy and Reduce Glare】- Our advanced multi-layered film filter blacks out your screen when viewing from the side, while maintaining a crystal clear screen straight-on. It also protects your eyes from harmful glare, UV, and blue light. [Note: It does not block visibility directly behind you, regardless of the distance.]
  • 【Perfect for Travel and Open Workspaces】- Our computer screen privacy filter is the ideal solution for healthcare providers, mobile workers, commuters, students, and business travelers. Now you can stay compliant and safeguard sensitive corporate information while working in airplanes, subways, airports and public areas.
  • 【Package Contents】- Each package includes one privacy screen shield filter, two sets of clear adhesive strips, two sets of slide mount tabs, and a microfiber cleaning cloth. Buy with confidence – located in the US, Sight Pro specializes in providing best-in-class privacy solutions to individuals, small businesses, corporations, government, and educational institutions. Our privacy screens are Section 889 and TAA compliant.
  • Tool arguments and results. If an agent calls a database or CRM tool, decide which fields the tool needs in clear text and transform the rest before the result goes back to the model.
  • Remote MCP servers and third-party services. OpenAI’s documentation states that data sent to remote MCP servers is subject to those services’ retention policies. Your redaction layer should run before a value is passed to any remote tool, because your provider settings do not extend to that service.
  • Uploaded files. Text extracted from documents, along with filenames, metadata, and document properties, is a separate input path and needs the same detection.
  • Application logs, traces, and error reports. Exception messages often echo the prompt. Scrub before the error reaches a monitoring service, and keep trace attributes to placeholder text.
  • Analytics and feedback events. A thumbs-down event with the prompt attached is a copy of the data you were trying to minimize.

Provider retention is a separate control

Provider settings and application-side minimization answer different questions. Provider settings describe what the vendor keeps and for how long. Minimization describes what you send in the first place. Both matter, and neither replaces the other.

OpenAI’s current API data-controls documentation describes the following. Terms, endpoint lists, and eligibility change over time, so check the live page and your organization’s project settings before relying on any single row.

Control What OpenAI’s documentation states What it does not settle
Training use API data is not used to train or improve models unless the customer opts in Whether logs are kept, and for how long
Abuse-monitoring logs Logs may include prompts, responses, and derived metadata; by default they are retained for up to 30 days, subject to stated exceptions Which exceptions apply to your account and feature
Modified Abuse Monitoring Eligible customers may request it; approval is required Endpoint and feature limitations; the documentation’s current list governs
Zero Data Retention Eligible customers may request it; approval is required Endpoint and feature limitations, and some features may retain application state even when it is enabled
Application state Some features may retain application state even when Zero Data Retention is enabled Which features apply; check each feature you use
Remote MCP servers Data sent to remote MCP servers is subject to those services’ retention policies Anything about the service’s policy, which you must read separately

Two operational points follow. First, do not assume a feature inherits an account-level setting. Confirm it per endpoint and per feature, and record the answer. Second, a control that limits retention on the provider side does not make the transmission of unnecessary personal data acceptable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What this does not guarantee

OWASP’s 2025 guidance for LLM applications lists sensitive information disclosure as a risk category and names anonymization and output filtering among the mitigations. Those are real reductions in exposure, and they have limits that you should state to your own stakeholders:

  • Detection is probabilistic. A recognizer can miss a value in an unexpected format, a misspelling, a transliteration, or a split across lines.
  • Context can identify people without naming them. A sentence such as “the only nurse on the third floor on Tuesday nights” can identify someone with no name or email in it.
  • Images and scanned documents bypass text recognizers. A text pass sees nothing in an image unless you extract the text first.
  • Pipeline changes can reintroduce paths. A new tool, a new log sink, or a new feature flag can route data around the boundary.
  • Compliance is not a side effect of installing a library. Enabling a provider setting or adding a recognizer does not establish that a system meets a legal or contractual requirement.

The practical response is to test against your own data, not against sample text, and to decide in advance what happens when detection is uncertain. For high-risk workflows, send the case to human review or refuse the model call rather than sending the unredacted content.

Testing and maintenance

  • Build a test corpus from representative documents, including the formats your users actually send: exports, forwarded threads, pasted tables, and multilingual text.
  • Add adversarial cases: split identifiers, unusual separators, Unicode lookalikes, and user text that contains placeholder-shaped strings.
  • Track false negatives, meaning values that reached the provider, and false positives, meaning values that were transformed without need. Review both on a schedule.
  • Review newly observed data shapes whenever a new integration, document type, or form field is added.
  • Re-check provider endpoint settings and project controls whenever you add a feature, since eligibility and exceptions differ by endpoint.
  • Test restoration failure paths as deliberately as the success path, including unknown tokens, malformed tokens, and replies from a different request.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.