Why a uniform PII policy fails
A single policy applied to every caller cannot distinguish between user roles, applications, and agents. This guide instead treats PII handling as a runtime policy-resolution problem, in which the proxy decides which policy applies to each request before any action is taken.
Resolve caller identity before anything else
Policy selection is only as reliable as the identity feeding it. Resolve context from signals the proxy can verify, not from fields the client can set freely.
Authenticated credential
An API key, service credential, or signed token bound to an application. This is the strongest signal for per-application policy.
Token claims
Role, group, or department claims from a validated JWT. Verify signature and expiry at the proxy before reading any claim.
Agent identity
For autonomous agents, a distinct identity per agent rather than the identity of the user who launched it.
Request attributes
Environment, data classification of the route, or declared purpose. Use these as additional attributes for attribute-based access control, not as the sole basis.
Resolved context object
Normalize all inputs into one context record that the policy engine evaluates and the audit log stores.
Structure the policy model
Each policy applies an action per entity type and per traffic scope. The scopes are prompt, response, and tool-call payload. The available actions are allow, mask, tokenize, block, or log-only.
Set precedence and fail-safe defaults
The proxy matches the resolved context to one policy using explicit precedence and a safe default. Conflicting matches and missing identity are negative paths that should be tested explicitly (see the testing section below).
Account for detection limits in policy design
Detector failure is one of the negative paths a policy design must handle. Verify the behavior of each policy when detection fails, and confirm that the resulting action is the one you intend.
Policy resolution path in one proxy
The four stages below summarize how a single request moves through the proxy.
- Step 1Resolve identityDerive user role, application, or agent from verified credentials.
- Step 2Select policyMatch context to one policy using explicit precedence and a safe default.
- Step 3Enforce actionsAllow, mask, tokenize, block, or log-only per entity type and scope.
- Step 4Record evidenceLog the decision and policy version, not the raw data.
Test policies and produce audit evidence
- Build synthetic test cases for each role, application, and agent, using fabricated PII, and assert both the selected policy and the resulting action.
- Test negative paths: missing identity, expired token, conflicting matches, and detector failure.
- Run new or changed policies in log-only mode first and compare outcomes against the current policy before enforcing.
- Record in each audit entry the request ID, resolved context, policy ID and version, scope, entity types detected, counts, and action taken.
- Store hashed or tokenized references instead of raw values, and restrict access to the audit store.
- Review the audit design with your privacy and compliance teams against the GDPR, HIPAA, or NIST AI RMF obligations that apply to you.