@xpert-ai/plugin-sensitive-filter from xpert-plugins, used to filter sensitive content on both agent input and output stages.
Typical Use Cases
- Filter PII such as ID numbers, phone numbers, and bank cards
- Block high-risk content directly
- Rewrite recoverable content into a safe response
Install and Enable
- Install the plugin package in your host project:
- Enable the plugin through environment variables:
- Follow Publish & Use to ensure the host loads the plugin.
Runtime Hooks
beforeAgent: evaluate and optionally rewrite/block inputwrapModelCall: evaluate and optionally rewrite/block model outputafterAgent: write audit snapshot
Configuration Modes
The middleware has two mutually exclusive modes:rule: deterministic rules (keyword/regex)llm: natural-language policy evaluation (LLM hits are enforced in rewrite behavior)
Minimal Rule Mode Example
rule mode, each rule should include:
pattern, type, scope, severity, and action.
Minimal LLM Mode Example
llm mode, runtime-required fields are:
model, scope, and rulePrompt.
Validation Checklist
- Validate the hit path in
rulemode first. - Then switch to
llmmode and validate semantic policy behavior. - Verify that audit records include hit details for both input and output phases when expected.
Troubleshooting
- No effect in
rulemode: usually caused by incomplete rule fields or mismatchedscope. - No effect in
llmmode: confirmmodel,scope, andrulePromptare all present. - Unexpected LLM rewrite behavior: inspect audit traces for policy fallback/error hints.