Where to intercept: the function-calling lifecycle
Controls apply at the point where a call is formed and executed. Four control points in the lifecycle each play a different role in keeping PII out of tool-call arguments.
| Control point | Role |
|---|---|
| Schema | Typed, bounded parameters limit what the model can place in a call. |
| Pre-execution inspection | Arguments are checked, then allowed, redacted, tokenized, or blocked. |
| Tool-side validation | The receiving service rejects data it should never accept. |
| Logging and audit | Traces keep evidence of decisions without retaining raw PII. |
How PII ends up in tool-call arguments
PII can reach a tool call from several places, including user prompts, retrieved documents, and prior tool outputs. Free-text fields make it easiest for that data to be placed in an argument, which is why constraining schemas so free-text fields are rare is the first control.
Leakage is not limited to top-level strings. Nested fields, arrays, and encoded values can also carry PII, so inspection and testing need to cover them.
Implementing the layered controls
1. Constrain schemas
Use typed, bounded parameters so free-text fields are rare. This limits what the model can place in a call before any other control runs.
2. Inspect arguments before execution
Check arguments before the tool runs, then allow, redact, tokenize, or block them according to policy.
3. Scope each tool to least privilege
Give each tool only the access it needs. The receiving service should also validate input and reject data it should never accept.
4. Keep raw arguments out of logs and traces
Retain evidence of decisions without retaining raw PII, so logs and traces do not become a second place where data leaks.
Tradeoffs and limitations to plan for
Inspection can produce false positives and missed detections, and results will differ from tool to tool. Record both per tool and revisit policies when they change.
Test beyond top-level strings: nested fields, arrays, and encoded values should be part of every test pass, and logs, traces, and caches should be inspected afterward to confirm raw values were not retained.
Where a runtime enforcement layer fits
Enforce the controls in a runtime layer the model cannot bypass, placed around the point where a call is formed and executed. This is where arguments are inspected, where the allow, redact, tokenize, or block decision is applied, and where decision records are produced.
Test and audit the controls
Use this checklist to confirm the controls work as intended.
- Inventory every tool, including MCP servers, and record which cross a trust boundary.
- Seed test prompts, retrieved documents, and prior tool outputs with synthetic PII, then confirm what reaches each tool's arguments.
- Test nested fields, arrays, and encoded values, not only top-level strings.
- Record false-positive and missed-detection results per tool and revisit policies when they change.
- Inspect logs, traces, and caches after each test run to confirm raw values were not retained.
- Retain decision records showing what was inspected, the action taken, and the policy version applied.