← Back to directory
Legal & Compliance Medium to set up AI workflow Triage & Route

Privacy-Minded Router for PII Detection

Source reviewed Updated 2026-07-07

Detects sensitive PII in chat inputs using risk scoring and routes them through secure local sanitization or cloud LLMs with full audit...

developers and engineersops and IT teams

What it does

You keep your sensitive personal information safe by having this agent automatically detect PII in your chat inputs and route them through secure local sanitization or compliant cloud models. It ensures full audit trails so you can meet GDPR and HIPAA standards without sacrificing performance on clean data.

Step by step

  1. Implement regex patterns for standard PII types like email addresses and phone numbers to create an initial filter layer.
  2. Define a risk scoring algorithm that assigns numerical weights to detected entities based on their sensitivity level.
  3. Configure the routing logic to direct low-risk requests to OpenRouter and high-risk requests to local Ollama instances.

Where the LLM does the work

  • Prompt engineering is required to ensure the LLM accurately identifies context-specific PII that regex might miss.
  • The system needs dynamic threshold tuning for risk scores based on specific regulatory requirements like GDPR or HIPAA.
  • Generate sanitized response templates that maintain user intent while removing sensitive data fields effectively.

Watch out for

Regex patterns can produce false positives on benign text so you must implement a secondary LLM verification step to reduce noise.
Local Ollama models may lack the nuance of cloud models for complex PII detection so benchmark them against your specific data set first.
Audit logs might inadvertently store raw PII if not carefully scrubbed before persistence so add a sanitization filter to the logging pipeline.
Latency spikes can occur when switching between local and cloud endpoints so implement circuit breakers to prevent cascading failures.

Tools that fit

Code Service Logic and pattern detection
AI Agent LLM Context-aware classification
Ollama Chat Model LLM Local LLM processing
Simple Memory Service State management
OpenRouter Chat Model LLM Cloud LLM routing

The agent brief

Everything your agent needs, including the gotchas. Copy it and go.
agent-brief.md
You are helping me build the following AI agent workflow.

## Goal
Privacy-Minded Router for PII Detection: Detects sensitive PII in chat inputs using risk scoring and routes them through secure local sanitization or cloud LLMs with full audit...

## Specification
- What it does: You keep your sensitive personal information safe by having this agent automatically detect PII in your chat inputs and route them through secure local sanitization or compliant cloud models. It ensures full audit trails so you can meet GDPR and HIPAA standards without sacrificing performance on clean data.
- Trigger: Triggered by an event (Manual · on demand)
- Autonomy: Fully hands-off
- Expected setup effort: about an afternoon
- Tools/services involved:
  - Code: Logic and pattern detection
  - AI Agent: Context-aware classification
  - Ollama Chat Model: Local LLM processing
  - Simple Memory: State management
  - OpenRouter Chat Model: Cloud LLM routing

## Known pitfalls, handle each one explicitly in your implementation
1. Regex patterns can produce false positives on benign text so you must implement a secondary LLM verification step to reduce noise.
2. Local Ollama models may lack the nuance of cloud models for complex PII detection so benchmark them against your specific data set first.
3. Audit logs might inadvertently store raw PII if not carefully scrubbed before persistence so add a sanitization filter to the logging pipeline.
4. Latency spikes can occur when switching between local and cloud endpoints so implement circuit breakers to prevent cascading failures.

## Reference implementation
https://n8n.io/workflows/5874 (workflow template)
Fetch and inspect this before building. If it matches my stack, adapt it;
if not, rebuild the pattern with my tools.

## Process requirements
1. Before building: ask me which of the listed tools I actually use and
   what my platform is (n8n / Make / code / other). Do not assume.
2. Adapt the pattern to my answers; do not force the reference stack.
3. Address every pitfall above; tell me how you handled each.
4. Provide a test plan I can run before letting this touch real data.
5. Ask before any step that sends messages, modifies data, or spends money.

Source: https://usecasesforagents.com/use-case/ai-privacy-minded-router-for-pii-detection/ via usecasesforagents.com

Frequently asked questions

Can I use a different LLM than Ollama?

Yes. Ollama is only the example LLM in this recipe. The same flow works with Anthropic, Cohere, DeepSeek and Google Gemini. Swap the LLM connection and keep the rest of the setup as written.

Want this running in your business?

This is what I do. I design and build AI agents like this one, and keep them running. If you want it set up for your team instead of doing it yourself, get in touch.
Get in touch →

Who it's for

Built for developers who want the busywork around code automated, not the code itself.

Ops-IT teams triaging their own internal requests get the same pattern, different queue.

Seen in the wild

← Back to directory