dsh-insert-context: Inject reminders into the agent context according to step count

Introduction

Agents within DeepSeek Harness (DSH) execute many consecutive steps within a single task: calling tools, modifying files, and reasoning. As the step count rises, models tend to “forget” the delivery standards or convergence rhythms you emphasized at the beginning within the long context. Common workarounds include repeating the same sentence in every user message or stacking rules in the system prompt—the former wastes tokens, while the latter only takes effect at the start of the session and may not be re-read during intermediate steps.

dsh-insert-context (Maintainer: ADkun, Category: Workflow) does something different: during the task execution process, following a step rhythm you define, it inserts a configurable reminder into the agent’s own context; you can also choose whether to append a sentence to the end of user messages. All three capabilities have independent toggles and a master switch, configured entirely through the DSH settings page without requiring code changes. Current version 1.5.0, License MIT, Runtime requirement Node.js >= 22.

What is this

In one sentence: Before every admitted step of an agent, it listens to agent/pre-step, injects context messages according to rules, and can rewrite upcoming user messages.

The plugin is divided into a host-side (index.js) and a browser settings page (client.js). The settings entry is located at Settings → 过程插入 (or Context insertion in English interfaces), listed after Our Free Model. Community directory page: skillhub.cn/plugins/ADkun/dsh-insert-context; Source code and full documentation: github.com/ADkun/dsh-insert-context.

Core Features

The following explains the three types of behavior based on the README; if any category is turned off and unconfigured, no corresponding injection will occur.

Master Switch (enabled)

Defaults to On. When turned off, the plugin becomes completely silent: it does not inject rule messages, does not append user sentences, and the step counter pauses. When turned back on, counting resumes from where it paused, preventing multiple rules from triggering consecutively due to steps “missed” during the silent period.

Rule Injection (rules)

Each rule is an object { start, every, repeat, text }, meaning: Starting from step start, trigger once every every steps, for a total of repeat times; repeat of 0 indicates unlimited times.

Examples of hit step sets (consistent with official documentation):

Rule Hit Steps
{ start: 10, every: 10, repeat: 0 } 10, 20, 30, 40, … (Infinite)
{ start: 5, every: 5, repeat: 9 } 5, 10, 15, …, 45 (Total 9 times)
{ start: 60, every: 10, repeat: 5 } 60, 70, 80, 90, 100

When the current step falls within the hit set, the text is injected into the agent as an additional context message. Only the placeholder {{step}} is supported in text, which will be replaced by the current step number; this placeholder is not supported in appendText. Other {{…}} patterns will be injected as-is, and the host will output a warning log with the insert-context: prefix.

When multiple rules hit the same step, they are merged into a single message: the paragraphs from each rule are joined by newlines according to their order in the settings page, and each paragraph replaces {{step}} individually.

There is only one built-in default rule (this is the behavior immediately after installation when userAppend is off by default):

现在是第 {{step}} 步,注意任务收敛进度。

Corresponding schedule: start: 10, every: 10, repeat: 0 (Infinite).

User Message Appending (userAppend / appendText)

Defaults to Off (userAppend: false). When enabled, it appends a sentence from appendText to the end of the user message you send. The built-in default text (the square brackets are part of the text and are only used when the append switch is on) is:

[注:回复不复述过程,结构清晰可读性好。]

There are two related switches:

  • appendFirstOnly (Default On): Only append after the first user message in the session to avoid repeating the same sentence every turn.
  • appendSubagents (Default Off): Whether to also append to user-type messages sent to sub-agents via delegate / send_message.

When userAppend is enabled, if the last text block of the message already ends with appendText, that message is skipped to avoid trailing duplication.

Step Counting and Deduplication

  • Counting is independent per agent ID: The scheduler and sub-agents each have their own set of counts; a sub-agent at its step 5 will hit { start: 5, … } according to its own steps, regardless of the parent agent’s current step count.
  • Steps rejected by downstream are not counted; steps during the period when the master switch is off are also not counted.
  • The counter is cleared after the agent is destroyed (agent/disposed); counting starts from when the plugin mount becomes effective.
  • If a user message has already been modified by appending in a certain step, no rule message is injected in that same step to avoid duplicate reminders in the same batch of context.

Configuration Fields Overview

The fields saved on the settings page match the config shape in cordis.patch.yml (excerpt of default values):

enabled: true
rules:
  - start: 10
    every: 10
    repeat: 0
    text: '现在是第 {{step}} 步,注意任务收敛进度。'
userAppend: false
appendFirstOnly: true
appendSubagents: false
appendText: '[注:回复不复述过程,结构清晰可读性好。]'
Field Type Default Description
enabled boolean true Master switch
rules Array of rules See above No rule injection if empty array
rules[].start 1–100000 10 First hit step
rules[].every 1–1000 10 Interval
rules[].repeat 0–1000 0 Number of hits; 0 = Infinite
rules[].text String ≤1000 See above Injection text
userAppend boolean false Whether to append user sentence
appendFirstOnly boolean true Whether only for the first user message
appendSubagents boolean false Whether to include sub-agent messages
appendText String ≤1000 See above Appended content

The settings page saves to $DSH_PROFILE_DIR/insert-context.json (falling back to $DSH_HOME, then ~/.dsh) with permission 0600. After clicking Save on the settings page, it takes effect on the next step without needing a restart; manual JSON editing requires the plugin to remount (restart DSH or trigger hot reload). Priority: Settings page file > cordis.patch.yml line configuration > Code built-in defaults.

Installation and Activation

The installation method provided in the README is to add the plugin package directory to DSH, with an example of a local path (please replace with the actual directory on your machine):

dsh plugin add D:\dsh\dsh-insert-context

You can also select the same directory as the installation target in the DSH plugin manager. After installation, open Settings → 过程插入 (Context insertion), and confirm that the master switch and rule preview meet expectations; enable the “Append User Message” related switches if user-side tone constraints are needed.

Typical Usage

1. Remind for convergence using only the default rhythm

Keep factory defaults: Master switch on, userAppend off. Long tasks will inject “Pay attention to task convergence progress” once every 10 steps starting from step 10, with the current step number automatically included in the text.

2. Dense early reminders, different wording later

Add multiple rule lines in the settings page, for example, first { start: 5, every: 5, repeat: 9 } covering steps 5–45, then { start: 60, every: 10, repeat: 5 } covering steps 60–100; the text for each line can contain different convergence or delivery boundary descriptions. The README also provides several example texts (not default), which can be copied to new rule lines for use.

3. Add a sentence regarding output format at the beginning of the session

Enable userAppend and keep appendFirstOnly: true (default). Only the first user message will carry [Note: The reply should not recount the process; ensure clear structure and readability.] at the end, without repeating it in subsequent turns.

4. Read/write configuration via HTTP (Optional)

If there is a webServer carrier in the environment, the plugin registers /api/insert-context/settings (GET / POST / DELETE), which can be used for scripts or automation; requests must satisfy the trust boundaries in the README (local Host, same origin, etc.). General users can primarily use the settings page.

Use Cases and Notes

Suitable for DSH users who need periodic reminders during the middle stages of long tasks but do not want to copy and paste the same paragraph into every user input. In parallel sub-agent or delegation scenarios, you can design different rule densities based on independent step counting per agent.

Please note before use:

  • The plugin runs with the current DSH process privileges. Please review the source code and the MIT license yourself before installation.
  • Community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer; plugin star counts are based on the directory page (currently 0).
  • Modifying the built-in defaults in cordis.patch.yml or index.js usually requires remounting the plugin line to take effect; using the settings page Save for daily rule tuning is the most convenient.

Conclusion

dsh-insert-context turns “what to remind at which step” into a configurable schedule: rule injection, {{step}} placeholders, user message appending, and the master switch are all completed on the Context insertion page. For details, example texts, and API tables, please refer to the GitHub README.

  • Directory Page: https://www.skillhub.cn/plugins/ADkun/dsh-insert-context
  • Repository: https://github.com/ADkun/dsh-insert-context
羽毛球分组比赛记分
小程序二维码

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

Xiaoye