dsh-jev-context-gate: DSH Intelligent Rules and Context Gating

Introduction

When running agents in DeepSeek Harness (DSH), pressure typically arises from two types of issues: First, the context window is filled before a request is even sent, as the Skill catalog, tool status, and project instructions crowd together, causing information loss before the main model begins inference. Second, users desire a “decide, then act” flow at fixed nodes—such as screening instructions after a user message, pruning the catalog before Skill injection, or intercepting/augmenting context around tool calls—rather than relying entirely on a single guess by the main model.

The host’s built-in routing and compression capabilities act as a fallback, but they are difficult to configure for specific business logic regarding “which event triggers which content to read, which option to select, and which action to execute.” The dsh-jev-context-gate plugin (package name dsh-jev-context-gate, categorized under Workflows in the UI and displayed as “Smart rules” in the list), published by maintainer vb2250158, addresses this need. It is a DSH smart rule plugin that reads content to be judged at configurable events, uses a judgment model to answer multiple-choice questions (or score candidates), and then executes the behavior configured for the selected option. This article introduces its positioning, capabilities, and configuration key points; facts are based on the GitHub repository README. The community directory is available at the SkillHub plugin page (not officially affiliated with DeepSeek or Quantstat/Hunyuan).

What is this

  • Positioning: A smart rule plugin for DSH, accessible via Plugins → Smart Rules; configurations under DSH 0.2 are read and written using the plugin entry ID dsh-jev-context-gate.
  • Version & License: Current release package version 0.1.36 (see repository package.json); License MIT.
  • Requirements: Requires DSH 0.2.1-alpha.1 or a compatible 0.2 release; see repository docs/dsh-0.2-compatibility.md for details.
  • Judgment Method: An independent judgment model can be selected for each rule. Standard models return JSON via LLM to estimate the probability of each option; model IDs starting with jev- are marked as Jev native (native structured calls still depend on model provider support; see limitations below).

Plugin brief (English): Data-driven preflight and evidence-aware context gates for DeepSeek Harness — inserting configurable judgments and actions at key events in the request chain using data-driven preflight checks and evidence-aware context gating.

Core Features

Rule Engine (Jev)

Each rule consists of: Rule Title and Description (not sent to the judgment model), Event, Content to Judge, Question (Title + 2–16 options, or script-generated title/option text), and Options and Actions (text, action type, action parameters). The action corresponding to the highest probability option is executed only after it meets the rule threshold; actions of unselected options are not executed.

Event Types (Runtime mount points see the “Rule Semantics” table in the README):

Event Typical Use
User sends message Preflight checks, custom candidate filtering, etc.
Skill catalog ready for injection E.g., pre-configured “Skill Pruning”: scoring the brief catalog for relevance and keeping the top N entries
Skill body ready for injection Judging Jev-prepared Skills individually: continue, skip, or append context
Tool returns result Processing on streams containing tool results
Pre-tool call / Post-tool call Intercepting calls, augmenting context, sending progress or questions via Rabi, etc.

Content to Judge can come from: the latest user message, visible text in the current step, tool results for the turn, custom static text, or dynamic event parameters.

Option Sources include: Manual configuration, “Content to judge as options”, fixed content line-by-line, script generation, and for extended events, “Event parameters as options” (string or { id, text } array, combinable with thresholds, top/bottom N filtering, etc.).

Action Types examples: Augment main session context, Inject Skill body, Skip this Skill injection, Append reminder to the end of the reply, Intercept tool call, Invoke external actions (Built-in tool adapter can call any installed tool; optional rabi adapter for channel messages, etc.). Extended plugins can register events and action adapters via ctx.inject(['jev'], …) (see README 0.1.21).

Jev has a Master Switch; a Test View is provided within the rules page (“Open Test Page”); testing does not execute rules or modify the session.

Unified Context Policy (contextPolicy)

In addition to rules, the plugin provides contextPolicy (enabled by default, independent of the Jev master switch) for uniformly handling status previews, snapshots, and project instruction compression strategies in long-context scenarios:

  • Status previews only shorten structured arrays, without truncating unparseable facts or authorization text; if it cannot fit into the preview budget, the original text is retained and passed to normal compression.
  • Snapshots/catalogs are differentiated by source.kind, source.plugin, source.contextKey, and source.form for same-session identity; multiple states of the same type from the same plugin must use different contextKeys.
  • The model can read full content via context_read pagination by original index; large states show array count and a few entries in the preview, while Skill catalogs retain all names but shorten descriptions.
  • Default ratios: thresholdRatio 0.8, headroomRatio 0.06, targetRatio 0.4, retainRatio 0.16; Status preview limit 12000 characters, catalog description 96 characters, array preview 3 items, detail page 4096 characters—all modifiable via plugin configuration contextPolicy.

Prerequisites for enabling contextPolicy: The repository’s Host Patch patches/2026-10-10-request-context-policy.patch must be applied, and the affected Host packages rebuilt; enabling it without the patch will result in an error. If you do not wish to patch yet, set contextPolicy.enabled: false to retain smart rule functionality. Patch application steps are in patches/README.md (including git apply --check and notes on re-checking after upstream updates).

Summary of Preset and Extension Capabilities

  • Skill Pruning (since 0.1.14): Event is “Skill catalog ready for injection”, scores candidates for relevance, and the main model only receives retained summaries; defaults to keeping 10 items, modifiable in the rule’s “Max items to keep”.
  • Work Group Related Rules (0.1.20, disabled by default): Depends on Rabi and rabiroute_* tools; requires filling in Route ID, Group ID, and Personality ID in the edit dialog before enabling; polling after a question is held by the current DSH process and ends upon restart.
  • Dynamic Filtering (0.1.17): Returns 0–1 scores for all candidates in one request, then selects based on top N, bottom N, or percentage thresholds; candidate scripts allow 2–500 entries, total content not exceeding 64,000 characters, and retention count 1–50.

Installation and Activation

The captured materials do not provide a public one-line installation command like dsh plugin add …. The maintainer’s release workflow described in the README is: Commit and push source code and version tags → Verify remote SHA → Update fixed SHA and version in private plugins.json → Import → Restart DSH → Read back the installation package and interact via browser; it explicitly states not to use link:, file:, or workspace: as installation sources.

For actual installation, refer to the SkillHub directory page or the DSH plugin import process in your environment. Before enabling, please confirm:

  1. DSH version satisfies 0.2.1-alpha.1+ (or compatible 0.2).
  2. If contextPolicy is needed, apply the patch according to the instructions and rebuild the Host.
  3. Click this plugin in the plugin list to enter the detail page for configuration (the settings menu does not duplicate this entry).

Peer Dependencies (Excerpt, see package.json): @deepseek-ai/cordis, @deepseek-ai/dsh-llm, @deepseek-ai/dsh-tools, @deepseek-ai/dsh-skill, @deepseek-ai/dsh-settings, etc., all require the >=0.2.1-alpha.1 <0.3.0 range.

Typical Usage

1. Configure a rule in the UI

  1. Open Plugins → Smart Rules and confirm the Jev master switch is as expected.
  2. Create or edit a rule: Fill in according to Event → Content to Judge → Question → Options and Actions; save in the dialog, cancel to undo the current edit.
  3. Select a Judgment Model for rules requiring probability judgment; after saving, the content is read when the event triggers, and the action of the option reaching the threshold is executed.

For example, to enable and edit the preset Skill Pruning: change “Max items to keep” from 10 to 5, so only higher-relevance summary entries are retained before the Skill catalog is injected.

2. User Message + Custom Candidate Filtering

Add a rule: Select User sends message for the event, select Filter custom candidates for the judgment method, and enter one precaution per line; configure the question and “Max items to keep”. Selected content will be injected into the current session. You can also change the candidate source to Filter script candidates: The script runs in a local worker thread for each event (must return within 5 seconds), can read files, and returns a string array or { id, text } array.

3. Question Script (Modify title and option text only)

The script receives event, input, options and must return { title, options }; it cannot modify option actions. Example (from README):

const fs = await import('node:fs/promises')
const extra = await fs.readFile('C:/rules/question.txt', 'utf8')
return {
  title: extra.trim() + ':这条消息需要调查吗?',
  options: options.map(option => ({ id: option.id, label: option.label })),
}

Scripts have local Node privileges; only configure code you trust.

4. Extended Events (Other Plugins)

Registration and emission example (concept from README 0.1.21):

ctx.inject(['jev'], scope => scope.jev.registerEvent({ key, display, parameters }))
// The revoke function is returned by registerEvent
scope.jev.emit({ key, id, agent, parameters, signal })

In extended scenarios, emit() can return the processed parameters and per-rule selections; the event provider is responsible for writing back its own event data (e.g., replacing the catalog to be injected).

Use Cases and Notes

Who is it for

  • DSH users who need repeatable, configurable “Decision → Action” flows on the agent/pre-step or tool pipeline, without wanting to write all logic into a single prompt.
  • Scenarios with many Skills where the catalog summary consumes the window, hoping to prune the Skill catalog based on current context before passing it to the main model.
  • Teams with long sessions needing a unified context strategy (preview, snapshot, context_read pagination) and willing to apply Host patches according to the documentation.

Limitations and Risks (Explicitly stated in README)

  • Jev native structured calls are not fully integrated yet; the probabilities returned by standard models are self-reported estimates, not calibrated confidence.
  • Actions are not executed if judgment fails, script fails, no event content exists, the result is invalid, or the context budget is exceeded; the plugin does not verify factual conclusions given by the model.
  • “Append reminder to the end of the reply” happens before the original stream ends and cannot retract text already streamed.
  • The plugin runs with current DSH process privileges; question scripts and filter scripts can read local files—read the source code and MIT license before installation, and only enable trusted rules and scripts.
  • Uninstalling the plugin revokes tools and listeners, but recorded replacements still participate in session replay.

Conclusion

dsh-jev-context-gate consolidates “what to read, what to ask, and what to do upon selection” in DSH into editable smart rules, and unifies long-context preview and compression strategies under the optional contextPolicy; consistent with the “Everything is a plugin” DSH ecosystem, it is suitable for integration into session and Skill injection chains as a workflow-type extension.

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

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

Xiaoye