dsh-text-guard: A DeepSeek Harness Plugin for Neutralizing Configured Code Point Sequences Before Session Logging

Introduction

DeepSeek Harness (DSH) runs in an environment that requires session logs to be recorded, and the official DeepSeek API is highly sensitive to certain specific text sequences. For example, certain regional indicator symbol pairs (such as U+1F1F9 followed by U+1F1FC, i.e., flag emoji) will be directly rejected by the API with a 400 error. Since DSH’s mechanism requires resending history records with each request, once the log contains these rejected sequences, subsequent rounds of the entire session will be blocked.

dsh-text-guard is a plugin designed for this purpose. It neutralizes configured codepoint sequences before content enters the session log.

Plugin Overview

This is a DeepSeek Harness plugin maintained by developer 7771sd. It focuses on resolving the issue where the API rejects requests due to specific text sequences, thereby breaking session continuity. Its core value lies in intercepting and replacing these sensitive sequences during the logging phase, ensuring the session can continue normally.

Core Functionality

The plugin works by hooking into three specific hook points, rewriting content before it is written to the log:

  1. tools/post-execute: Intercepts tool execution results, including web scraping, file reading, command output, etc.
  2. tools/ptc-dispatch-log: Intercepts persistent log copies dispatched by the run_code sub-dispatcher.
  3. agent/pre-step: Intercepts messages entering a step, including text pasted by users.

For non-matching sequences, content remains unchanged with its original object identity preserved, without affecting performance.

Installation and Activation

Install using the Harness CLI, no build step or additional dependencies required:

dsh plugin --profile <profile> add github:7771sd/dsh-text-guard

After installation, the plugin is mounted into “wide mode” via a patch.

Configuration

The configuration file is located at cordis.patch.yml. By default, the plugin enables wide mode when mounted, but all fields can be overridden in your configuration file.

Configuration example:

- id: text-guard
  config:
    mode: exact
    sequences: [[0x1F1F9, 0x1F1FC]]
    replacement: '[flag U+{codepoints}]'
    toolResults: true
    userMessages: true
    log: true

Key field descriptions:

  • mode: Matching mode. Defaults to regional-pairs (matching any two consecutive regional indicators); when set to exact, only matches the configured sequences.
  • sequences: List of codepoint sequences to neutralize (effective in exact mode).
  • replacement: Replacement text template, using the {codepoints} placeholder to insert matched codepoints.
  • toolResults / userMessages / log: Controls at which stages neutralization and logging are enabled.

Note: Configuration changes cannot be hot-reloaded. The plugin package must be remounted (disabled and re-enabled) to take effect.

Use Cases and Considerations

Use cases:
When your agent needs to call external tools (such as browser scraping, file system reading/writing), the output may contain text rejected by the API. Using this plugin prevents this content from entering the session log, avoiding subsequent request blocking.

Limitations and considerations:
1. Lossy replacement: The plugin’s design is inherently lossy. If the original text must be preserved verbatim, do not mount this plugin.
2. System prompts not covered: Text injected into requests via skill files or instruction files (the system prompt section) does not pass through this interception point and is not protected.
3. Log inconsistency: Neutralized user messages appear as replaced text in server-side logs, while the client interface still shows the original text you sent, resulting in inconsistency between the two.
4. Environment requirements: Requires Node.js version ^22.19 or >=24.

Conclusion

dsh-text-guard resolves the session crash issue caused by API content risk filtering. By performing ASCII replacement before logging, it ensures the replayability of session history. For more details, please refer to the project homepage.

Plugin Directory Page
GitHub Repository

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye