dsh-language-guard: Locking DSH Agent's Thought and Reply Language in Long Sessions

Preface

When running agents in DeepSeek Harness (DSH), the system prompt assembles many sections such as identity, strategy, deliverable references, and more. The largest of these is the tool documentation written in English, and it lands right in the middle of the prompt. According to the official README’s test on DSH 0.2.1-rc.2: in the content after order 50, approximately 98.1% of characters come from the English tool documentation, with 5.7K–14K characters separating the first paragraph from the last. In short sessions, writing a single line “please respond in Chinese” at the top is often enough; however, once tools are called consecutively, long files are read, or long-chain reasoning is performed, internal reasoning and replies tend to slip back into English, even though your settings remain unchanged.

dsh-language-guard (Language Guard) is a DSH plugin published by community maintainer 58fly, classified under model reasoning. It injects language constraints into the beginning, middle, and end of the system prompt, and provides three strength levels, a settings panel, and a sidebar quick switch. The plugin has zero runtime dependencies, requires no build, and takes effect on the next message after configuration changes. This article organizes the installation and usage instructions based on its GitHub repository; the plugin directory page can be found at SkillHub (community directory, with no official affiliation with DeepSeek / HHTeam).

What Is This

In one sentence: dsh-language-guard constrains internal reasoning, user-visible replies, plan-type text, and the description parameter of tool calls (including the card title of run_code in PTC mode) to your selected target language via a resident system prompt section; the default target is Simplified Chinese (zh-CN), and the default strength is “Enhanced” (C).

Unlike repeatedly reminding “use Chinese” in conversations, this plugin targets the root cause of “English tool documentation pulling the model back to English”: in addition to the head and tail constraints, the Enhanced and Periodic levels insert a reaffirmation (language-guard:mid, order 5100) after all tool documentation (tools:sdk, order 5000).

Core Mechanism and Three Strength Levels

The plugin registers three never-unregistered sections via ctx.systemPrompt.section(); switching levels only changes the text:

section name order position B C D
language-guard:head -2000 very front ✅ ✅ ✅
language-guard:mid 5100 after tool documentation ❌ ✅ ✅
language-guard:tail 11200 last ✅ ✅ ✅

The resident character overhead given in the README (Simplified Chinese copy): Level B approximately 1022 characters/step, Level C approximately 1168 characters/step; the mid-section added each time for C/D levels is approximately 146 characters.

The three-level descriptions on the settings panel match the documentation:

Level Config value Description
Basic B Places a language constraint at both the beginning and end of the prompt only; lowest cost; suitable for short sessions.
Enhanced C On top of the basic level, adds a reaffirmation after the tool documentation to offset language drift caused by English tool documentation; recommended default.
Periodic D On top of Enhanced, appends a language self-check reminder at the beginning of every Nth round; suitable for long sessions; reminders appear in the session log.

The periodic level’s interval field injectEveryNRounds defaults to 8, with a range of 3–50; the reminder is injected at the first step of the matching round; the round counter does not reset after restarting or resuming a session.

Installation and Activation

Environment requirements: DSH >= 0.2.1-rc.2, Node ^22.19.0 || >=24.0.0. dependencies is empty; all peer dependencies are optional.

GUI (Recommended)

  1. Open the “Plugins” page in the sidebar.
  2. Click “Add Plugin”, and paste the package name dsh-language-guard.
  3. After installation completes, click “Enable Now”.

Command Line

dsh plugin add dsh-language-guard

Teams or CI can pin versions (README example):

dsh plugin add dsh-language-guard@0.2.1

When npm is unreachable, install from GitHub:

dsh plugin add https://github.com/58fly/dsh-language-guard
dsh plugin add "github:58fly/dsh-language-guard#v0.2.1"

Confirm successful activation: a language icon appears at the bottom of the sidebar, next to settings (when wide enough, it displays “简体中文 ▾”); the installed list on the plugin page contains dsh-language-guard and its configuration card can be opened. If no controls are visible, the plugin is usually not enabled—the configuration UI is only registered when the plugin is enabled.

Please read the repository source code and the MIT License yourself before installation. The plugin runs with the permissions of the current DSH process, sharing the same access to configuration and session data as the host.

Configuration

All seven fields are volatile: no DSH restart is needed after saving; the next message will use the new configuration.

Field Type Default Description
languageMode "" \| "auto" \| "manual" "" auto follows the interface language, manual fixes targetLanguage
targetLanguage string "zh-CN" BCP-47 label; presets include zh-CN, zh-TW, en, ja, ko
strength "B" \| "C" \| "D" "C" Strength level
injectEveryNRounds number 8 Only effective for level D, 3–50
preserveCodeTerms boolean true When true, preserves code, paths, identifiers, etc. in original form
extraRules string "" Appended after the built-in rules
overrideHead string "" If non-empty, completely replaces the built-in head section (advanced)

When hand-writing cordis.patch.yml, note: the patch replaces config entirely, so all fields must be written out, for example:

- id: dsh-language-guard
  name: dsh-language-guard
  config:
    languageMode: auto
    targetLanguage: zh-CN
    strength: C
    injectEveryNRounds: 8

In auto mode, the target language is primarily derived from the DSH “Settings → General → Language” interface language; when it cannot be read, targetLanguage serves as the fallback. In standard installations, the interface language is mostly zh or en; zh maps to zh-CN; for Traditional Chinese, Japanese, Korean, etc., switch to manual mode and select the corresponding label.

Typical Usage

Settings Panel

Path: Sidebar Plugins Page → Installed → dsh-language-guard. Here you can choose auto/manual, the three strength levels, target language, whether to preserve code terms in original form, additional rules, etc. The save prompt reads “Saved · No restart required, effective on next message”.

The language button at the bottom of the sidebar opens a dropdown menu: the first item is “Auto” (follows interface language), followed by five preset languages. Selecting one immediately writes to the configuration; selecting a specific language also sets the mode to manual.

/language Command

Only affects the memory override for this run; does not write to disk:

/language          Report current language and configuration values
/language ja       Switch to Japanese for this run
/language reset    Clear the override, return to configuration values
/language default  Same as reset

Priority: memory override > configuration value > default value.

Verifying Successful Injection

After sending a message, check system/message in the session log ~/.dsh/sessions/.../session.v4.jsonl.zstd for markers such as “【语言锁定 · 最高优先级】” (Language Lock · Highest Priority); the Enhanced level should hit all three sections: head, mid, and tail. The repository provides node scripts/verify-installed.mjs for a one-click self-check (requires zstd on the system).

Applicable Scenarios and Notes

Suitable for: DSH sessions that require long-duration reasoning and replies in the same target language; wanting tool call descriptions, plans, and sub-agent descriptions to also use a unified language; not wanting to depend on external translation services and wanting constraints completed at the generation layer.

With other plugins: If using dsh-context’s promptPrefix / promptSuffix simultaneously, it will duplicate language constraints at the same order as this plugin; the documentation recommends clearing or disabling dsh-context. The official cot-translation performs rendering-layer translation and makes network requests; this plugin does not read session content and does not make network requests—the two have different positioning and can coexist as needed.

Known boundaries (excerpt): The constraint text templates are hard-coded Simplified Chinese, only replacing the language name and code; it does not rewrite English schemas in the API tools parameter; with the absolute-lock design, a single-round “answer in English this time” will not temporarily bypass the plugin; periodic reminders are visible in the interface as “Context injection · language-guard · Language self-check”.

The DSH ecosystem advocates “everything is a plugin”; dsh-language-guard uses three system prompt anchors to fight language drift in long sessions, and uses a panel and sidebar to reduce switching costs to “effective on next message”. For more information, visit the SkillHub directory page and the GitHub repository.

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

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

Xiaoye