The 500 AI Agents Projects is a curated collection of AI agent use cases across various industries. It showcases practical applications and provides links to open-source projects for implementation, illustrating how AI agents are transforming sectors such as healthcare, finance, education, retail, and more.
feat: add PII sanitization agent for autonomous AI pipelines (#115)
teodorofodocrispin-cmyk9beeb721c2af
diff --git a/README.md b/README.mdindex 5447e52..702bcff 100644--- a/README.md+++ b/README.md@@ -116,6 +116,7 @@ Choosing a framework? Here's when to use each:| **MediSuite-AI-Agent** | Health Insurance | Automates hospital / insurance claiming workflow | [](https://github.com/ahmedmansour5/MediSuite-Ai-Agent) || **Lina Egyptian Medical Chatbot** | Healthcare | Egyptian medical assistant chatbot | [](https://github.com/dina-khalid/Lina-Egyptian-Medical-Chatbot) || **NextRole (AI Career Assistant)** | Human Resources | Tailors a resume to a job description and generates interview prep plus a day-of battlecard via a multi-agent system | [](https://github.com/tam159/next-role) |+| **PII Sanitization Agent** | Privacy/Compliance | Redacts PII (emails, phones, national IDs, bank accounts, API keys) from text before it reaches an LLM; fail-closed, multilingual, on-chain proof via TrustBoost | [](https://github.com/teodorofodocrispin-cmyk/TrustBoost-PII-Sanitizer) |---diff --git a/agents/21-pii-sanitization-agent/.env.example b/agents/21-pii-sanitization-agent/.env.examplenew file mode 100644index 0000000..7ae139e--- /dev/null+++ b/agents/21-pii-sanitization-agent/.env.example@@ -0,0 +1,11 @@+# TrustBoost PII Sanitization Agent — environment variables+# Copy this file to .env and fill in real values. Never commit a real key.++# Your agent's wallet/identifier (used in the trial payload). Optional.+TRUSTBOOST_WALLET=your-agent-id-or-wallet++# Solana tx hash after paying for volume (leave as TRIAL for the free tier).+TRUSTBOOST_TX_HASH=TRIAL++# Optional: override the API base (defaults to https://api.trustboost.dev).+TRUSTBOOST_API_BASE=https://api.trustboost.devdiff --git a/agents/21-pii-sanitization-agent/README.md b/agents/21-pii-sanitization-agent/README.mdnew file mode 100644index 0000000..4b8371a--- /dev/null+++ b/agents/21-pii-sanitization-agent/README.md@@ -0,0 +1,83 @@+# PII Sanitization Agent++Removes sensitive data from text **before** it reaches an LLM or external API.+Built for autonomous agent pipelines where human review is not possible.++The agent calls the [TrustBoost](https://api.trustboost.dev) API, which detects+and redacts PII (emails, phones, national IDs, bank accounts, API keys) and+returns a structured, auditable result. This is a thin client: the detection+models, multilingual support, and on-chain proof of sanitization live behind the+API, so no PII-handling code or weights live in this repo.++## Why it matters++PII leaking through autonomous pipelines is a real gap — an agent that forwards+user text to an LLM can accidentally expose emails, phones, tax IDs, or secrets.+This agent is the guardrail: sanitize first, then send.++- Semantic PII detection (well above regex-only accuracy)+- Multilingual: EN, ES-LATAM, PT-BR, DE, JA+- LATAM identifiers: RFC, CPF, CUIT, RUT+- Fail-closed: on any API/transport error it returns `[REDACTED]`, never raw PII+- Audit trail: no raw PII is stored by the agent; optional on-chain proof available++## Quick start++```bash+pip install -r requirements.txt+python agent.py --text "Call me at 555-123-4567, email [email protected], RFC PEMJ880126MNEZSN01"+```++With no API key it uses the **free trial** (50 sanitizations, `tx_hash=TRIAL`).+For higher volume, pay once via x402 and pass the Solana tx hash:++```bash+export TRUSTBOOST_WALLET="<your-agent-wallet>"+python agent.py --text "..." --tx-hash "<solana_tx_hash>"+```++Sanitize a file:++```bash+python agent.py --file input.txt --context legal+```++Context modes: `general | financial | legal | medical | code`.++## Sample output++```json+{+ "status": "success",+ "data": {+ "sanitized_content": "Hi, I'm [REDACTED]. My email is [REDACTED] and my phone is [REDACTED]. RFC: [REDACTED]. Account [REDACTED]. API key [REDACTED].",+ "safety_score": 0.6,+ "risk_category": "PRIVATE",+ "entities": [+ {"type": "email", "category": "PRIVATE"},+ {"type": "phone", "category": "PRIVATE"},+ {"type": "national_id", "category": "PRIVATE"}+ ]+ }+}+```++(Runtime: ~2–5 s per call depending on network. End-to-end demo under 10 min.)++## Ethical considerations++- Raw input is never stored by this agent. Sanitized output may be retained by the+ API provider for 90 days for audit; see the TrustBoost privacy docs.+- Fails closed on API error — it will not emit raw PII if the service is unreachable.+- Human oversight is recommended for high-risk deployments (healthcare, finance, legal).+- The included `sk-abc123fakekeynotreal0000000000` in sample text is a **fake** fixture,+ exactly what the redactor should catch.++## Compliance context++EU AI Act, GDPR, HIPAA, LGPD. Use this agent wherever agent-to-agent or+agent-to-LLM text carries user data.++## License++MIT (repository root). The TrustBoost API is a separate service; see its terms.diff --git a/agents/21-pii-sanitization-agent/agent.py b/agents/21-pii-sanitization-agent/agent.pynew file mode 100644index 0000000..c29b89c--- /dev/null+++ b/agents/21-pii-sanitization-agent/agent.py@@ -0,0 +1,114 @@+"""+PII Sanitization Agent — client for the TrustBoost API.++Removes sensitive data (emails, phones, national IDs, bank accounts,+API keys) from text before it reaches an LLM or external API. Built for+autonomous agent pipelines where human review is not possible.++This is a thin client: the sanitization logic, models, and on-chain+proof live behind the TrustBoost API. The agent demonstrates the+privacy/security pattern — call it on any user text before an LLM call.++Usage:+ python agent.py --text "Call me at 555-123-4567, email [email protected]"+ python agent.py --file input.txt+ python agent.py # runs the built-in demo++Uses the free trial (50 sanitizations) when no API key / tx_hash is set.+"""++import argparse+import os+import sys+import json++try:+ from dotenv import load_dotenv+ load_dotenv()+except Exception:+ pass++import requests++API_BASE = os.environ.get("TRUSTBOOST_API_BASE", "https://api.trustboost.dev")+ENDPOINT = f"{API_BASE}/sanitize"+++def sanitize(text: str, context: str = "general", tx_hash: str = "TRIAL") -> dict:+ """Send text to TrustBoost and return the sanitized result.++ Args:+ text: raw text that may contain PII+ context: general | financial | legal | medical | code+ tx_hash: "TRIAL" for the free tier, or a Solana tx hash after payment+ """+ payload = {+ "text": text,+ "tx_hash": tx_hash,+ "wallet_address": os.environ.get("TRUSTBOOST_WALLET", "demo-agent"),+ "context": context,+ }+ try:+ resp = requests.post(ENDPOINT, json=payload, timeout=30)+ except requests.RequestException as e:+ # Fail closed: do NOT return raw PII on transport error.+ return {+ "status": "error",+ "risk_category": "CRITICAL",+ "sanitized_content": "[REDACTED — sanitization service unreachable]",+ "error": str(e),+ }++ if resp.status_code == 200:+ return resp.json()++ if resp.status_code == 402:+ # Payment required — the service is live but needs a paid tx_hash.+ return {+ "status": "payment_required",+ "risk_category": "CRITICAL",+ "sanitized_content": "[REDACTED — payment required to sanitize]",+ "detail": resp.json().get("error", "Payment required"),+ }++ # Any other failure: fail closed.+ return {+ "status": "error",+ "risk_category": "CRITICAL",+ "sanitized_content": "[REDACTED — unexpected response]",+ "http_status": resp.status_code,+ }+++DEMO_TEXT = (+ "Hi, I'm Juan Pérez. My email is [email protected] and my phone is "+ "+1-555-123-4567. RFC: PEMJ880126MNEZSN01. Account 0123456789. "+ "API key sk-abc123fakekeynotreal0000000000."+)+++def main():+ ap = argparse.ArgumentParser(description="PII Sanitization Agent (TrustBoost client)")+ ap.add_argument("--text", help="text to sanitize")+ ap.add_argument("--file", help="path to a text file to sanitize")+ ap.add_argument("--context", default="general", help="general|financial|legal|medical|code")+ ap.add_argument("--tx-hash", default="TRIAL", help="TRIAL for free tier, or Solana tx hash")+ args = ap.parse_args()++ if args.file:+ with open(args.file, "r", encoding="utf-8") as f:+ text = f.read()+ elif args.text:+ text = args.text+ else:+ text = DEMO_TEXT+ print("No --text/--file provided. Running built-in demo.\n")++ print("INPUT :", text[:120] + ("..." if len(text) > 120 else ""))+ result = sanitize(text, context=args.context, tx_hash=args.tx_hash)+ print("\nRESULT :")+ print(json.dumps(result, indent=2, ensure_ascii=False)[:800])+++if __name__ == "__main__":+ main()diff --git a/agents/21-pii-sanitization-agent/metadata.yaml b/agents/21-pii-sanitization-agent/metadata.yamlnew file mode 100644index 0000000..ac0f159--- /dev/null+++ b/agents/21-pii-sanitization-agent/metadata.yaml@@ -0,0 +1,11 @@+title: pii-sanitization-agent+description: Sanitizes PII from text before it reaches LLMs or external APIs, using the TrustBoost API — fail-closed, multilingual, on-chain proof+author: teodorofodocrispin-cmyk+language: python+framework: other+tags: [privacy, pii, sanitization, compliance, security, safety]+industry: general+difficulty: beginner+llm: none+entrypoint: agent.py+requirements: requirements.txtdiff --git a/agents/21-pii-sanitization-agent/requirements.txt b/agents/21-pii-sanitization-agent/requirements.txtnew file mode 100644index 0000000..2b1be2a--- /dev/null+++ b/agents/21-pii-sanitization-agent/requirements.txt@@ -0,0 +1,2 @@+requests>=2.31.0+python-dotenv>=1.0.0