Introduction¶
When running agents in DeepSeek Harness (DSH), user inputs, system prompts, workspace instructions, session recalls, and tool file read results are all included in requests sent to model providers. If these contain email addresses, phone numbers, API keys, or bank card numbers, this sensitive data leaves the local machine. Common practices involve post-hoc log auditing or appending notices via Hooks. However, in the DSH Claude Code / Codex Hook protocol, updatedInput is documented as “parsed but not applied,” meaning it cannot modify the prompts and tool results about to be sent. Native Cordis plugins, however, can replace detected PII with placeholders at the entry point of the agent loop before passing the data to the upstream model.
Below is an introduction to the community plugin dsh-pii-anonymizer (Maintainer: JWE24-code, Category: admin-security). It performs deterministic, one-way PII anonymization on “all text sent to the model” at the start of the agent loop. Detection relies on fixed rules and checksums, without calling a model.
What is this¶
dsh-pii-anonymizer is a native DSH bundle plugin (npm package name dsh-pii-anonymizer, current version 0.2.1, MIT License). Before requests leave the local machine, it uses rules to detect structured PII and replaces it with keyed placeholders like [[EMAIL_3f9a2c1d]]. Local session logs still record your input as-is; files on disk and tool output content itself are not rewritten by the plugin.
Mount Points and Rewriting Scope¶
Each listener is registered with prepend: true, positioning them at the outermost layer of the corresponding waterfall, rewriting the final text after other plugins have contributed.
| Hook | Package | Rewriting Target |
|---|---|---|
system-prompt/assemble |
dsh-system-prompt |
Prompt sections, runtime context, string-type prompt variables |
agent/pre-step |
dsh-agent-loop |
Every message text block entering the model in this step (user prompts, snapshots, AGENTS.md, recall, relay, skill directories, tool-attached context, etc.) |
tools/post-execute |
dsh-tools |
Tool result content read by the model, block decision feedback, and attached context |
The README clarifies: External Hook bridging cannot achieve the same coverage; only native plugins can replace the messages, prompts, and tool results entering model requests.
Detection Types and Placeholders¶
Detection is deterministic: syntax or checksums, no ML/NER used. Context-dependent PII such as free-text names or zip-code addresses is intentionally not detected to avoid false positives.
| Type | Trigger Condition | Validation |
|---|---|---|
API_KEY |
sk-, sk-ant-, AKIA…, ghp_… and other known prefixes |
— |
IBAN |
Formats like CC00… |
mod-97 |
CREDIT_CARD |
13–19 digits (may contain spaces/hyphens) | Luhn |
SSN |
DDD-DD-DDDD |
— |
EMAIL |
RFC-style address | — |
IPV4 / IPV6 |
Address form | IPv4 octet range |
PHONE |
7–15 digits with common separators | Excludes ISO dates, version numbers, etc. |
The placeholder format is [[TYPE_<hash>]], where <hash> is the first 8 hex characters of HMAC-SHA256(secret, type + normalized value). The same real value produces consistent placeholders across sessions, sub-agents, and restarts; the plugin does not store a “value → placeholder” mapping table, making it one-way and impossible to restore plaintext from the plugin side.
The secret key is defaulted to $DSH_HOME/pii-anonymizer.key (i.e., ~/.dsh/pii-anonymizer.key), generating 32 random bytes with 0600 permissions on first use. Deleting the key file will cause all subsequent placeholders to change; if the key file cannot be read or written, it falls back to an in-process key. Replacement still occurs but is unstable across restarts.
Behavior Example¶
When you type a sentence containing PII in a conversation, the model side sees placeholders and may receive a user-role notification (containing only type and count, no real values or placeholder strings). The local transcript retains the original text. The illustration in the README:
you type: email a@x.com or call +31 6 1234 5678
model sees: email [[EMAIL_6c1f0a9e]] or call [[PHONE_d24b7c03]]
+ notice(PII shield: 2 item(s)...)
local log: as you typed
To disable notifications, set notify: false in the config.
Coverage and Non-Coverage¶
Will Rewrite (Model-facing text): User prompts and all injected messages in the current step; system prompts and runtime context; tool result bodies via tools/post-execute (including errors returned by tools).
Will Not Rewrite: Local session logs, transcripts, memory, and plaintext in files on disk; complete: true system-prompt sections (restored by the framework after assembly); tool schemas; the few tool result paths that skip post-execute; assistant replies themselves (placeholders are not restored in output). PII not covered by detection rules (such as names or addresses) is still sent as-is.
If fields like IPs in workspace instructions must be visible to the model, you can disable specific channels: systemPrompt: false or toolResults: false.
Installation and Activation¶
The package is a DSH bundle: package.json declares dsh.bundle.patch, and cordis.patch.yml inserts the pii-anonymizer line; the profile needs to list it in both dependencies and dsh.profile.bundles.
Install in the profile directory (e.g., ~/.dsh/profiles/<name>):
npm install dsh-pii-anonymizer
Or via the terminal application:
/plugins add dsh-pii-anonymizer
For local checkouts, you can modify the manifest using node tools/register-profile.mjs ~/.dsh/profiles/tui (this creates a package.json.bak), and ensure the profile can resolve the package, for example:
ln -s "$PWD" ~/.dsh/profiles/node_modules/dsh-pii-anonymizer
Restart the DSH application after installation to load the plugin; to rollback, restore the corresponding profile’s package.json.bak.
Runtime requirement: Node.js >= 20 (see engines in package.json).
Configuration¶
Set the plugin id pii-anonymizer in the profile’s Cordis configuration:
- id: pii-anonymizer
name: dsh-pii-anonymizer
config:
enabled: true # Master switch
notify: true # Insert notification message if this step's input contains PII
debug: false # Only log count-based shield events, do not log values
systemPrompt: true # Rewrite system prompt + runtime context
toolResults: true # Rewrite tool result content
keyFile: '' # If empty, uses $DSH_HOME/pii-anonymizer.key
Use Cases and Notes¶
It is suitable for daily development, debugging, or automated agents in DSH to reduce the probability of structured sensitive information such as emails, keys, and card numbers entering third-party model requests, while maintaining consistent placeholder semantics across multi-turn dialogues (e.g., [[EMAIL_…]] written to memory still refers to the same address).
Please read the repository source code and MIT License yourself before use; the plugin runs with the current DSH process permissions, and local plaintext still exists in $DSH_HOME and workspace files. The protection boundary is the “outbound request,” not full-disk encryption or DLP. The community directory SkillHub Plugin Page and the GitHub repository are maintained by the community and are not officially affiliated with DeepSeek / High-Flyer; the DSH ecosystem itself is “everything is a plugin,” so verifying sources and configurations before installing third-party bundles is standard practice.
Conclusion¶
dsh-pii-anonymizer performs rule-based PII replacement on prompts, context, and tool results sent to models at the earliest stage of the agent loop. The keyed placeholders are stable across sessions and irreversible, filling the gap left by external Hooks that cannot rewrite inputs. For details and end-to-end testing instructions, see GitHub: JWE24-code/dsh-pii-anonymizer, and for the directory index, see SkillHub.