Foreword¶
When using DeepSeek Harness (DSH), you may occasionally encounter an HTTP 400 error with the message Content Exists Risk. This is typically caused by the request body containing specific Unicode glyphs, such as Regional Indicator Pairs (the encoding method for flag emojis). When a web page scraped by an agent contains such content, it enters the tool results and is subsequently replayed in every subsequent request, causing the entire session to fail permanently. The dsh-unicode-guard plugin aims to intercept these glyphs and replace them with readable ASCII labels to prevent session crashes.
Plugin Overview¶
dsh-unicode-guard is a DSH plugin maintained by KAsyori and licensed under the MIT License. It filters requests across three hook levels: the tool results layer, the session healing layer, and the LLM request layer. The plugin replaces Regional Indicator Pairs with labels such as [FLAG:AB] and discards Variation Selectors that immediately follow them.
Core Features¶
The plugin intervenes at three distinct producer levels:
- tools/post-execute: Rewrites tool results before they are appended to the session.
- agent/pre-step: Replaces contaminated surface nodes if the session is already affected, ensuring the next request is automatically clean.
- llm/stream: Sanitizes the request body before serialization and transmission to the adapter. This handles data such as summaries, instruction bodies, and MCP server instructions that are never transmitted as a single text stream.
Installation and Activation¶
Installing this plugin requires DSH version >= 0.1.7-rc.2.
Install via Bundle (Recommended)¶
Use the official installation command. The package includes cordis.patch.yml and will automatically insert the configuration lines:
dsh plugin add dsh-unicode-guard
Manual Installation¶
For manual configuration, you need to link the plugin directory into your config file and append the configuration to cordis.patch.yml. Modifying cordis.patch.yml supports hot reload, but adding the link itself requires a DSH restart.
Configuration¶
Configuration items are written to cordis.patch.yml via YAML. If unknown keys or incorrect value types are present, the plugin will throw an error upon mounting.
| Key | Default | Description |
|---|---|---|
mode |
regional |
Filtering mode. regional filters only Regional Indicator Pairs; astral replaces all non-BMP characters (defaulting to U+FFFD), which may break legitimate output and should be enabled with caution. |
toolResults |
true |
Whether to scrub tool results before logging. |
userMessages |
true |
Whether to scrub user messages during the healing phase. |
assistantMessages |
false |
Whether to scrub assistant messages during the healing phase. |
request |
true |
Whether to enable request scrubbing at the llm/stream level. |
verbose |
true |
Whether to log every rewrite action via ctx.logger. |
Example configuration:
- insert:
- id: unicode-guard
name: dsh-unicode-guard
config:
mode: regional
verbose: true
Verification and Usage¶
After installation, check the logs to confirm the plugin is mounted:
[I] [unicode-guard] unicode-guard: mounted (mode=regional, toolResults=true, ...)
The plugin logs rewrite behaviors, for example:
[W] [unicode-guard] unicode-guard: scrubbed the web_fetch tool result
[W] [unicode-guard] unicode-guard: healed 1 surface node(s), removed 2 glyph(s)
[W] [unicode-guard] unicode-guard: scrubbed the outgoing request
For end-to-end testing, read a file containing Regional Indicator Pairs; the tool result should display [FLAG:AB] instead of the raw emoji.
Notes¶
- Log Integrity: Healing operations do not reduce session log size. The original records are preserved on disk; only the current surface is shadowed.
- Client-Side Nature: This is a client-side robustness measure, not a substitute for server-side content filtering. If the endpoint stops rejecting these glyphs, the plugin acts merely as a harmless normalizer.
- Healing Timing: Already compromised sessions are healed automatically in the next turn; no retry is required.
Conclusion¶
dsh-unicode-guard resolves the session deadlock issue caused by specific glyphs triggering HTTP 400 errors by sanitizing the data before it enters the model-visible surface. It preserves information readability through ASCII labels while removing the bytes that corrupt the request.