{"slug": "my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it", "title": "My Clinical AI Agent’s Debug Logs Were a PHI Database. Here’s How I (Mostly) Fixed It.", "summary": "A developer who added observability to a local clinical AI agent found that debug logs contained patients' full names, dates of birth, and phone numbers in plain text. After wiring in Microsoft's Presidio PII detection library and testing on 752 PHI entities across 40 synthetic notes, the masking pipeline never failed but detection failed 135 times, later reduced to 17. The developer warns that redacting a note does not redact the trace, as patient names reappear in extractions, tool calls, and reasoning steps.", "body_md": "Member-only story\n\n# My Clinical AI Agent’s Debug Logs Were a PHI Database. Here’s How I (Mostly) Fixed It.\n\n## Every trace restates the patient’s note — in extractions, tool calls, and reasoning.\n\nI added observability to my local clinical AI agent, opened the trace viewer, and stared at a patient’s full name, date of birth, and phone number sitting in plain text in a database I’d just spun up.\n\nWith synthetic patients, that’s a shrug. Wire this into a real clinical pipeline and your observability backend quietly becomes a PHI database nobody threat-modeled. The standard fix is “redact your traces before export.” So I did: I wired in Presidio, Microsoft’s open-source PII detection library, built a ground-truth set of 752 PHI entities across 40 synthetic notes, and measured what actually leaked.\n\nThe masking pipeline never failed once. The detection underneath it failed 135 times. Refining the PHI detection got it down to 17 but that was not the most interesting finding of the experiment.\n\nDuring the detection evaluation, I realized that redacting the note is not redacting the trace. The same patient name gets…", "url": "https://wpnews.pro/news/my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it", "canonical_source": "https://pub.towardsai.net/my-clinical-ai-agents-debug-logs-were-a-phi-database-here-s-how-i-mostly-fixed-it-4326abd3f5e4?source=rss----98111c9905da---4", "published_at": "2026-07-21 22:01:02+00:00", "updated_at": "2026-07-21 22:27:10.653924+00:00", "lang": "en", "topics": ["ai-safety", "ai-ethics", "ai-agents", "artificial-intelligence"], "entities": ["Microsoft", "Presidio"], "alternates": {"html": "https://wpnews.pro/news/my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it", "markdown": "https://wpnews.pro/news/my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it.md", "text": "https://wpnews.pro/news/my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it.txt", "jsonld": "https://wpnews.pro/news/my-clinical-ai-agents-debug-logs-were-a-phi-database-heres-how-i-mostly-fixed-it.jsonld"}}