Skip to main content

Scanning agent transcripts for secrets, without sending them anywhere

An in-depth look at building a 100% local PII detection and masking system for AI coding agent sessions.

AI-written
Inewgen
29 Jul 2026Source: Dev.to3 min read (0 views)Last updated 02 Aug 2026
Share
Scanning agent transcripts for secrets, without sending them anywhere

Stock photo for illustration only, not from the actual event

Font size
  • Coding agent transcripts store sensitive credentials in plain text on local disk storage.
  • Cloud-based scanning creates leak risks, necessitating a 100% local processing solution.
  • A composite detector combines Regex and a 1.6 GB quantized ONNX model for high accuracy.
  • Constrained Viterbi decoding ensures precise token span masking without formatting errors.

You paste a .env into a Claude Code session to debug a failing deploy. The agent reads it, fixes the config, and moves on. Twenty minutes later the task is done and you close the terminal. The secret is still there. Not in the terminal, in the transcript. Every agent session writes a JSONL file to disk, and that file now holds your production database URL in clear text, sitting in a directory you will never think about again.

Multiply that by a few hundred sessions. That is the actual state of most machines running coding agents today. The obvious fix is to scan those transcripts and mask what you find. The obvious way to scan them is to send them to something that is good at finding secrets, which in 2026 means a cloud deployed model. To find out whether your transcripts contain credentials, you would upload all of your transcripts, including the ones that contain credentials, to a third party. The scan itself becomes the leak, which drove the requirement for a fully local solution.

Running AI models locally for security-critical tasks like credential detection is becoming an essential paradigm. As enterprises place a higher premium on strict data privacy, relying on third-party cloud infrastructure for sensitive artifacts like API tokens and database keys introduces unacceptable compliance and security surfaces.

Going local means balancing a model small enough to ship, fast enough to feel instant, and accurate enough to be worth turning on. The team's first instinct was regex, which successfully captures structured items like AWS access keys, JWTs, and credit card numbers with microsecond latency.

Never miss the latest news?

Subscribe to get news summaries by email - not often enough to be annoying.

โฆษณา

code terminal security scan

Stock photo for illustration only, not from the actual event

However, unstructured data like names, street addresses, and passphrases require a neural approach. The team integrated OpenAI's privacy filter, quantized to int8 and exported to ONNX, running through ONNX Runtime. Weights and tokenizer total just over 1.6 GB on disk, which presents a footprint challenge for a menu bar utility.

1.6 GBTotal model weights and tokenizer size on disk
33Classes per token evaluated in the BIOES scheme

To mitigate the size impact, the feature remains off by default, downloading weights on demand with SHA-256 verification. Furthermore, decoding raw token outputs utilizes a constrained Viterbi pass to eliminate illegal state transitions, ensuring that every detected credential span is fully formed and properly formatted before string-level masking takes place.

Source: Dev.to

Comments

Leave a Comment
0/2000

Found something wrong in this article? Report an issue with this article