Implementation Guide

Detecting Protected Class Proxies in LLM Prompts at Runtime

To detect protected class proxies in LLM prompts, inspect the final assembled prompt, including user input, retrieved context, and tool results, before the model call. Combine dictionary matching, entity recognition, and optionally a classifier, evaluate hits against use-case policy, apply a block, redact, flag, or escalate action, and write an audit record for every decision. Runtime detection complements fairness testing and legal review. It does not replace either.

What a protected class proxy looks like in a prompt

A protected class proxy is a term, phrase, or feature in a prompt that can stand in for a protected characteristic, even when that characteristic is never named. Proxies can enter a prompt from several sources: the user's own input, context retrieved from other systems, and results returned by tools.

Because the model responds to the whole assembled prompt, that assembled prompt is the right unit to inspect. Checking only the user's message would miss proxies that arrive through retrieved context or tool results.

Where to intercept

Intercept at the point where the prompt is fully assembled and before it is sent to the model. At that point the prompt contains everything the model will see, so a single inspection step covers all three input sources:

  • User input: text entered directly by the user.
  • Retrieved context: content pulled into the prompt from other sources.
  • Tool results: output returned to the prompt by tools and agent workflows.

A detection pipeline from interception to audit

Inline proxy detection follows four stages. Each stage runs for every prompt, so that every decision has a record.

  1. Intercept

    Capture the assembled prompt, retrieved context, and tool results before the model call.

  2. Detect

    Run pattern, entity, statistical, or classifier checks for proxy features.

  3. Enforce

    Apply block, redact, flag, or escalate based on use-case policy.

  4. Record

    Log each decision with enough context to support review.

Enforcement actions

Detection hits are evaluated against the policy for the specific use case, and the result determines one of four actions:

  • Block: stop the prompt from reaching the model.
  • Redact: remove the flagged content before the model call.
  • Flag: allow the prompt and mark it for review.
  • Escalate: route the decision for further review.

Audit logging

Write an audit record for every decision, not only for blocked prompts. Each record should carry enough context to support later review of what was detected, which policy applied, and which action was taken.

Runtime detection compared with design-time bias testing

Runtime detection and design-time bias testing address different points in the lifecycle. Runtime detection acts on the prompts that actually reach the model. Fairness testing and legal review remain necessary, and runtime detection does not replace either.

Runtime detection and design-time review
AspectRuntime detectionDesign-time bias testing and legal review
When it appliesInline, before each model callAt design time
What it inspectsThe final assembled prompt, including retrieved context and tool resultsComplements runtime detection; not replaced by it
What it producesAn enforcement action and an audit record for every decisionFindings that inform design and policy

Detection techniques and their tradeoffs

The recommended approach combines several techniques rather than relying on one. Pattern, entity, statistical, and classifier checks can all be used to look for proxy features, and a classifier is optional.

Detection techniques in the pipeline
TechniqueRole in the pipelineConsideration
Dictionary matchingChecks prompt text for known proxy terms and patternsPart of the core combination
Entity recognitionIdentifies entities in the assembled prompt that may act as proxiesPart of the core combination
Statistical checksLooks for proxy features using statistical signalsChoose according to use-case policy
ClassifierAdds a model-based check for proxy featuresOptional

Whichever techniques are combined, their hits are not decisions on their own. They are evaluated against use-case policy, and the policy determines whether the prompt is blocked, redacted, flagged, or escalated.

Limits, governance, and evaluation

Runtime detection is one control among several. It does not replace fairness testing or legal review, and it should be governed alongside them.

  • Scope: detection covers what is in the assembled prompt at the interception point, so every path that adds content to a prompt needs to pass through it.
  • Policy: actions depend on use-case policy, so the same hit may lead to different outcomes in different use cases.
  • Evidence: audit records for every decision give reviewers the context they need to evaluate how detection and enforcement are performing.

Review your runtime enforcement points

Talk through where proxies can enter your prompts and agent workflows, and how policy enforcement and audit logging could apply.

Talk to an Expert